element which will serve as the element's context menu.
- dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
- draggable: Defines whether the element can be dragged.
- enter_key_hint: Hints what media types the media element is able to play.
- hidden: Defines whether the element is hidden.
- input_mode: Defines the type of the element.
- item_prop: Defines the name of the element for metadata purposes.
- lang: Defines the language used in the element.
- role: Defines the role of the element.
- slot: Assigns a slot in a shadow DOM shadow tree to an element.
- spell_check: Defines whether the element may be checked for spelling errors.
- tab_index: Defines the position of the current element in the tabbing order.
- title: Defines a tooltip for the element.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the form.
-
- Returns:
- The form component.
- """
- ...
-
-class FormControl(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- label=None,
- input=None,
- help_text=None,
- error_message=None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_invalid: Optional[Union[Var[bool], bool]] = None,
- is_read_only: Optional[Union[Var[bool], bool]] = None,
- is_required: Optional[Union[Var[bool], bool]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "FormControl":
- """Create a form control component.
-
- Args:
- *children: The children of the form control.
- label: The label of the form control.
- input: The input of the form control.
- help_text: The help text of the form control.
- error_message: The error message of the form control.
- is_disabled: If true, the form control will be disabled.
- is_invalid: If true, the form control will be invalid.
- is_read_only: If true, the form control will be readonly
- is_required: If true, the form control will be required.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the form control.
-
- Raises:
- AttributeError: raise an error if missing required kwargs.
-
- Returns:
- The form control component.
- """
- ...
-
-class FormHelperText(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "FormHelperText":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class FormLabel(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- html_for: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "FormLabel":
- """Create the component.
-
- Args:
- *children: The children of the component.
- html_for: Link
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class FormErrorMessage(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "FormErrorMessage":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/forms/iconbutton.py b/reflex/components/chakra/forms/iconbutton.py
deleted file mode 100644
index 10e3d3a6f..000000000
--- a/reflex/components/chakra/forms/iconbutton.py
+++ /dev/null
@@ -1,38 +0,0 @@
-"""An icon button component."""
-
-from typing import Optional
-
-from reflex.components.chakra.typography.text import Text
-from reflex.components.component import Component
-from reflex.vars import Var
-
-
-class IconButton(Text):
- """A button with an icon."""
-
- tag = "IconButton"
- library = "@chakra-ui/button@2.1.0"
-
- # The type of button.
- type: Var[str]
-
- # A label that describes the button
- aria_label: Var[str]
-
- # The icon to be used in the button.
- icon: Optional[Component]
-
- # If true, the button will be styled in its active state.
- is_active: Var[bool]
-
- # If true, the button will be disabled.
- is_disabled: Var[bool]
-
- # If true, the button will show a spinner.
- is_loading: Var[bool]
-
- # If true, the button will be perfectly round. Else, it'll be slightly round
- is_round: Var[bool]
-
- # Replace the spinner component when isLoading is set to true
- spinner: Var[str]
diff --git a/reflex/components/chakra/forms/iconbutton.pyi b/reflex/components/chakra/forms/iconbutton.pyi
deleted file mode 100644
index a98d4d23d..000000000
--- a/reflex/components/chakra/forms/iconbutton.pyi
+++ /dev/null
@@ -1,108 +0,0 @@
-"""Stub file for reflex/components/chakra/forms/iconbutton.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
-
-from reflex.components.chakra.typography.text import Text
-from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class IconButton(Text):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- type: Optional[Union[Var[str], str]] = None,
- aria_label: Optional[Union[Var[str], str]] = None,
- icon: Optional[Component] = None,
- is_active: Optional[Union[Var[bool], bool]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_loading: Optional[Union[Var[bool], bool]] = None,
- is_round: Optional[Union[Var[bool], bool]] = None,
- spinner: Optional[Union[Var[str], str]] = None,
- as_: Optional[Union[Var[str], str]] = None,
- no_of_lines: Optional[Union[Var[int], int]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "IconButton":
- """Create the component.
-
- Args:
- *children: The children of the component.
- type: The type of button.
- aria_label: A label that describes the button
- icon: The icon to be used in the button.
- is_active: If true, the button will be styled in its active state.
- is_disabled: If true, the button will be disabled.
- is_loading: If true, the button will show a spinner.
- is_round: If true, the button will be perfectly round. Else, it'll be slightly round
- spinner: Replace the spinner component when isLoading is set to true
- as_: Override the tag. The default tag is ``.
- no_of_lines: Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/forms/input.py b/reflex/components/chakra/forms/input.py
deleted file mode 100644
index c162a776f..000000000
--- a/reflex/components/chakra/forms/input.py
+++ /dev/null
@@ -1,130 +0,0 @@
-"""An input component."""
-
-from reflex.components.chakra import (
- ChakraComponent,
- LiteralButtonSize,
- LiteralInputVariant,
-)
-from reflex.components.component import Component
-from reflex.components.core.debounce import DebounceInput
-from reflex.components.literals import LiteralInputType
-from reflex.constants import MemoizationMode
-from reflex.event import EventHandler
-from reflex.utils.imports import ImportDict
-from reflex.vars import Var
-
-
-class Input(ChakraComponent):
- """The Input component is a component that is used to get user input in a text field."""
-
- tag = "Input"
-
- # State var to bind the input.
- value: Var[str]
-
- # The default value of the input.
- default_value: Var[str]
-
- # The placeholder text.
- placeholder: Var[str]
-
- # The type of input.
- type_: Var[LiteralInputType]
-
- # The border color when the input is invalid.
- error_border_color: Var[str]
-
- # The border color when the input is focused.
- focus_border_color: Var[str]
-
- # If true, the form control will be disabled. This has 2 side effects - The FormLabel will have `data-disabled` attribute - The form element (e.g, Input) will be disabled
- is_disabled: Var[bool]
-
- # If true, the form control will be invalid. This has 2 side effects - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true
- is_invalid: Var[bool]
-
- # If true, the form control will be readonly.
- is_read_only: Var[bool]
-
- # If true, the form control will be required. This has 2 side effects - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true
- is_required: Var[bool]
-
- # "outline" | "filled" | "flushed" | "unstyled"
- variant: Var[LiteralInputVariant]
-
- # "lg" | "md" | "sm" | "xs"
- size: Var[LiteralButtonSize]
-
- # The name of the form field
- name: Var[str]
-
- # Fired when the input value changes.
- on_change: EventHandler[lambda e0: [e0.target.value]]
-
- # Fired when the input is focused.
- on_focus: EventHandler[lambda e0: [e0.target.value]]
-
- # Fired when the input lose focus.
- on_blur: EventHandler[lambda e0: [e0.target.value]]
-
- # Fired when a key is pressed down.
- on_key_down: EventHandler[lambda e0: [e0.key]]
-
- # Fired when a key is released.
- on_key_up: EventHandler[lambda e0: [e0.key]]
-
- def add_imports(self) -> ImportDict:
- """Add imports for the Input component.
-
- Returns:
- The import dict.
- """
- return {"/utils/state": "set_val"}
-
- @classmethod
- def create(cls, *children, **props) -> Component:
- """Create an Input component.
-
- Args:
- *children: The children of the component.
- **props: The properties of the component.
-
- Returns:
- The component.
- """
- if props.get("value") is not None and props.get("on_change") is not None:
- # create a debounced input if the user requests full control to avoid typing jank
- return DebounceInput.create(super().create(*children, **props))
- return super().create(*children, **props)
-
-
-class InputGroup(ChakraComponent):
- """The InputGroup component is a component that is used to group a set of inputs."""
-
- tag = "InputGroup"
-
- _memoization_mode = MemoizationMode(recursive=False)
-
-
-class InputLeftAddon(ChakraComponent):
- """The InputLeftAddon component is a component that is used to add an addon to the left of an input."""
-
- tag = "InputLeftAddon"
-
-
-class InputRightAddon(ChakraComponent):
- """The InputRightAddon component is a component that is used to add an addon to the right of an input."""
-
- tag = "InputRightAddon"
-
-
-class InputLeftElement(ChakraComponent):
- """The InputLeftElement component is a component that is used to add an element to the left of an input."""
-
- tag = "InputLeftElement"
-
-
-class InputRightElement(ChakraComponent):
- """The InputRightElement component is a component that is used to add an element to the right of an input."""
-
- tag = "InputRightElement"
diff --git a/reflex/components/chakra/forms/input.pyi b/reflex/components/chakra/forms/input.pyi
deleted file mode 100644
index fcf61c888..000000000
--- a/reflex/components/chakra/forms/input.pyi
+++ /dev/null
@@ -1,566 +0,0 @@
-"""Stub file for reflex/components/chakra/forms/input.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import (
- ChakraComponent,
-)
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.utils.imports import ImportDict
-from reflex.vars import BaseVar, Var
-
-class Input(ChakraComponent):
- def add_imports(self) -> ImportDict: ...
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- value: Optional[Union[Var[str], str]] = None,
- default_value: Optional[Union[Var[str], str]] = None,
- placeholder: Optional[Union[Var[str], str]] = None,
- type_: Optional[
- Union[
- Var[
- Literal[
- "button",
- "checkbox",
- "color",
- "date",
- "datetime-local",
- "email",
- "file",
- "hidden",
- "image",
- "month",
- "number",
- "password",
- "radio",
- "range",
- "reset",
- "search",
- "submit",
- "tel",
- "text",
- "time",
- "url",
- "week",
- ]
- ],
- Literal[
- "button",
- "checkbox",
- "color",
- "date",
- "datetime-local",
- "email",
- "file",
- "hidden",
- "image",
- "month",
- "number",
- "password",
- "radio",
- "range",
- "reset",
- "search",
- "submit",
- "tel",
- "text",
- "time",
- "url",
- "week",
- ],
- ]
- ] = None,
- error_border_color: Optional[Union[Var[str], str]] = None,
- focus_border_color: Optional[Union[Var[str], str]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_invalid: Optional[Union[Var[bool], bool]] = None,
- is_read_only: Optional[Union[Var[bool], bool]] = None,
- is_required: Optional[Union[Var[bool], bool]] = None,
- variant: Optional[
- Union[
- Var[Literal["outline", "filled", "flushed", "unstyled"]],
- Literal["outline", "filled", "flushed", "unstyled"],
- ]
- ] = None,
- size: Optional[
- Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]]
- ] = None,
- name: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_key_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Input":
- """Create an Input component.
-
- Args:
- *children: The children of the component.
- value: State var to bind the input.
- default_value: The default value of the input.
- placeholder: The placeholder text.
- type_: The type of input.
- error_border_color: The border color when the input is invalid.
- focus_border_color: The border color when the input is focused.
- is_disabled: If true, the form control will be disabled. This has 2 side effects - The FormLabel will have `data-disabled` attribute - The form element (e.g, Input) will be disabled
- is_invalid: If true, the form control will be invalid. This has 2 side effects - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true
- is_read_only: If true, the form control will be readonly.
- is_required: If true, the form control will be required. This has 2 side effects - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true
- variant: "outline" | "filled" | "flushed" | "unstyled"
- size: "lg" | "md" | "sm" | "xs"
- name: The name of the form field
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Returns:
- The component.
- """
- ...
-
-class InputGroup(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "InputGroup":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class InputLeftAddon(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "InputLeftAddon":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class InputRightAddon(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "InputRightAddon":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class InputLeftElement(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "InputLeftElement":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class InputRightElement(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "InputRightElement":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/forms/multiselect.py b/reflex/components/chakra/forms/multiselect.py
deleted file mode 100644
index 3d52d4bbe..000000000
--- a/reflex/components/chakra/forms/multiselect.py
+++ /dev/null
@@ -1,355 +0,0 @@
-"""Provides a feature-rich Select and some (not all) related components."""
-
-from __future__ import annotations
-
-from typing import Any, Dict, List, Optional, Set, Union
-
-from reflex.base import Base
-from reflex.components.component import Component
-from reflex.constants import EventTriggers
-from reflex.vars import Var
-
-
-class Option(Base):
- """An option component for the chakra-react-select Select."""
-
- # What is displayed to the user
- label: str
-
- # The value of the option, must be serializable
- value: Any
-
- # the variant of the option tag
- variant: Optional[str] = None
-
- # [not working yet]
- # Whether the option is disabled
- # is_disabled: Optional[bool] = None
-
- # [not working yet]
- # The visual color appearance of the component
- # options: "whiteAlpha" | "blackAlpha" | "gray" | "red" |
- # "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" |
- # "purple" | "pink" | "linkedin" | "facebook" | "messenger" |
- # "whatsapp" | "twitter" | "telegram"
- # default: "gray"
- # color_scheme: Optional[str] = None
-
- # [not working yet]
- # The icon of the option tag
- # icon: Optional[str] = None
-
-
-class Select(Component):
- """The default chakra-react-select Select component.
- Not every available prop is listed here,
- for a complete overview check the react-select/chakra-react-select docs.
- Props added by chakra-react-select are marked with "[chakra]".
- """
-
- library = "chakra-react-select@4.7.5"
- tag = "Select"
- alias = "MultiSelect"
-
- # Focus the control when it is mounted
- auto_focus: Var[bool]
-
- # Remove the currently focused option when the user presses backspace
- # when Select isClearable or isMulti
- backspace_removes_value: Var[bool]
-
- # Remove focus from the input when the user selects an option
- # (handy for dismissing the keyboard on touch devices)
- blur_input_on_select: Var[bool]
-
- # When the user reaches the top/bottom of the menu,
- # prevent scroll on the scroll-parent
- capture_menu_scroll: Var[bool]
-
- # [chakra]
- # To use the chakraStyles prop, first,
- # check the documentation for the original styles prop from the react-select docs.
- # This package offers an identical API for the chakraStyles prop, however,
- # the provided and output style objects use Chakra's sx prop
- # instead of the default emotion styles the original package offers.
- # This allows you to both use the shorthand styling props you'd normally use
- # to style Chakra components, as well as tokens from your theme such as named colors.
- # All of the style keys offered in the original package can be used in the chakraStyles prop
- # except for menuPortal. Along with some other caveats, this is explained below.
- # Most of the components rendered by this package use the basic Chakra component with a few exceptions.
- # Here are the style keys offered and the corresponding Chakra component that is rendered:
- # - clearIndicator - Box (uses theme styles for Chakra's CloseButton)
- # - container - Box
- # - control - Box (uses theme styles for Chakra's Input)
- # - dropdownIndicator - Box (uses theme styles for Chrakra's InputRightAddon)
- # - downChevron - Icon
- # - crossIcon - Icon
- # - group - Box
- # - groupHeading - Box (uses theme styles for Chakra's Menu group title)
- # - indicatorsContainer - Box
- # - indicatorSeparator - Divider
- # - input - chakra.input (wrapped in a Box)
- # - inputContainer - Box
- # - loadingIndicator - Spinner
- # - loadingMessage - Box
- # - menu - Box
- # - menuList - Box (uses theme styles for Chakra's Menu)
- # - multiValue - chakra.span (uses theme styles for Chakra's Tag)
- # - multiValueLabel - chakra.span (uses theme styles for Chakra's TagLabel)
- # - multiValueRemove - Box (uses theme styles for Chakra's TagCloseButton)
- # - noOptionsMessage - Box
- # - option - Box (uses theme styles for Chakra's MenuItem)
- # - placeholder - Box
- # - singleValue - Box
- # - valueContainer - Box
- chakra_styles: Var[str]
-
- # Close the select menu when the user selects an option
- close_menu_on_select: Var[bool]
-
- # If true, close the select menu when the user scrolls the document/body.
- close_menu_on_scroll: Var[bool]
-
- # [chakra]
- # The visual color appearance of the component
- # options: "whiteAlpha" | "blackAlpha" | "gray" | "red" |
- # "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" |
- # "purple" | "pink" | "linkedin" | "facebook" | "messenger" |
- # "whatsapp" | "twitter" | "telegram"
- # default: "gray"
- color_scheme: Var[str]
-
- # This complex object includes all the compositional components
- # that are used in react-select. If you wish to overwrite a component,
- # pass in an object with the appropriate namespace.
- # If you only wish to restyle a component,
- # we recommend using the styles prop instead.
- components: Var[Dict[str, Component]]
-
- # Whether the value of the select, e.g. SingleValue,
- # should be displayed in the control.
- control_should_render_value: Var[bool]
-
- # Delimiter used to join multiple values into a single HTML Input value
- delimiter: Var[str]
-
- # [chakra]
- # Colors the component border with the given chakra color string on error state
- # default: "red.500"
- error_border_color: Var[str]
-
- # Clear all values when the user presses escape AND the menu is closed
- escape_clears_value: Var[bool]
-
- # [chakra]
- # Colors the component border with the given chakra color string on focus
- # default: "blue.500"
- focus_border_color: Var[str]
-
- # Sets the form attribute on the input
- form: Var[str]
-
- # Hide the selected option from the menu
- hide_selected_options: Var[bool]
-
- # The id to set on the SelectContainer component.
- # id: Var[str]
-
- # The value of the search input
- input_value: Var[str]
-
- # The id of the search input
- input_id: Var[str]
-
- # Is the select value clearable
- is_clearable: Var[bool]
-
- # Is the select disabled
- is_disabled: Var[bool]
-
- # [chakra]
- # Style component in the chakra invalid style
- # default: False
- is_invalid: Var[bool]
-
- # Support multiple selected options
- is_multi: Var[bool]
-
- # [chakra]
- # Style component as disabled (chakra style)
- # default: False
- is_read_only: Var[bool]
-
- # Is the select direction right-to-left
- is_rtl: Var[bool]
-
- # Whether to enable search functionality
- is_searchable: Var[bool]
-
- # Minimum height of the menu before flipping
- min_menu_height: Var[int]
-
- # Maximum height of the menu before scrolling
- max_menu_height: Var[int]
-
- # Default placement of the menu in relation to the control.
- # 'auto' will flip when there isn't enough space below the control.
- # options: "bottom" | "auto" | "top"
- menu_placement: Var[str]
-
- # The CSS position value of the menu,
- # when "fixed" extra layout management is required
- # options: "absolute" | "fixed"
- menu_position: Var[str]
-
- # Whether to block scroll events when the menu is open
- menu_should_block_scroll: Var[bool]
-
- # Whether the menu should be scrolled into view when it opens
- menu_should_scroll_into_view: Var[bool]
-
- # Name of the HTML Input (optional - without this, no input will be rendered)
- name: Var[str]
-
- # Allows control of whether the menu is opened when the Select is focused
- open_menu_on_focus: Var[bool]
-
- # Allows control of whether the menu is opened when the Select is clicked
- open_menu_on_click: Var[bool]
-
- # Array of options that populate the select menu
- options: Var[List[Dict]]
-
- # Number of options to jump in menu when page{up|down} keys are used
- page_size: Var[int]
-
- # Placeholder for the select value
- placeholder: Var[Optional[str]]
-
- # Marks the value-holding input as required for form validation
- required: Var[bool]
-
- # [chakra]
- # If you choose to stick with the default selectedOptionStyle="color",
- # you have one additional styling option.
- # If you do not like the default of blue for the highlight color,
- # you can pass the selectedOptionColorScheme prop to change it.
- # This prop will accept any named color from your theme's color palette,
- # and it will use the 500 value in light mode or the 300 value in dark mode.
- # This prop can only be used for named colors from your theme, not arbitrary hex/rgb colors.
- # If you would like to use a specific color for the background that's not a part of your theme,
- # use the chakraStyles prop to customize it.
- # default: "blue"
- selected_option_color_scheme: Var[str]
-
- # [chakra]
- # The default option "color" will style a selected option
- # similar to how react-select does it,
- # by highlighting the selected option in the color blue.
- # Alternatively, if you pass "check" for the value,
- # the selected option will be styled like the Chakra UI Menu component
- # and include a check icon next to the selected option(s).
- # If is_multi and selected_option_style="check" are passed,
- # space will only be added for the check marks
- # if hide_selected_options=False is also passed.
- # options: "color" | "check"
- # default: "color"
- selected_option_style: Var[str]
-
- # [chakra]
- # The size of the component.
- # options: "sm" | "md" | "lg"
- # default: "md"
- size: Var[str]
-
- # Sets the tabIndex attribute on the input
- tab_index: Var[int]
-
- # Select the currently focused option when the user presses tab
- tab_selects_value: Var[bool]
-
- # [chakra]
- # Variant of multi-select tags
- # options: "subtle" | "solid" | "outline"
- # default: "subtle"
- tag_variant: Var[str]
-
- # Remove all non-essential styles
- unstyled: Var[bool]
-
- # [chakra]
- # If this prop is passed,
- # the dropdown indicator at the right of the component will be styled
- # in the same way the original Chakra Select component is styled,
- # instead of being styled as an InputRightAddon.
- # The original purpose of styling it as an addon
- # was to create a visual separation between the dropdown indicator
- # and the button for clearing the selected options.
- # However, as this button only appears when isMulti is passed,
- # using this style could make more sense for a single select.
- # default: False
- use_basic_style: Var[bool]
-
- # [chakra]
- # The variant of the Select. If no variant is passed,
- # it will default to defaultProps.variant from the theme for Chakra's Input component.
- # If your component theme for Input is not modified, it will be outline.
- # options: "outline" | "filled" | "flushed" | "unstyled"
- # default: "outline"
- variant: Var[str]
-
- # How the options should be displayed in the menu.
- menu_position: Var[str] = "fixed" # type: ignore
-
- def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
- """Get the event triggers that pass the component's value to the handler.
-
- Returns:
- A dict mapping the event trigger to the var that is passed to the handler.
- """
- return {
- **super().get_event_triggers(),
- EventTriggers.ON_CHANGE: (
- lambda e0: [
- Var.create_safe(f"{e0}.map(e => e.value)", _var_is_local=True)
- ]
- if self.is_multi.equals(Var.create_safe(True))
- else lambda e0: [e0]
- ),
- }
-
- @classmethod
- def get_initial_props(cls) -> Set[str]:
- """Get the initial props to set for the component.
-
- Returns:
- The initial props to set.
- """
- return super().get_initial_props() | {"is_multi"}
-
- @classmethod
- def create(
- cls, options: List[Union[Option, str, int, float, bool]], **props
- ) -> Component:
- """Takes a list of options and additional properties, checks if each option is an
- instance of Option, and returns a Select component with the given options and
- properties. No children allowed.
-
- Args:
- options (List[Option | str | int | float | bool]): A list of values.
- **props: Additional properties to be passed to the Select component.
-
- Returns:
- The `create` method is returning an instance of the `Select` class.
- """
- converted_options: List[Option] = []
- if not isinstance(options, Var):
- for option in options:
- if not isinstance(option, Option):
- converted_options.append(Option(label=str(option), value=option))
- else:
- converted_options.append(option)
- props["options"] = [o.dict() for o in converted_options]
- else:
- props["options"] = options
- return super().create(*[], **props)
diff --git a/reflex/components/chakra/forms/numberinput.py b/reflex/components/chakra/forms/numberinput.py
deleted file mode 100644
index 39956840d..000000000
--- a/reflex/components/chakra/forms/numberinput.py
+++ /dev/null
@@ -1,128 +0,0 @@
-"""A number input component."""
-
-from numbers import Number
-
-from reflex.components.chakra import (
- ChakraComponent,
- LiteralButtonSize,
- LiteralInputVariant,
-)
-from reflex.components.component import Component
-from reflex.event import EventHandler
-from reflex.vars import Var
-
-
-class NumberInput(ChakraComponent):
- """The wrapper that provides context and logic to the components."""
-
- tag = "NumberInput"
-
- # State var to bind the input.
- value: Var[Number]
-
- # If true, the input's value will change based on mouse wheel.
- allow_mouse_wheel: Var[bool]
-
- # This controls the value update when you blur out of the input. - If true and the value is greater than max, the value will be reset to max - Else, the value remains the same.
- clamped_value_on_blur: Var[bool]
-
- # The initial value of the counter. Should be less than max and greater than min
- default_value: Var[Number]
-
- # The border color when the input is invalid.
- error_border_color: Var[str]
-
- # The border color when the input is focused.
- focus_border_color: Var[str]
-
- # If true, the input will be focused as you increment or decrement the value with the stepper
- focus_input_on_change: Var[bool]
-
- # Hints at the type of data that might be entered by the user. It also determines the type of keyboard shown to the user on mobile devices ("text" | "search" | "none" | "tel" | "url" | "email" | "numeric" | "decimal")
- # input_mode: Var[LiteralInputNumberMode]
-
- # Whether the input should be disabled.
- is_disabled: Var[bool]
-
- # If true, the input will have `aria-invalid` set to true
- is_invalid: Var[bool]
-
- # If true, the input will be in readonly mode
- is_read_only: Var[bool]
-
- # Whether the input is required
- is_required: Var[bool]
-
- # Whether the pressed key should be allowed in the input. The default behavior is to allow DOM floating point characters defined by /^[Ee0-9+\-.]$/
- is_valid_character: Var[str]
-
- # This controls the value update behavior in general. - If true and you use the stepper or up/down arrow keys, the value will not exceed the max or go lower than min - If false, the value will be allowed to go out of range.
- keep_within_range: Var[bool]
-
- # The maximum value of the counter
- max_: Var[Number]
-
- # The minimum value of the counter
- min_: Var[Number]
-
- # "outline" | "filled" | "flushed" | "unstyled"
- variant: Var[LiteralInputVariant]
-
- # "lg" | "md" | "sm" | "xs"
- size: Var[LiteralButtonSize]
-
- # The name of the form field
- name: Var[str]
-
- # Fired when the input value changes.
- on_change: EventHandler[lambda e0: [e0]]
-
- @classmethod
- def create(cls, *children, **props) -> Component:
- """Create a number input component.
-
- If no children are provided, a default stepper will be used.
-
- Args:
- *children: The children of the component.
- **props: The props of the component.
-
- Returns:
- The component.
- """
- if len(children) == 0:
- _id = props.pop("id", None)
- children = [
- NumberInputField.create(id=_id)
- if _id is not None
- else NumberInputField.create(),
- NumberInputStepper.create(
- NumberIncrementStepper.create(),
- NumberDecrementStepper.create(),
- ),
- ]
- return super().create(*children, **props)
-
-
-class NumberInputField(ChakraComponent):
- """The input field itself."""
-
- tag = "NumberInputField"
-
-
-class NumberInputStepper(ChakraComponent):
- """The wrapper for the input's stepper buttons."""
-
- tag = "NumberInputStepper"
-
-
-class NumberIncrementStepper(ChakraComponent):
- """The button to increment the value of the input."""
-
- tag = "NumberIncrementStepper"
-
-
-class NumberDecrementStepper(ChakraComponent):
- """The button to decrement the value of the input."""
-
- tag = "NumberDecrementStepper"
diff --git a/reflex/components/chakra/forms/numberinput.pyi b/reflex/components/chakra/forms/numberinput.pyi
deleted file mode 100644
index 521fcdd74..000000000
--- a/reflex/components/chakra/forms/numberinput.pyi
+++ /dev/null
@@ -1,442 +0,0 @@
-"""Stub file for reflex/components/chakra/forms/numberinput.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from numbers import Number
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import (
- ChakraComponent,
-)
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class NumberInput(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- value: Optional[Union[Var[Number], Number]] = None,
- allow_mouse_wheel: Optional[Union[Var[bool], bool]] = None,
- clamped_value_on_blur: Optional[Union[Var[bool], bool]] = None,
- default_value: Optional[Union[Var[Number], Number]] = None,
- error_border_color: Optional[Union[Var[str], str]] = None,
- focus_border_color: Optional[Union[Var[str], str]] = None,
- focus_input_on_change: Optional[Union[Var[bool], bool]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_invalid: Optional[Union[Var[bool], bool]] = None,
- is_read_only: Optional[Union[Var[bool], bool]] = None,
- is_required: Optional[Union[Var[bool], bool]] = None,
- is_valid_character: Optional[Union[Var[str], str]] = None,
- keep_within_range: Optional[Union[Var[bool], bool]] = None,
- max_: Optional[Union[Var[Number], Number]] = None,
- min_: Optional[Union[Var[Number], Number]] = None,
- variant: Optional[
- Union[
- Var[Literal["outline", "filled", "flushed", "unstyled"]],
- Literal["outline", "filled", "flushed", "unstyled"],
- ]
- ] = None,
- size: Optional[
- Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]]
- ] = None,
- name: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "NumberInput":
- """Create a number input component.
-
- If no children are provided, a default stepper will be used.
-
- Args:
- *children: The children of the component.
- value: State var to bind the input.
- allow_mouse_wheel: If true, the input's value will change based on mouse wheel.
- clamped_value_on_blur: This controls the value update when you blur out of the input. - If true and the value is greater than max, the value will be reset to max - Else, the value remains the same.
- default_value: The initial value of the counter. Should be less than max and greater than min
- error_border_color: The border color when the input is invalid.
- focus_border_color: The border color when the input is focused.
- focus_input_on_change: If true, the input will be focused as you increment or decrement the value with the stepper
- is_disabled: Hints at the type of data that might be entered by the user. It also determines the type of keyboard shown to the user on mobile devices ("text" | "search" | "none" | "tel" | "url" | "email" | "numeric" | "decimal") input_mode: Var[LiteralInputNumberMode] Whether the input should be disabled.
- is_invalid: If true, the input will have `aria-invalid` set to true
- is_read_only: If true, the input will be in readonly mode
- is_required: Whether the input is required
- is_valid_character: Whether the pressed key should be allowed in the input. The default behavior is to allow DOM floating point characters defined by /^[Ee0-9+\\-.]$/
- keep_within_range: This controls the value update behavior in general. - If true and you use the stepper or up/down arrow keys, the value will not exceed the max or go lower than min - If false, the value will be allowed to go out of range.
- max_: The maximum value of the counter
- min_: The minimum value of the counter
- variant: "outline" | "filled" | "flushed" | "unstyled"
- size: "lg" | "md" | "sm" | "xs"
- name: The name of the form field
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class NumberInputField(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "NumberInputField":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class NumberInputStepper(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "NumberInputStepper":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class NumberIncrementStepper(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "NumberIncrementStepper":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class NumberDecrementStepper(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "NumberDecrementStepper":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/forms/password.py b/reflex/components/chakra/forms/password.py
deleted file mode 100644
index 100bb6151..000000000
--- a/reflex/components/chakra/forms/password.py
+++ /dev/null
@@ -1,11 +0,0 @@
-"""A password input component."""
-
-from reflex.components.chakra.forms.input import Input
-from reflex.vars import Var
-
-
-class Password(Input):
- """A password input component."""
-
- # The type of input.
- type_: Var[str] = "password" # type: ignore
diff --git a/reflex/components/chakra/forms/password.pyi b/reflex/components/chakra/forms/password.pyi
deleted file mode 100644
index 8d2a02109..000000000
--- a/reflex/components/chakra/forms/password.pyi
+++ /dev/null
@@ -1,129 +0,0 @@
-"""Stub file for reflex/components/chakra/forms/password.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra.forms.input import Input
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Password(Input):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- type_: Optional[Union[Var[str], str]] = None,
- value: Optional[Union[Var[str], str]] = None,
- default_value: Optional[Union[Var[str], str]] = None,
- placeholder: Optional[Union[Var[str], str]] = None,
- error_border_color: Optional[Union[Var[str], str]] = None,
- focus_border_color: Optional[Union[Var[str], str]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_invalid: Optional[Union[Var[bool], bool]] = None,
- is_read_only: Optional[Union[Var[bool], bool]] = None,
- is_required: Optional[Union[Var[bool], bool]] = None,
- variant: Optional[
- Union[
- Var[Literal["outline", "filled", "flushed", "unstyled"]],
- Literal["outline", "filled", "flushed", "unstyled"],
- ]
- ] = None,
- size: Optional[
- Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]]
- ] = None,
- name: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_key_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Password":
- """Create an Input component.
-
- Args:
- *children: The children of the component.
- type_: The type of input.
- value: State var to bind the input.
- default_value: The default value of the input.
- placeholder: The placeholder text.
- error_border_color: The border color when the input is invalid.
- focus_border_color: The border color when the input is focused.
- is_disabled: If true, the form control will be disabled. This has 2 side effects - The FormLabel will have `data-disabled` attribute - The form element (e.g, Input) will be disabled
- is_invalid: If true, the form control will be invalid. This has 2 side effects - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true
- is_read_only: If true, the form control will be readonly.
- is_required: If true, the form control will be required. This has 2 side effects - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true
- variant: "outline" | "filled" | "flushed" | "unstyled"
- size: "lg" | "md" | "sm" | "xs"
- name: The name of the form field
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/forms/pininput.py b/reflex/components/chakra/forms/pininput.py
deleted file mode 100644
index 7e075887e..000000000
--- a/reflex/components/chakra/forms/pininput.py
+++ /dev/null
@@ -1,201 +0,0 @@
-"""A pin input component."""
-
-from __future__ import annotations
-
-from typing import Optional
-
-from reflex.components.chakra import ChakraComponent, LiteralInputVariant
-from reflex.components.component import Component
-from reflex.components.tags.tag import Tag
-from reflex.event import EventHandler
-from reflex.utils import format
-from reflex.utils.imports import ImportDict, merge_imports
-from reflex.vars import Var
-
-
-class PinInput(ChakraComponent):
- """The component that provides context to all the pin-input fields."""
-
- tag = "PinInput"
-
- # State var to bind the input.
- value: Var[str]
-
- # If true, the pin input receives focus on mount
- auto_focus: Var[bool]
-
- # The default value of the pin input
- default_value: Var[str]
-
- # The border color when the input is invalid.
- error_border_color: Var[str]
-
- # The border color when the input is focused.
- focus_border_color: Var[str]
-
- # The top-level id string that will be applied to the input fields. The index of the input will be appended to this top-level id.
- id_: Var[str]
-
- # The length of the number input.
- length: Var[int]
-
- # If true, the pin input component is put in the disabled state
- is_disabled: Var[bool]
-
- # If true, the pin input component is put in the invalid state
- is_invalid: Var[bool]
-
- # If true, focus will move automatically to the next input once filled
- manage_focus: Var[bool]
-
- # If true, the input's value will be masked just like `type=password`
- mask: Var[bool]
-
- # The placeholder for the pin input
- placeholder: Var[str]
-
- # The type of values the pin-input should allow ("number" | "alphanumeric").
- type_: Var[str]
-
- # "outline" | "flushed" | "filled" | "unstyled"
- variant: Var[LiteralInputVariant]
-
- # The name of the form field
- name: Var[str]
-
- # Fired when the pin input is changed.
- on_change: EventHandler[lambda e0: [e0]]
-
- # Fired when the pin input is completed.
- on_complete: EventHandler[lambda e0: [e0]]
-
- def _get_imports(self) -> ImportDict:
- """Include PinInputField explicitly because it may not be a child component at compile time.
-
- Returns:
- The merged import dict.
- """
- range_var = Var.range(0)
- return merge_imports(
- super()._get_imports(),
- PinInputField()._get_all_imports(), # type: ignore
- range_var._var_data.imports if range_var._var_data is not None else {},
- )
-
- def get_ref(self) -> str | None:
- """Override ref handling to handle array refs.
-
- PinInputFields may be created dynamically, so it's not possible
- to compute their ref at compile time, so we return a cheating
- guess if the id is specified.
-
- The `ref` for this outer component will always be stripped off, so what
- is returned here only matters for form ref collection purposes.
-
- Returns:
- None.
- """
- if any(isinstance(c, PinInputField) for c in self.children):
- return None
- if self.id:
- return format.format_array_ref(self.id, idx=self.length)
- return super().get_ref()
-
- def _get_ref_hook(self) -> Optional[str]:
- """Override the base _get_ref_hook to handle array refs.
-
- Returns:
- The overrided hooks.
- """
- if self.id:
- ref = format.format_array_ref(self.id, None)
- refs_declaration = Var.range(self.length).foreach(
- lambda: Var.create_safe("useRef(null)", _var_is_string=False),
- )
- refs_declaration._var_is_local = True
- if ref:
- return (
- f"const {ref} = {str(refs_declaration)}; "
- f"{str(Var.create_safe(ref, _var_is_string=False).as_ref())} = {ref}"
- )
- return super()._get_ref_hook()
-
- def _render(self) -> Tag:
- """Override the base _render to remove the fake get_ref.
-
- Returns:
- The rendered component.
- """
- return super()._render().remove_props("ref")
-
- @classmethod
- def create(cls, *children, **props) -> Component:
- """Create a pin input component.
-
- If no children are passed in, the component will create a default pin input
- based on the length prop.
-
- Args:
- *children: The children of the component.
- **props: The props of the component.
-
- Returns:
- The pin input component.
- """
- if children:
- props.pop("length", None)
- elif "length" in props:
- field_props = {}
- if "id" in props:
- field_props["id"] = props["id"]
- if "name" in props:
- field_props["name"] = props["name"]
- children = [
- PinInputField.for_length(props["length"], **field_props),
- ]
- return super().create(*children, **props)
-
-
-class PinInputField(ChakraComponent):
- """The text field that user types in - must be a direct child of PinInput."""
-
- tag = "PinInputField"
-
- # the position of the PinInputField inside the PinInput.
- # Default to None because it is assigned by PinInput when created.
- index: Optional[Var[int]] = None
-
- # The name of the form field
- name: Var[str]
-
- @classmethod
- def for_length(cls, length: Var | int, **props) -> Var:
- """Create a PinInputField for a PinInput with a given length.
-
- Args:
- length: The length of the PinInput.
- props: The props of each PinInputField (name will become indexed).
-
- Returns:
- The PinInputField.
- """
- name = props.get("name")
-
- def _create(i):
- if name is not None:
- props["name"] = f"{name}-{i}"
- return PinInputField.create(**props, index=i, key=i)
-
- return Var.range(length).foreach(_create) # type: ignore
-
- def _get_ref_hook(self) -> Optional[str]:
- return None
-
- def get_ref(self):
- """Get the array ref for the pin input.
-
- Returns:
- The array ref.
- """
- if self.id:
- return format.format_array_ref(self.id, self.index)
diff --git a/reflex/components/chakra/forms/pininput.pyi b/reflex/components/chakra/forms/pininput.pyi
deleted file mode 100644
index c8f5cc878..000000000
--- a/reflex/components/chakra/forms/pininput.pyi
+++ /dev/null
@@ -1,215 +0,0 @@
-"""Stub file for reflex/components/chakra/forms/pininput.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class PinInput(ChakraComponent):
- def get_ref(self) -> str | None: ...
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- value: Optional[Union[Var[str], str]] = None,
- auto_focus: Optional[Union[Var[bool], bool]] = None,
- default_value: Optional[Union[Var[str], str]] = None,
- error_border_color: Optional[Union[Var[str], str]] = None,
- focus_border_color: Optional[Union[Var[str], str]] = None,
- id_: Optional[Union[Var[str], str]] = None,
- length: Optional[Union[Var[int], int]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_invalid: Optional[Union[Var[bool], bool]] = None,
- manage_focus: Optional[Union[Var[bool], bool]] = None,
- mask: Optional[Union[Var[bool], bool]] = None,
- placeholder: Optional[Union[Var[str], str]] = None,
- type_: Optional[Union[Var[str], str]] = None,
- variant: Optional[
- Union[
- Var[Literal["outline", "filled", "flushed", "unstyled"]],
- Literal["outline", "filled", "flushed", "unstyled"],
- ]
- ] = None,
- name: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_complete: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "PinInput":
- """Create a pin input component.
-
- If no children are passed in, the component will create a default pin input
- based on the length prop.
-
- Args:
- *children: The children of the component.
- value: State var to bind the input.
- auto_focus: If true, the pin input receives focus on mount
- default_value: The default value of the pin input
- error_border_color: The border color when the input is invalid.
- focus_border_color: The border color when the input is focused.
- id_: The top-level id string that will be applied to the input fields. The index of the input will be appended to this top-level id.
- length: The length of the number input.
- is_disabled: If true, the pin input component is put in the disabled state
- is_invalid: If true, the pin input component is put in the invalid state
- manage_focus: If true, focus will move automatically to the next input once filled
- mask: If true, the input's value will be masked just like `type=password`
- placeholder: The placeholder for the pin input
- type_: The type of values the pin-input should allow ("number" | "alphanumeric").
- variant: "outline" | "flushed" | "filled" | "unstyled"
- name: The name of the form field
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The pin input component.
- """
- ...
-
-class PinInputField(ChakraComponent):
- @classmethod
- def for_length(cls, length: Var | int, **props) -> Var: ...
- def get_ref(self): ...
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- index: Optional[Union[Var[int], int]] = None,
- name: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "PinInputField":
- """Create the component.
-
- Args:
- *children: The children of the component.
- index: the position of the PinInputField inside the PinInput. Default to None because it is assigned by PinInput when created.
- name: The name of the form field
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/forms/radio.py b/reflex/components/chakra/forms/radio.py
deleted file mode 100644
index d43327935..000000000
--- a/reflex/components/chakra/forms/radio.py
+++ /dev/null
@@ -1,101 +0,0 @@
-"""A radio component."""
-
-from typing import Any, List
-
-from reflex.components.chakra import ChakraComponent
-from reflex.components.chakra.typography.text import Text
-from reflex.components.component import Component
-from reflex.components.core.foreach import Foreach
-from reflex.event import EventHandler
-from reflex.utils.types import _issubclass
-from reflex.vars import Var
-
-
-class RadioGroup(ChakraComponent):
- """A grouping of individual radio options."""
-
- tag = "RadioGroup"
-
- # State var to bind the input.
- value: Var[Any]
-
- # The default value.
- default_value: Var[Any]
-
- # The name of the form field
- name: Var[str]
-
- # Fired when the radio group value changes.
- on_change: EventHandler[lambda e0: [e0]]
-
- @classmethod
- def create(cls, *children, **props) -> Component:
- """Create a radio group component.
-
- Args:
- *children: The children of the component.
- **props: The props of the component.
-
- Returns:
- The component.
- """
- if len(children) == 1 and isinstance(children[0], list):
- children = [Radio.create(child) for child in children[0]]
- if (
- len(children) == 1
- and isinstance(children[0], Var)
- and _issubclass(children[0]._var_type, List)
- ):
- children = [Foreach.create(children[0], lambda item: Radio.create(item))]
- return super().create(*children, **props)
-
-
-class Radio(Text):
- """Radios are used when only one choice may be selected in a series of options."""
-
- tag = "Radio"
-
- # Value of radio.
- value: Var[Any]
-
- # The default value.
- default_value: Var[Any]
-
- # The color scheme.
- color_scheme: Var[str]
-
- # If true, the radio will be initially checked.
- default_checked: Var[bool]
-
- # If true, the radio will be checked. You'll need to pass onChange to update its value (since it is now controlled)
- is_checked: Var[bool]
-
- # If true, the radio will be disabled.
- is_disabled: Var[bool]
-
- # If true, the radio button will be invalid. This also sets `aria-invalid` to true.
- is_invalid: Var[bool]
-
- # If true, the radio will be read-only
- is_read_only: Var[bool]
-
- # If true, the radio button will be required. This also sets `aria-required` to true.
- is_required: Var[bool]
-
- @classmethod
- def create(cls, *children, **props) -> Component:
- """Create a radio component.
-
- By default, the value is bound to the first child.
-
- Args:
- *children: The children of the component.
- **props: The props of the component.
-
- Returns:
- The radio component.
- """
- if "value" not in props:
- assert len(children) == 1
- props["value"] = children[0]
- return super().create(*children, **props)
diff --git a/reflex/components/chakra/forms/radio.pyi b/reflex/components/chakra/forms/radio.pyi
deleted file mode 100644
index 9d9eb06a8..000000000
--- a/reflex/components/chakra/forms/radio.pyi
+++ /dev/null
@@ -1,197 +0,0 @@
-"""Stub file for reflex/components/chakra/forms/radio.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.components.chakra.typography.text import Text
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class RadioGroup(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- value: Optional[Union[Var[Any], Any]] = None,
- default_value: Optional[Union[Var[Any], Any]] = None,
- name: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "RadioGroup":
- """Create a radio group component.
-
- Args:
- *children: The children of the component.
- value: State var to bind the input.
- default_value: The default value.
- name: The name of the form field
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class Radio(Text):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- value: Optional[Union[Var[Any], Any]] = None,
- default_value: Optional[Union[Var[Any], Any]] = None,
- color_scheme: Optional[Union[Var[str], str]] = None,
- default_checked: Optional[Union[Var[bool], bool]] = None,
- is_checked: Optional[Union[Var[bool], bool]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_invalid: Optional[Union[Var[bool], bool]] = None,
- is_read_only: Optional[Union[Var[bool], bool]] = None,
- is_required: Optional[Union[Var[bool], bool]] = None,
- as_: Optional[Union[Var[str], str]] = None,
- no_of_lines: Optional[Union[Var[int], int]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Radio":
- """Create a radio component.
-
- By default, the value is bound to the first child.
-
- Args:
- *children: The children of the component.
- value: Value of radio.
- default_value: The default value.
- color_scheme: The color scheme.
- default_checked: If true, the radio will be initially checked.
- is_checked: If true, the radio will be checked. You'll need to pass onChange to update its value (since it is now controlled)
- is_disabled: If true, the radio will be disabled.
- is_invalid: If true, the radio button will be invalid. This also sets `aria-invalid` to true.
- is_read_only: If true, the radio will be read-only
- is_required: If true, the radio button will be required. This also sets `aria-required` to true.
- as_: Override the tag. The default tag is `
`.
- no_of_lines: Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The radio component.
- """
- ...
diff --git a/reflex/components/chakra/forms/rangeslider.py b/reflex/components/chakra/forms/rangeslider.py
deleted file mode 100644
index 9e0c179b8..000000000
--- a/reflex/components/chakra/forms/rangeslider.py
+++ /dev/null
@@ -1,149 +0,0 @@
-"""A range slider component."""
-
-from __future__ import annotations
-
-from typing import List, Optional
-
-from reflex.components.chakra import ChakraComponent, LiteralChakraDirection
-from reflex.components.component import Component
-from reflex.event import EventHandler
-from reflex.utils import format
-from reflex.vars import Var
-
-
-class RangeSlider(ChakraComponent):
- """The RangeSlider is a multi thumb slider used to select a range of related values. A common use-case of this component is a price range picker that allows a user to set the minimum and maximum price."""
-
- tag = "RangeSlider"
-
- # State var to bind the input.
- value: Var[List[int]]
-
- # The default values.
- default_value: Var[List[int]]
-
- # The writing mode ("ltr" | "rtl")
- direction: Var[LiteralChakraDirection]
-
- # If false, the slider handle will not capture focus when value changes.
- focus_thumb_on_change: Var[bool]
-
- # If true, the slider will be disabled
- is_disabled: Var[bool]
-
- # If true, the slider will be in `read-only` state.
- is_read_only: Var[bool]
-
- # If true, the value will be incremented or decremented in reverse.
- is_reversed: Var[bool]
-
- # The minimum value of the slider.
- min_: Var[int]
-
- # The maximum value of the slider.
- max_: Var[int]
-
- # The minimum distance between slider thumbs. Useful for preventing the thumbs from being too close together.
- min_steps_between_thumbs: Var[int]
-
- # The name of the form field
- name: Var[str]
-
- # Fired when the value changes.
- on_change: EventHandler[lambda e0: [e0]]
-
- # Fired when the value starts changing.
- on_change_start: EventHandler[lambda e0: [e0]]
-
- # Fired when the value stops changing.
- on_change_end: EventHandler[lambda e0: [e0]]
-
- def get_ref(self):
- """Get the ref of the component.
-
- Returns:
- The ref of the component.
- """
- return None
-
- def _get_ref_hook(self) -> Optional[str]:
- """Override the base _get_ref_hook to handle array refs.
-
- Returns:
- The overrided hooks.
- """
- if self.id:
- ref = format.format_array_ref(self.id, None)
- if ref:
- return (
- f"const {ref} = Array.from({{length:2}}, () => useRef(null)); "
- f"{str(Var.create_safe(ref, _var_is_string=False).as_ref())} = {ref}"
- )
- return super()._get_ref_hook()
-
- @classmethod
- def create(cls, *children, **props) -> Component:
- """Create a RangeSlider component.
-
- If no children are provided, a default RangeSlider will be created.
-
- Args:
- *children: The children of the component.
- **props: The properties of the component.
-
- Returns:
- The RangeSlider component.
- """
- if len(children) == 0:
- _id = props.get("id", None)
- if _id:
- children = [
- RangeSliderTrack.create(
- RangeSliderFilledTrack.create(),
- ),
- RangeSliderThumb.create(index=0, id=_id),
- RangeSliderThumb.create(index=1, id=_id),
- ]
- else:
- children = [
- RangeSliderTrack.create(
- RangeSliderFilledTrack.create(),
- ),
- RangeSliderThumb.create(index=0),
- RangeSliderThumb.create(index=1),
- ]
- return super().create(*children, **props)
-
-
-class RangeSliderTrack(ChakraComponent):
- """A range slider track."""
-
- tag = "RangeSliderTrack"
-
-
-class RangeSliderFilledTrack(ChakraComponent):
- """A filled range slider track."""
-
- tag = "RangeSliderFilledTrack"
-
-
-class RangeSliderThumb(ChakraComponent):
- """A range slider thumb."""
-
- tag = "RangeSliderThumb"
-
- # The position of the thumb.
- index: Var[int]
-
- def _get_ref_hook(self) -> Optional[str]:
- # hook is None because RangeSlider is handling it.
- return None
-
- def get_ref(self):
- """Get an array ref for the range slider thumb.
-
- Returns:
- The array ref.
- """
- if self.id:
- return format.format_array_ref(self.id, self.index)
diff --git a/reflex/components/chakra/forms/rangeslider.pyi b/reflex/components/chakra/forms/rangeslider.pyi
deleted file mode 100644
index 38ca43f73..000000000
--- a/reflex/components/chakra/forms/rangeslider.pyi
+++ /dev/null
@@ -1,354 +0,0 @@
-"""Stub file for reflex/components/chakra/forms/rangeslider.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class RangeSlider(ChakraComponent):
- def get_ref(self): ...
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- value: Optional[Union[Var[List[int]], List[int]]] = None,
- default_value: Optional[Union[Var[List[int]], List[int]]] = None,
- direction: Optional[
- Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]
- ] = None,
- focus_thumb_on_change: Optional[Union[Var[bool], bool]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_read_only: Optional[Union[Var[bool], bool]] = None,
- is_reversed: Optional[Union[Var[bool], bool]] = None,
- min_: Optional[Union[Var[int], int]] = None,
- max_: Optional[Union[Var[int], int]] = None,
- min_steps_between_thumbs: Optional[Union[Var[int], int]] = None,
- name: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change_end: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change_start: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "RangeSlider":
- """Create a RangeSlider component.
-
- If no children are provided, a default RangeSlider will be created.
-
- Args:
- *children: The children of the component.
- value: State var to bind the input.
- default_value: The default values.
- direction: The writing mode ("ltr" | "rtl")
- focus_thumb_on_change: If false, the slider handle will not capture focus when value changes.
- is_disabled: If true, the slider will be disabled
- is_read_only: If true, the slider will be in `read-only` state.
- is_reversed: If true, the value will be incremented or decremented in reverse.
- min_: The minimum value of the slider.
- max_: The maximum value of the slider.
- min_steps_between_thumbs: The minimum distance between slider thumbs. Useful for preventing the thumbs from being too close together.
- name: The name of the form field
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Returns:
- The RangeSlider component.
- """
- ...
-
-class RangeSliderTrack(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "RangeSliderTrack":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class RangeSliderFilledTrack(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "RangeSliderFilledTrack":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class RangeSliderThumb(ChakraComponent):
- def get_ref(self): ...
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- index: Optional[Union[Var[int], int]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "RangeSliderThumb":
- """Create the component.
-
- Args:
- *children: The children of the component.
- index: The position of the thumb.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/forms/select.py b/reflex/components/chakra/forms/select.py
deleted file mode 100644
index 3c25ea8b9..000000000
--- a/reflex/components/chakra/forms/select.py
+++ /dev/null
@@ -1,103 +0,0 @@
-"""A select component."""
-
-from typing import Any, List
-
-from reflex.components.chakra import ChakraComponent, LiteralInputVariant
-from reflex.components.chakra.typography.text import Text
-from reflex.components.component import Component
-from reflex.components.core.foreach import Foreach
-from reflex.event import EventHandler
-from reflex.utils.types import _issubclass
-from reflex.vars import Var
-
-
-class Select(ChakraComponent):
- """Select component is a component that allows users pick a value from predefined options. Ideally, it should be used when there are more than 5 options, otherwise you might consider using a radio group instead."""
-
- tag = "Select"
-
- # State var to bind the select.
- value: Var[str]
-
- # The default value of the select.
- default_value: Var[str]
-
- # The placeholder text.
- placeholder: Var[str]
-
- # The border color when the select is invalid.
- error_border_color: Var[str]
-
- # The border color when the select is focused.
- focus_border_color: Var[str]
-
- # If true, the select will be disabled.
- is_disabled: Var[bool]
-
- # If true, the form control will be invalid. This has 2 side effects: - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true
- is_invalid: Var[bool]
-
- # If true, the form control will be required. This has 2 side effects: - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true
- is_required: Var[bool]
-
- # "outline" | "filled" | "flushed" | "unstyled"
- variant: Var[LiteralInputVariant]
-
- # The size of the select.
- size: Var[str]
-
- # The name of the form field
- name: Var[str]
-
- # Fired when the value changes.
- on_change: EventHandler[lambda e0: [e0.target.value]]
-
- @classmethod
- def create(cls, *children, **props) -> Component:
- """Create a select component.
-
- If a list is provided as the first children, a default component
- will be created for each item in the list.
-
- Args:
- *children: The children of the component.
- **props: The props of the component.
-
- Returns:
- The component.
- """
- if len(children) == 1 and isinstance(children[0], list):
- children = [Option.create(child) for child in children[0]]
- if (
- len(children) == 1
- and isinstance(children[0], Var)
- and _issubclass(children[0]._var_type, List)
- ):
- children = [Foreach.create(children[0], lambda item: Option.create(item))]
- return super().create(*children, **props)
-
-
-class Option(Text):
- """A select option."""
-
- tag = "option"
-
- value: Var[Any]
-
- @classmethod
- def create(cls, *children, **props) -> Component:
- """Create a select option component.
-
- By default, the value of the option is the text of the option.
-
- Args:
- *children: The children of the component.
- **props: The props of the component.
-
- Returns:
- The component.
- """
- if "value" not in props:
- assert len(children) == 1
- props["value"] = children[0]
- return super().create(*children, **props)
diff --git a/reflex/components/chakra/forms/select.pyi b/reflex/components/chakra/forms/select.pyi
deleted file mode 100644
index 8835cd588..000000000
--- a/reflex/components/chakra/forms/select.pyi
+++ /dev/null
@@ -1,204 +0,0 @@
-"""Stub file for reflex/components/chakra/forms/select.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.components.chakra.typography.text import Text
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Select(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- value: Optional[Union[Var[str], str]] = None,
- default_value: Optional[Union[Var[str], str]] = None,
- placeholder: Optional[Union[Var[str], str]] = None,
- error_border_color: Optional[Union[Var[str], str]] = None,
- focus_border_color: Optional[Union[Var[str], str]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_invalid: Optional[Union[Var[bool], bool]] = None,
- is_required: Optional[Union[Var[bool], bool]] = None,
- variant: Optional[
- Union[
- Var[Literal["outline", "filled", "flushed", "unstyled"]],
- Literal["outline", "filled", "flushed", "unstyled"],
- ]
- ] = None,
- size: Optional[Union[Var[str], str]] = None,
- name: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Select":
- """Create a select component.
-
- If a list is provided as the first children, a default component
- will be created for each item in the list.
-
- Args:
- *children: The children of the component.
- value: State var to bind the select.
- default_value: The default value of the select.
- placeholder: The placeholder text.
- error_border_color: The border color when the select is invalid.
- focus_border_color: The border color when the select is focused.
- is_disabled: If true, the select will be disabled.
- is_invalid: If true, the form control will be invalid. This has 2 side effects: - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true
- is_required: If true, the form control will be required. This has 2 side effects: - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true
- variant: "outline" | "filled" | "flushed" | "unstyled"
- size: The size of the select.
- name: The name of the form field
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class Option(Text):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- value: Optional[Union[Var[Any], Any]] = None,
- as_: Optional[Union[Var[str], str]] = None,
- no_of_lines: Optional[Union[Var[int], int]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Option":
- """Create a select option component.
-
- By default, the value of the option is the text of the option.
-
- Args:
- *children: The children of the component.
- as_: Override the tag. The default tag is `
`.
- no_of_lines: Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/forms/slider.py b/reflex/components/chakra/forms/slider.py
deleted file mode 100644
index e773a93e1..000000000
--- a/reflex/components/chakra/forms/slider.py
+++ /dev/null
@@ -1,130 +0,0 @@
-"""A slider component."""
-
-from __future__ import annotations
-
-from typing import Literal
-
-from reflex.components.chakra import ChakraComponent, LiteralChakraDirection
-from reflex.components.component import Component
-from reflex.event import EventHandler
-from reflex.vars import Var
-
-LiteralLayout = Literal["horizontal", "vertical"]
-
-
-class Slider(ChakraComponent):
- """The wrapper that provides context and functionality for all children."""
-
- tag = "Slider"
-
- # State var to bind the input.
- value: Var[int]
-
- # The color scheme.
- color_scheme: Var[str]
-
- # The placeholder text.
- default_value: Var[int]
-
- # The writing mode ("ltr" | "rtl")
- direction: Var[LiteralChakraDirection]
-
- # If false, the slider handle will not capture focus when value changes.
- focus_thumb_on_change: Var[bool]
-
- # If true, the slider will be disabled
- is_disabled: Var[bool]
-
- # If true, the slider will be in `read-only` state.
- is_read_only: Var[bool]
-
- # If true, the value will be incremented or decremented in reverse.
- is_reversed: Var[bool]
-
- # The minimum value of the slider.
- min_: Var[int]
-
- # The maximum value of the slider.
- max_: Var[int]
-
- # The step in which increments/decrements have to be made
- step: Var[int]
-
- # The minimum distance between slider thumbs. Useful for preventing the thumbs from being too close together.
- min_steps_between_thumbs: Var[int]
-
- # Oreintation of the slider vertical | horizontal.
- orientation: Var[LiteralLayout]
-
- # Minimum height of the slider.
- min_h: Var[str]
-
- # Minimum width of the slider.
- min_w: Var[str]
-
- # Maximum height of the slider.
- max_h: Var[str]
-
- # Maximum width of the slider.
- max_w: Var[str]
-
- # The name of the form field
- name: Var[str]
-
- # Fired when the value changes.
- on_change: EventHandler[lambda e0: [e0]]
-
- # Fired when the value starts changing.
- on_change_start: EventHandler[lambda e0: [e0]]
-
- # Fired when the value stops changing.
- on_change_end: EventHandler[lambda e0: [e0]]
-
- @classmethod
- def create(cls, *children, **props) -> Component:
- """Create a slider component.
-
- If no children are provided, a default slider will be created.
-
- Args:
- *children: The children of the component.
- **props: The properties of the component.
-
- Returns:
- The slider component.
- """
- if len(children) == 0:
- children = [
- SliderTrack.create(
- SliderFilledTrack.create(),
- ),
- SliderThumb.create(),
- ]
- return super().create(*children, **props)
-
-
-class SliderTrack(ChakraComponent):
- """The empty part of the slider that shows the track."""
-
- tag = "SliderTrack"
-
-
-class SliderFilledTrack(ChakraComponent):
- """The filled part of the slider."""
-
- tag = "SliderFilledTrack"
-
-
-class SliderThumb(ChakraComponent):
- """The handle that's used to change the slider value."""
-
- tag = "SliderThumb"
-
- # The size of the thumb.
- box_size: Var[str]
-
-
-class SliderMark(ChakraComponent):
- """The label or mark that shows names for specific slider values."""
-
- tag = "SliderMark"
diff --git a/reflex/components/chakra/forms/slider.pyi b/reflex/components/chakra/forms/slider.pyi
deleted file mode 100644
index 40eec470b..000000000
--- a/reflex/components/chakra/forms/slider.pyi
+++ /dev/null
@@ -1,449 +0,0 @@
-"""Stub file for reflex/components/chakra/forms/slider.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-LiteralLayout = Literal["horizontal", "vertical"]
-
-class Slider(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- value: Optional[Union[Var[int], int]] = None,
- color_scheme: Optional[Union[Var[str], str]] = None,
- default_value: Optional[Union[Var[int], int]] = None,
- direction: Optional[
- Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]
- ] = None,
- focus_thumb_on_change: Optional[Union[Var[bool], bool]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_read_only: Optional[Union[Var[bool], bool]] = None,
- is_reversed: Optional[Union[Var[bool], bool]] = None,
- min_: Optional[Union[Var[int], int]] = None,
- max_: Optional[Union[Var[int], int]] = None,
- step: Optional[Union[Var[int], int]] = None,
- min_steps_between_thumbs: Optional[Union[Var[int], int]] = None,
- orientation: Optional[
- Union[
- Var[Literal["horizontal", "vertical"]],
- Literal["horizontal", "vertical"],
- ]
- ] = None,
- min_h: Optional[Union[Var[str], str]] = None,
- min_w: Optional[Union[Var[str], str]] = None,
- max_h: Optional[Union[Var[str], str]] = None,
- max_w: Optional[Union[Var[str], str]] = None,
- name: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change_end: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change_start: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Slider":
- """Create a slider component.
-
- If no children are provided, a default slider will be created.
-
- Args:
- *children: The children of the component.
- value: State var to bind the input.
- color_scheme: The color scheme.
- default_value: The placeholder text.
- direction: The writing mode ("ltr" | "rtl")
- focus_thumb_on_change: If false, the slider handle will not capture focus when value changes.
- is_disabled: If true, the slider will be disabled
- is_read_only: If true, the slider will be in `read-only` state.
- is_reversed: If true, the value will be incremented or decremented in reverse.
- min_: The minimum value of the slider.
- max_: The maximum value of the slider.
- step: The step in which increments/decrements have to be made
- min_steps_between_thumbs: The minimum distance between slider thumbs. Useful for preventing the thumbs from being too close together.
- orientation: Oreintation of the slider vertical | horizontal.
- min_h: Minimum height of the slider.
- min_w: Minimum width of the slider.
- max_h: Maximum height of the slider.
- max_w: Maximum width of the slider.
- name: The name of the form field
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Returns:
- The slider component.
- """
- ...
-
-class SliderTrack(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "SliderTrack":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class SliderFilledTrack(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "SliderFilledTrack":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class SliderThumb(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- box_size: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "SliderThumb":
- """Create the component.
-
- Args:
- *children: The children of the component.
- box_size: The size of the thumb.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class SliderMark(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "SliderMark":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/forms/switch.py b/reflex/components/chakra/forms/switch.py
deleted file mode 100644
index a52c7c9a5..000000000
--- a/reflex/components/chakra/forms/switch.py
+++ /dev/null
@@ -1,49 +0,0 @@
-"""A switch component."""
-
-from __future__ import annotations
-
-from reflex.components.chakra import ChakraComponent, LiteralColorScheme
-from reflex.event import EventHandler
-from reflex.vars import Var
-
-
-class Switch(ChakraComponent):
- """Toggleable switch component."""
-
- tag = "Switch"
-
- # If true, the switch will be checked. You'll need to set an on_change event handler to update its value (since it is now controlled)
- is_checked: Var[bool]
-
- # If true, the switch will be disabled
- is_disabled: Var[bool]
-
- # If true and is_disabled prop is set, the switch will remain tabbable but not interactive.
- is_focusable: Var[bool]
-
- # If true, the switch is marked as invalid. Changes style of unchecked state.
- is_invalid: Var[bool]
-
- # If true, the switch will be readonly
- is_read_only: Var[bool]
-
- # If true, the switch will be required
- is_required: Var[bool]
-
- # The name of the input field in a switch (Useful for form submission).
- name: Var[str]
-
- # The value of the input field when checked (use is_checked prop for a bool)
- value: Var[str] = Var.create(True) # type: ignore
-
- # The spacing between the switch and its label text (0.5rem)
- spacing: Var[str]
-
- # The placeholder text.
- placeholder: Var[str]
-
- # The color scheme of the switch (e.g. "blue", "green", "red", etc.)
- color_scheme: Var[LiteralColorScheme]
-
- # Fired when the switch value changes
- on_change: EventHandler[lambda e0: [e0.target.checked]]
diff --git a/reflex/components/chakra/forms/switch.pyi b/reflex/components/chakra/forms/switch.pyi
deleted file mode 100644
index be132e858..000000000
--- a/reflex/components/chakra/forms/switch.pyi
+++ /dev/null
@@ -1,159 +0,0 @@
-"""Stub file for reflex/components/chakra/forms/switch.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Switch(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- is_checked: Optional[Union[Var[bool], bool]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_focusable: Optional[Union[Var[bool], bool]] = None,
- is_invalid: Optional[Union[Var[bool], bool]] = None,
- is_read_only: Optional[Union[Var[bool], bool]] = None,
- is_required: Optional[Union[Var[bool], bool]] = None,
- name: Optional[Union[Var[str], str]] = None,
- value: Optional[Union[Var[str], str]] = None,
- spacing: Optional[Union[Var[str], str]] = None,
- placeholder: Optional[Union[Var[str], str]] = None,
- color_scheme: Optional[
- Union[
- Var[
- Literal[
- "none",
- "gray",
- "red",
- "orange",
- "yellow",
- "green",
- "teal",
- "blue",
- "cyan",
- "purple",
- "pink",
- "whiteAlpha",
- "blackAlpha",
- "linkedin",
- "facebook",
- "messenger",
- "whatsapp",
- "twitter",
- "telegram",
- ]
- ],
- Literal[
- "none",
- "gray",
- "red",
- "orange",
- "yellow",
- "green",
- "teal",
- "blue",
- "cyan",
- "purple",
- "pink",
- "whiteAlpha",
- "blackAlpha",
- "linkedin",
- "facebook",
- "messenger",
- "whatsapp",
- "twitter",
- "telegram",
- ],
- ]
- ] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Switch":
- """Create the component.
-
- Args:
- *children: The children of the component.
- is_checked: If true, the switch will be checked. You'll need to set an on_change event handler to update its value (since it is now controlled)
- is_disabled: If true, the switch will be disabled
- is_focusable: If true and is_disabled prop is set, the switch will remain tabbable but not interactive.
- is_invalid: If true, the switch is marked as invalid. Changes style of unchecked state.
- is_read_only: If true, the switch will be readonly
- is_required: If true, the switch will be required
- name: The name of the input field in a switch (Useful for form submission).
- value: The value of the input field when checked (use is_checked prop for a bool)
- spacing: The spacing between the switch and its label text (0.5rem)
- placeholder: The placeholder text.
- color_scheme: The color scheme of the switch (e.g. "blue", "green", "red", etc.)
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/forms/textarea.py b/reflex/components/chakra/forms/textarea.py
deleted file mode 100644
index a88158feb..000000000
--- a/reflex/components/chakra/forms/textarea.py
+++ /dev/null
@@ -1,79 +0,0 @@
-"""A textarea component."""
-
-from __future__ import annotations
-
-from reflex.components.chakra import ChakraComponent, LiteralInputVariant
-from reflex.components.component import Component
-from reflex.components.core.debounce import DebounceInput
-from reflex.event import EventHandler
-from reflex.vars import Var
-
-
-class TextArea(ChakraComponent):
- """A text area component."""
-
- tag = "Textarea"
-
- # State var to bind the input.
- value: Var[str]
-
- # The default value of the textarea.
- default_value: Var[str]
-
- # The placeholder text.
- placeholder: Var[str]
-
- # The border color when the input is invalid.
- error_border_color: Var[str]
-
- # The border color when the input is focused.
- focus_border_color: Var[str]
-
- # If true, the form control will be disabled.
- is_disabled: Var[bool]
-
- # If true, the form control will be invalid.
- is_invalid: Var[bool]
-
- # If true, the form control will be read-only.
- is_read_only: Var[bool]
-
- # If true, the form control will be required.
- is_required: Var[bool]
-
- # "outline" | "filled" | "flushed" | "unstyled"
- variant: Var[LiteralInputVariant]
-
- # The name of the form field
- name: Var[str]
-
- # Fired when the value changes.
- on_change: EventHandler[lambda e0: [e0.target.value]]
-
- # Fired when the textarea gets focus.
- on_focus: EventHandler[lambda e0: [e0.target.value]]
-
- # Fired when the textarea loses focus.
- on_blur: EventHandler[lambda e0: [e0.target.value]]
-
- # Fired when a key is pressed down.
- on_key_down: EventHandler[lambda e0: [e0.key]]
-
- # Fired when a key is released.
- on_key_up: EventHandler[lambda e0: [e0.key]]
-
- @classmethod
- def create(cls, *children, **props) -> Component:
- """Create an Input component.
-
- Args:
- *children: The children of the component.
- **props: The properties of the component.
-
- Returns:
- The component.
- """
- if props.get("value") is not None and props.get("on_change") is not None:
- # create a debounced input if the user requests full control to avoid typing jank
- return DebounceInput.create(super().create(*children, **props))
- return super().create(*children, **props)
diff --git a/reflex/components/chakra/forms/textarea.pyi b/reflex/components/chakra/forms/textarea.pyi
deleted file mode 100644
index b73c6d907..000000000
--- a/reflex/components/chakra/forms/textarea.pyi
+++ /dev/null
@@ -1,123 +0,0 @@
-"""Stub file for reflex/components/chakra/forms/textarea.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class TextArea(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- value: Optional[Union[Var[str], str]] = None,
- default_value: Optional[Union[Var[str], str]] = None,
- placeholder: Optional[Union[Var[str], str]] = None,
- error_border_color: Optional[Union[Var[str], str]] = None,
- focus_border_color: Optional[Union[Var[str], str]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_invalid: Optional[Union[Var[bool], bool]] = None,
- is_read_only: Optional[Union[Var[bool], bool]] = None,
- is_required: Optional[Union[Var[bool], bool]] = None,
- variant: Optional[
- Union[
- Var[Literal["outline", "filled", "flushed", "unstyled"]],
- Literal["outline", "filled", "flushed", "unstyled"],
- ]
- ] = None,
- name: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_key_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "TextArea":
- """Create an Input component.
-
- Args:
- *children: The children of the component.
- value: State var to bind the input.
- default_value: The default value of the textarea.
- placeholder: The placeholder text.
- error_border_color: The border color when the input is invalid.
- focus_border_color: The border color when the input is focused.
- is_disabled: If true, the form control will be disabled.
- is_invalid: If true, the form control will be invalid.
- is_read_only: If true, the form control will be read-only.
- is_required: If true, the form control will be required.
- variant: "outline" | "filled" | "flushed" | "unstyled"
- name: The name of the form field
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/forms/time_picker.py b/reflex/components/chakra/forms/time_picker.py
deleted file mode 100644
index d778293fd..000000000
--- a/reflex/components/chakra/forms/time_picker.py
+++ /dev/null
@@ -1,11 +0,0 @@
-"""A time input component."""
-
-from reflex.components.chakra.forms.input import Input
-from reflex.vars import Var
-
-
-class TimePicker(Input):
- """A time input component."""
-
- # The type of input.
- type_: Var[str] = "time" # type: ignore
diff --git a/reflex/components/chakra/forms/time_picker.pyi b/reflex/components/chakra/forms/time_picker.pyi
deleted file mode 100644
index 1f9e641e8..000000000
--- a/reflex/components/chakra/forms/time_picker.pyi
+++ /dev/null
@@ -1,129 +0,0 @@
-"""Stub file for reflex/components/chakra/forms/time_picker.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra.forms.input import Input
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class TimePicker(Input):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- type_: Optional[Union[Var[str], str]] = None,
- value: Optional[Union[Var[str], str]] = None,
- default_value: Optional[Union[Var[str], str]] = None,
- placeholder: Optional[Union[Var[str], str]] = None,
- error_border_color: Optional[Union[Var[str], str]] = None,
- focus_border_color: Optional[Union[Var[str], str]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_invalid: Optional[Union[Var[bool], bool]] = None,
- is_read_only: Optional[Union[Var[bool], bool]] = None,
- is_required: Optional[Union[Var[bool], bool]] = None,
- variant: Optional[
- Union[
- Var[Literal["outline", "filled", "flushed", "unstyled"]],
- Literal["outline", "filled", "flushed", "unstyled"],
- ]
- ] = None,
- size: Optional[
- Union[Var[Literal["sm", "md", "lg", "xs"]], Literal["sm", "md", "lg", "xs"]]
- ] = None,
- name: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_key_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "TimePicker":
- """Create an Input component.
-
- Args:
- *children: The children of the component.
- type_: The type of input.
- value: State var to bind the input.
- default_value: The default value of the input.
- placeholder: The placeholder text.
- error_border_color: The border color when the input is invalid.
- focus_border_color: The border color when the input is focused.
- is_disabled: If true, the form control will be disabled. This has 2 side effects - The FormLabel will have `data-disabled` attribute - The form element (e.g, Input) will be disabled
- is_invalid: If true, the form control will be invalid. This has 2 side effects - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true
- is_read_only: If true, the form control will be readonly.
- is_required: If true, the form control will be required. This has 2 side effects - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true
- variant: "outline" | "filled" | "flushed" | "unstyled"
- size: "lg" | "md" | "sm" | "xs"
- name: The name of the form field
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/layout/__init__.py b/reflex/components/chakra/layout/__init__.py
deleted file mode 100644
index 13c28fdd4..000000000
--- a/reflex/components/chakra/layout/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-"""Convenience functions to define layout components."""
-
-from .aspect_ratio import AspectRatio
-from .box import Box
-from .card import Card, CardBody, CardFooter, CardHeader
-from .center import Center, Circle, Square
-from .container import Container
-from .flex import Flex
-from .grid import Grid, GridItem, ResponsiveGrid
-from .spacer import Spacer
-from .stack import Hstack, Stack, Vstack
-from .wrap import Wrap, WrapItem
-
-__all__ = [f for f in dir() if f[0].isupper()] # type: ignore
diff --git a/reflex/components/chakra/layout/aspect_ratio.py b/reflex/components/chakra/layout/aspect_ratio.py
deleted file mode 100644
index 5d0328d7e..000000000
--- a/reflex/components/chakra/layout/aspect_ratio.py
+++ /dev/null
@@ -1,13 +0,0 @@
-"""A AspectRatio component."""
-
-from reflex.components.chakra import ChakraComponent
-from reflex.vars import Var
-
-
-class AspectRatio(ChakraComponent):
- """AspectRatio component is used to embed responsive videos and maps, etc."""
-
- tag = "AspectRatio"
-
- # The aspect ratio of the Box
- ratio: Var[float]
diff --git a/reflex/components/chakra/layout/aspect_ratio.pyi b/reflex/components/chakra/layout/aspect_ratio.pyi
deleted file mode 100644
index da798076f..000000000
--- a/reflex/components/chakra/layout/aspect_ratio.pyi
+++ /dev/null
@@ -1,89 +0,0 @@
-"""Stub file for reflex/components/chakra/layout/aspect_ratio.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class AspectRatio(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- ratio: Optional[Union[Var[float], float]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "AspectRatio":
- """Create the component.
-
- Args:
- *children: The children of the component.
- ratio: The aspect ratio of the Box
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/layout/box.py b/reflex/components/chakra/layout/box.py
deleted file mode 100644
index 497e514b8..000000000
--- a/reflex/components/chakra/layout/box.py
+++ /dev/null
@@ -1,31 +0,0 @@
-"""A box component that can contain other components."""
-
-from reflex.components.chakra import ChakraComponent
-from reflex.components.tags import Tag
-from reflex.vars import Var
-
-
-class Box(ChakraComponent):
- """A generic container component that can contain other components."""
-
- tag = "Box"
-
- # The type element to render. You can specify an image, video, or any other HTML element such as iframe.
- element: Var[str]
-
- # The source of the content.
- src: Var[str]
-
- # The alt text of the content.
- alt: Var[str]
-
- def _render(self) -> Tag:
- return (
- super()
- ._render()
- .add_props(
- **{
- "as": self.element,
- }
- )
- )
diff --git a/reflex/components/chakra/layout/box.pyi b/reflex/components/chakra/layout/box.pyi
deleted file mode 100644
index 995cddfb3..000000000
--- a/reflex/components/chakra/layout/box.pyi
+++ /dev/null
@@ -1,93 +0,0 @@
-"""Stub file for reflex/components/chakra/layout/box.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Box(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- element: Optional[Union[Var[str], str]] = None,
- src: Optional[Union[Var[str], str]] = None,
- alt: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Box":
- """Create the component.
-
- Args:
- *children: The children of the component.
- element: The type element to render. You can specify an image, video, or any other HTML element such as iframe.
- src: The source of the content.
- alt: The alt text of the content.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/layout/card.py b/reflex/components/chakra/layout/card.py
deleted file mode 100644
index 595c5327f..000000000
--- a/reflex/components/chakra/layout/card.py
+++ /dev/null
@@ -1,100 +0,0 @@
-"""Chakra Card component."""
-
-from typing import Optional
-
-from reflex.components.chakra import (
- ChakraComponent,
- LiteralCardVariant,
- LiteralColorScheme,
- LiteralTagSize,
-)
-from reflex.components.component import Component
-from reflex.vars import Var
-
-
-class CardHeader(ChakraComponent):
- """The wrapper that contains a card's header."""
-
- tag = "CardHeader"
-
-
-class CardBody(ChakraComponent):
- """The wrapper that houses the card's main content."""
-
- tag = "CardBody"
-
-
-class CardFooter(ChakraComponent):
- """The footer that houses the card actions."""
-
- tag = "CardFooter"
-
-
-class Card(ChakraComponent):
- """The parent wrapper that provides context for its children."""
-
- tag = "Card"
-
- # [required] The flex alignment of the card
- align: Var[str]
-
- # [required] The flex direction of the card
- direction: Var[str]
-
- # [required] The flex distribution of the card
- justify: Var[str]
-
- # The visual color appearance of the component.
- # options: "whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" |
- # "green" | "teal" | "blue" | "cyan" | "purple" | "pink" | "linkedin" |
- # "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram"
- # default: "gray"
- color_scheme: Var[LiteralColorScheme]
-
- # The size of the Card
- # options: "sm" | "md" | "lg"
- # default: "md"
- size: Var[LiteralTagSize]
-
- # The variant of the Card
- # options: "elevated" | "outline" | "filled" | "unstyled"
- # default: "elevated"
- variant: Var[LiteralCardVariant]
-
- @classmethod
- def create(
- cls,
- body: Component,
- *,
- header: Optional[Component] = None,
- footer: Optional[Component] = None,
- **props,
- ) -> Component:
- """Creates a Chakra Card with a body and optionally header and/or footer, and returns it.
- If header, body or footer are not already instances of Chead, Cbody or Cfoot respectively,
- they will be wrapped as such for layout purposes. If you want to modify their props,
- e.g. padding_left, you should wrap them yourself.
-
- Args:
- body (Component): The main content of the Card that will be created.
- header (Optional[Component]): The header of the Card.
- footer (Optional[Component]): The footer of the Card.
- props: The properties to be passed to the component.
-
- Returns:
- The `create()` method returns a Card object.
- """
- children = []
- param_to_component_class = (
- (header, CardHeader),
- (body, CardBody),
- (footer, CardFooter),
- )
-
- for param, component_class in param_to_component_class:
- if isinstance(param, component_class):
- children.append(param)
- elif param is not None:
- children.append(component_class.create(param))
-
- return super().create(*children, **props)
diff --git a/reflex/components/chakra/layout/card.pyi b/reflex/components/chakra/layout/card.pyi
deleted file mode 100644
index 19aa6c57a..000000000
--- a/reflex/components/chakra/layout/card.pyi
+++ /dev/null
@@ -1,379 +0,0 @@
-"""Stub file for reflex/components/chakra/layout/card.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import (
- ChakraComponent,
-)
-from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class CardHeader(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "CardHeader":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class CardBody(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "CardBody":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class CardFooter(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "CardFooter":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class Card(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- header: Optional[Component] = None,
- footer: Optional[Component] = None,
- align: Optional[Union[Var[str], str]] = None,
- direction: Optional[Union[Var[str], str]] = None,
- justify: Optional[Union[Var[str], str]] = None,
- color_scheme: Optional[
- Union[
- Var[
- Literal[
- "none",
- "gray",
- "red",
- "orange",
- "yellow",
- "green",
- "teal",
- "blue",
- "cyan",
- "purple",
- "pink",
- "whiteAlpha",
- "blackAlpha",
- "linkedin",
- "facebook",
- "messenger",
- "whatsapp",
- "twitter",
- "telegram",
- ]
- ],
- Literal[
- "none",
- "gray",
- "red",
- "orange",
- "yellow",
- "green",
- "teal",
- "blue",
- "cyan",
- "purple",
- "pink",
- "whiteAlpha",
- "blackAlpha",
- "linkedin",
- "facebook",
- "messenger",
- "whatsapp",
- "twitter",
- "telegram",
- ],
- ]
- ] = None,
- size: Optional[
- Union[Var[Literal["sm", "md", "lg"]], Literal["sm", "md", "lg"]]
- ] = None,
- variant: Optional[
- Union[
- Var[Literal["outline", "filled", "elevated", "unstyled"]],
- Literal["outline", "filled", "elevated", "unstyled"],
- ]
- ] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Card":
- """Creates a Chakra Card with a body and optionally header and/or footer, and returns it.
- If header, body or footer are not already instances of Chead, Cbody or Cfoot respectively,
- they will be wrapped as such for layout purposes. If you want to modify their props,
- e.g. padding_left, you should wrap them yourself.
-
- Args:
- body (Component): The main content of the Card that will be created.
- header (Optional[Component]): The header of the Card.
- footer (Optional[Component]): The footer of the Card.
- props: The properties to be passed to the component.
-
- Returns:
- The `create()` method returns a Card object.
- """
- ...
diff --git a/reflex/components/chakra/layout/center.py b/reflex/components/chakra/layout/center.py
deleted file mode 100644
index bc3ced1aa..000000000
--- a/reflex/components/chakra/layout/center.py
+++ /dev/null
@@ -1,21 +0,0 @@
-"""A box that centers its contents."""
-
-from reflex.components.chakra import ChakraComponent
-
-
-class Center(ChakraComponent):
- """A box that centers its contents."""
-
- tag = "Center"
-
-
-class Square(ChakraComponent):
- """A centered square container."""
-
- tag = "Square"
-
-
-class Circle(ChakraComponent):
- """A square container with round border-radius."""
-
- tag = "Circle"
diff --git a/reflex/components/chakra/layout/center.pyi b/reflex/components/chakra/layout/center.pyi
deleted file mode 100644
index a78e662f7..000000000
--- a/reflex/components/chakra/layout/center.pyi
+++ /dev/null
@@ -1,239 +0,0 @@
-"""Stub file for reflex/components/chakra/layout/center.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Center(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Center":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class Square(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Square":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class Circle(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Circle":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/layout/container.py b/reflex/components/chakra/layout/container.py
deleted file mode 100644
index 26863d018..000000000
--- a/reflex/components/chakra/layout/container.py
+++ /dev/null
@@ -1,13 +0,0 @@
-"""A flexbox container."""
-
-from reflex.components.chakra import ChakraComponent
-from reflex.vars import Var
-
-
-class Container(ChakraComponent):
- """A flexbox container that centers its children and sets a max width."""
-
- tag = "Container"
-
- # If true, container will center its children regardless of their width.
- center_content: Var[bool]
diff --git a/reflex/components/chakra/layout/container.pyi b/reflex/components/chakra/layout/container.pyi
deleted file mode 100644
index 856dc5fec..000000000
--- a/reflex/components/chakra/layout/container.pyi
+++ /dev/null
@@ -1,89 +0,0 @@
-"""Stub file for reflex/components/chakra/layout/container.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Container(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- center_content: Optional[Union[Var[bool], bool]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Container":
- """Create the component.
-
- Args:
- *children: The children of the component.
- center_content: If true, container will center its children regardless of their width.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/layout/flex.py b/reflex/components/chakra/layout/flex.py
deleted file mode 100644
index ff6e5abce..000000000
--- a/reflex/components/chakra/layout/flex.py
+++ /dev/null
@@ -1,33 +0,0 @@
-"""A reflexive container component."""
-
-from typing import List, Union
-
-from reflex.components.chakra import ChakraComponent
-from reflex.vars import Var
-
-
-class Flex(ChakraComponent):
- """A reflexive container component."""
-
- tag = "Flex"
-
- # How to align items in the flex.
- align: Var[str]
-
- # Shorthand for flexBasis style prop
- basis: Var[str]
-
- # Shorthand for flexDirection style prop
- direction: Var[Union[str, List[str]]]
-
- # Shorthand for flexGrow style prop
- grow: Var[str]
-
- # The way to justify the items.
- justify: Var[str]
-
- # Shorthand for flexWrap style prop
- wrap: Var[Union[str, List[str]]]
-
- # Shorthand for flexShrink style prop
- shrink: Var[str]
diff --git a/reflex/components/chakra/layout/flex.pyi b/reflex/components/chakra/layout/flex.pyi
deleted file mode 100644
index da08f05a6..000000000
--- a/reflex/components/chakra/layout/flex.pyi
+++ /dev/null
@@ -1,101 +0,0 @@
-"""Stub file for reflex/components/chakra/layout/flex.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Flex(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- align: Optional[Union[Var[str], str]] = None,
- basis: Optional[Union[Var[str], str]] = None,
- direction: Optional[Union[Var[Union[List[str], str]], str, List[str]]] = None,
- grow: Optional[Union[Var[str], str]] = None,
- justify: Optional[Union[Var[str], str]] = None,
- wrap: Optional[Union[Var[Union[List[str], str]], str, List[str]]] = None,
- shrink: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Flex":
- """Create the component.
-
- Args:
- *children: The children of the component.
- align: How to align items in the flex.
- basis: Shorthand for flexBasis style prop
- direction: Shorthand for flexDirection style prop
- grow: Shorthand for flexGrow style prop
- justify: The way to justify the items.
- wrap: Shorthand for flexWrap style prop
- shrink: Shorthand for flexShrink style prop
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/layout/grid.py b/reflex/components/chakra/layout/grid.py
deleted file mode 100644
index ee1d8aa33..000000000
--- a/reflex/components/chakra/layout/grid.py
+++ /dev/null
@@ -1,125 +0,0 @@
-"""Container to stack elements with spacing."""
-
-from typing import List
-
-from reflex.components.chakra import ChakraComponent
-from reflex.vars import Var
-
-
-class Grid(ChakraComponent):
- """A grid component."""
-
- tag = "Grid"
-
- # Shorthand prop for gridAutoColumns to provide automatic column sizing based on content.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns)_
- auto_columns: Var[str]
-
- # Shorthand prop for gridAutoFlow to specify exactly how
- # auto-placed items get flowed into the grid.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow)_
- auto_flow: Var[str]
-
- # Shorthand prop for gridAutoRows.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows)_
- auto_rows: Var[str]
-
- # Shorthand prop for gridColumn.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column)_
- column: Var[str]
-
- # Shorthand prop for gridRow.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row)_
- row: Var[str]
-
- # Shorthand prop for gridTemplateColumns.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns)_
- template_columns: Var[str]
-
- # Shorthand prop for gridTemplateRows.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows)_
- template_rows: Var[str]
-
-
-class GridItem(ChakraComponent):
- """Used as a child of Grid to control the span, and start positions within the grid."""
-
- tag = "GridItem"
-
- # Shorthand prop for gridArea
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area)_
- area: Var[str]
-
- # Shorthand prop for gridColumnEnd
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-end)_
- col_end: Var[str]
-
- # The column number the grid item should start.
- col_start: Var[int]
-
- # The number of columns the grid item should span.
- col_span: Var[int]
-
- # Shorthand prop for gridRowEnd
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-end)_
- row_end: Var[str]
-
- # The row number the grid item should start.
- row_start: Var[int]
-
- # The number of rows the grid item should span.
- row_span: Var[int]
-
-
-class ResponsiveGrid(ChakraComponent):
- """A responsive grid component."""
-
- tag = "SimpleGrid"
-
- # Shorthand prop for gridAutoColumns to provide automatic column sizing based on content.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns)_
- auto_columns: Var[str]
-
- # Shorthand prop for gridAutoFlow to specify exactly how
- # auto-placed items get flowed into the grid.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow)_
- auto_flow: Var[str]
-
- # Shorthand prop for gridAutoRows.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows)_
- auto_rows: Var[str]
-
- # Shorthand prop for gridColumn.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column)_
- column: Var[str]
-
- # Shorthand prop for gridRow.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row)_
- row: Var[str]
-
- # A list that defines the number of columns for each breakpoint.
- columns: Var[List[int]]
-
- # The width at which child elements will break into columns. Pass a number for pixel values or a string for any other valid CSS length.
- min_child_width: Var[str]
-
- # The gap between the grid items
- spacing: Var[str]
-
- # The column gap between the grid items
- spacing_x: Var[str]
-
- # The row gap between the grid items
- spacing_y: Var[str]
-
- # Shorthand prop for gridTemplateAreas
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas)_
- template_areas: Var[str]
-
- # Shorthand prop for gridTemplateColumns.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns)_
- template_columns: Var[str]
-
- # Shorthand prop for gridTemplateRows.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows)_
- template_rows: Var[str]
diff --git a/reflex/components/chakra/layout/grid.pyi b/reflex/components/chakra/layout/grid.pyi
deleted file mode 100644
index b70ee344a..000000000
--- a/reflex/components/chakra/layout/grid.pyi
+++ /dev/null
@@ -1,293 +0,0 @@
-"""Stub file for reflex/components/chakra/layout/grid.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Grid(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- auto_columns: Optional[Union[Var[str], str]] = None,
- auto_flow: Optional[Union[Var[str], str]] = None,
- auto_rows: Optional[Union[Var[str], str]] = None,
- column: Optional[Union[Var[str], str]] = None,
- row: Optional[Union[Var[str], str]] = None,
- template_columns: Optional[Union[Var[str], str]] = None,
- template_rows: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Grid":
- """Create the component.
-
- Args:
- *children: The children of the component.
- auto_columns: Shorthand prop for gridAutoColumns to provide automatic column sizing based on content. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns)_
- auto_flow: Shorthand prop for gridAutoFlow to specify exactly how auto-placed items get flowed into the grid. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow)_
- auto_rows: Shorthand prop for gridAutoRows. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows)_
- column: Shorthand prop for gridColumn. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column)_
- row: Shorthand prop for gridRow. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row)_
- template_columns: Shorthand prop for gridTemplateColumns. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns)_
- template_rows: Shorthand prop for gridTemplateRows. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows)_
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class GridItem(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- area: Optional[Union[Var[str], str]] = None,
- col_end: Optional[Union[Var[str], str]] = None,
- col_start: Optional[Union[Var[int], int]] = None,
- col_span: Optional[Union[Var[int], int]] = None,
- row_end: Optional[Union[Var[str], str]] = None,
- row_start: Optional[Union[Var[int], int]] = None,
- row_span: Optional[Union[Var[int], int]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "GridItem":
- """Create the component.
-
- Args:
- *children: The children of the component.
- area: Shorthand prop for gridArea Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area)_
- col_end: Shorthand prop for gridColumnEnd Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-end)_
- col_start: The column number the grid item should start.
- col_span: The number of columns the grid item should span.
- row_end: Shorthand prop for gridRowEnd Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-end)_
- row_start: The row number the grid item should start.
- row_span: The number of rows the grid item should span.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class ResponsiveGrid(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- auto_columns: Optional[Union[Var[str], str]] = None,
- auto_flow: Optional[Union[Var[str], str]] = None,
- auto_rows: Optional[Union[Var[str], str]] = None,
- column: Optional[Union[Var[str], str]] = None,
- row: Optional[Union[Var[str], str]] = None,
- columns: Optional[Union[Var[List[int]], List[int]]] = None,
- min_child_width: Optional[Union[Var[str], str]] = None,
- spacing: Optional[Union[Var[str], str]] = None,
- spacing_x: Optional[Union[Var[str], str]] = None,
- spacing_y: Optional[Union[Var[str], str]] = None,
- template_areas: Optional[Union[Var[str], str]] = None,
- template_columns: Optional[Union[Var[str], str]] = None,
- template_rows: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "ResponsiveGrid":
- """Create the component.
-
- Args:
- *children: The children of the component.
- auto_columns: Shorthand prop for gridAutoColumns to provide automatic column sizing based on content. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns)_
- auto_flow: Shorthand prop for gridAutoFlow to specify exactly how auto-placed items get flowed into the grid. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow)_
- auto_rows: Shorthand prop for gridAutoRows. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows)_
- column: Shorthand prop for gridColumn. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column)_
- row: Shorthand prop for gridRow. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row)_
- columns: A list that defines the number of columns for each breakpoint.
- min_child_width: The width at which child elements will break into columns. Pass a number for pixel values or a string for any other valid CSS length.
- spacing: The gap between the grid items
- spacing_x: The column gap between the grid items
- spacing_y: The row gap between the grid items
- template_areas: Shorthand prop for gridTemplateAreas Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas)_
- template_columns: Shorthand prop for gridTemplateColumns. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns)_
- template_rows: Shorthand prop for gridTemplateRows. Learn more _[here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows)_
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/layout/spacer.py b/reflex/components/chakra/layout/spacer.py
deleted file mode 100644
index 3888f3726..000000000
--- a/reflex/components/chakra/layout/spacer.py
+++ /dev/null
@@ -1,9 +0,0 @@
-"""A flexible space component."""
-
-from reflex.components.chakra import ChakraComponent
-
-
-class Spacer(ChakraComponent):
- """A flexible space component."""
-
- tag = "Spacer"
diff --git a/reflex/components/chakra/layout/spacer.pyi b/reflex/components/chakra/layout/spacer.pyi
deleted file mode 100644
index 3cfeabc57..000000000
--- a/reflex/components/chakra/layout/spacer.pyi
+++ /dev/null
@@ -1,87 +0,0 @@
-"""Stub file for reflex/components/chakra/layout/spacer.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Spacer(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Spacer":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/layout/stack.py b/reflex/components/chakra/layout/stack.py
deleted file mode 100644
index 8e2ab34e6..000000000
--- a/reflex/components/chakra/layout/stack.py
+++ /dev/null
@@ -1,48 +0,0 @@
-"""Container to stack elements with spacing."""
-
-from typing import List, Union
-
-from reflex.components.chakra import ChakraComponent, LiteralStackDirection
-from reflex.vars import Var
-
-
-class Stack(ChakraComponent):
- """Container to stack elements with spacing."""
-
- tag = "Stack"
-
- # Shorthand for alignItems style prop
- align_items: Var[str]
-
- # The direction to stack the items.
- direction: Var[Union[LiteralStackDirection, List[str]]]
-
- # If true the items will be stacked horizontally.
- is_inline: Var[bool]
-
- # Shorthand for justifyContent style prop
- justify_content: Var[str]
-
- # If true, the children will be wrapped in a Box, and the Box will take the spacing props
- should_wrap_children: Var[bool]
-
- # The space between each stack item
- spacing: Var[str]
-
- # Shorthand for flexWrap style prop
- wrap: Var[str]
-
- # Alignment of contents.
- justify: Var[str]
-
-
-class Hstack(Stack):
- """Stack items horizontally."""
-
- tag = "HStack"
-
-
-class Vstack(Stack):
- """Stack items vertically."""
-
- tag = "VStack"
diff --git a/reflex/components/chakra/layout/stack.pyi b/reflex/components/chakra/layout/stack.pyi
deleted file mode 100644
index 715624a7b..000000000
--- a/reflex/components/chakra/layout/stack.pyi
+++ /dev/null
@@ -1,305 +0,0 @@
-"""Stub file for reflex/components/chakra/layout/stack.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Stack(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- align_items: Optional[Union[Var[str], str]] = None,
- direction: Optional[
- Union[
- Var[Union[List[str], Literal["row", "column"]]],
- Literal["row", "column"],
- List[str],
- ]
- ] = None,
- is_inline: Optional[Union[Var[bool], bool]] = None,
- justify_content: Optional[Union[Var[str], str]] = None,
- should_wrap_children: Optional[Union[Var[bool], bool]] = None,
- spacing: Optional[Union[Var[str], str]] = None,
- wrap: Optional[Union[Var[str], str]] = None,
- justify: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Stack":
- """Create the component.
-
- Args:
- *children: The children of the component.
- align_items: Shorthand for alignItems style prop
- direction: The direction to stack the items.
- is_inline: If true the items will be stacked horizontally.
- justify_content: Shorthand for justifyContent style prop
- should_wrap_children: If true, the children will be wrapped in a Box, and the Box will take the spacing props
- spacing: The space between each stack item
- wrap: Shorthand for flexWrap style prop
- justify: Alignment of contents.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class Hstack(Stack):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- align_items: Optional[Union[Var[str], str]] = None,
- direction: Optional[
- Union[
- Var[Union[List[str], Literal["row", "column"]]],
- Literal["row", "column"],
- List[str],
- ]
- ] = None,
- is_inline: Optional[Union[Var[bool], bool]] = None,
- justify_content: Optional[Union[Var[str], str]] = None,
- should_wrap_children: Optional[Union[Var[bool], bool]] = None,
- spacing: Optional[Union[Var[str], str]] = None,
- wrap: Optional[Union[Var[str], str]] = None,
- justify: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Hstack":
- """Create the component.
-
- Args:
- *children: The children of the component.
- align_items: Shorthand for alignItems style prop
- direction: The direction to stack the items.
- is_inline: If true the items will be stacked horizontally.
- justify_content: Shorthand for justifyContent style prop
- should_wrap_children: If true, the children will be wrapped in a Box, and the Box will take the spacing props
- spacing: The space between each stack item
- wrap: Shorthand for flexWrap style prop
- justify: Alignment of contents.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class Vstack(Stack):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- align_items: Optional[Union[Var[str], str]] = None,
- direction: Optional[
- Union[
- Var[Union[List[str], Literal["row", "column"]]],
- Literal["row", "column"],
- List[str],
- ]
- ] = None,
- is_inline: Optional[Union[Var[bool], bool]] = None,
- justify_content: Optional[Union[Var[str], str]] = None,
- should_wrap_children: Optional[Union[Var[bool], bool]] = None,
- spacing: Optional[Union[Var[str], str]] = None,
- wrap: Optional[Union[Var[str], str]] = None,
- justify: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Vstack":
- """Create the component.
-
- Args:
- *children: The children of the component.
- align_items: Shorthand for alignItems style prop
- direction: The direction to stack the items.
- is_inline: If true the items will be stacked horizontally.
- justify_content: Shorthand for justifyContent style prop
- should_wrap_children: If true, the children will be wrapped in a Box, and the Box will take the spacing props
- spacing: The space between each stack item
- wrap: Shorthand for flexWrap style prop
- justify: Alignment of contents.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/layout/wrap.py b/reflex/components/chakra/layout/wrap.py
deleted file mode 100644
index 5d436c5b2..000000000
--- a/reflex/components/chakra/layout/wrap.py
+++ /dev/null
@@ -1,57 +0,0 @@
-"""Container to stack elements with spacing."""
-
-from reflex.components.chakra import ChakraComponent
-from reflex.components.component import Component
-from reflex.vars import Var
-
-
-class Wrap(ChakraComponent):
- """Layout component used to add space between elements and wrap automatically if there isn't enough space."""
-
- tag = "Wrap"
-
- # How to align the items.
- align: Var[str]
-
- # The flex direction of the wrap.
- direction: Var[str]
-
- # How to justify the items.
- justify: Var[str]
-
- # Whether to wrap children in `rx.wrap_item`.
- should_wrap_children: Var[bool]
-
- # The spacing between the items.
- spacing: Var[str]
-
- # The horizontal spacing between the items.
- spacing_x: Var[str]
-
- # The vertical spacing between the items.
- spacing_y: Var[str]
-
- @classmethod
- def create(cls, *children, items=None, **props) -> Component:
- """Return a wrap component.
-
- Args:
- *children: The children of the component.
- items (list): The items of the wrap component.
- **props: The properties of the component.
-
- Returns:
- The wrap component.
- """
- if len(children) == 0:
- children = []
- for item in items or []:
- children.append(WrapItem.create(*item))
-
- return super().create(*children, **props)
-
-
-class WrapItem(ChakraComponent):
- """Item of the Wrap component."""
-
- tag = "WrapItem"
diff --git a/reflex/components/chakra/layout/wrap.pyi b/reflex/components/chakra/layout/wrap.pyi
deleted file mode 100644
index 51654ad61..000000000
--- a/reflex/components/chakra/layout/wrap.pyi
+++ /dev/null
@@ -1,179 +0,0 @@
-"""Stub file for reflex/components/chakra/layout/wrap.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Wrap(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- items=None,
- align: Optional[Union[Var[str], str]] = None,
- direction: Optional[Union[Var[str], str]] = None,
- justify: Optional[Union[Var[str], str]] = None,
- should_wrap_children: Optional[Union[Var[bool], bool]] = None,
- spacing: Optional[Union[Var[str], str]] = None,
- spacing_x: Optional[Union[Var[str], str]] = None,
- spacing_y: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Wrap":
- """Return a wrap component.
-
- Args:
- *children: The children of the component.
- items (list): The items of the wrap component.
- align: How to align the items.
- direction: The flex direction of the wrap.
- justify: How to justify the items.
- should_wrap_children: Whether to wrap children in `rx.wrap_item`.
- spacing: The spacing between the items.
- spacing_x: The horizontal spacing between the items.
- spacing_y: The vertical spacing between the items.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Returns:
- The wrap component.
- """
- ...
-
-class WrapItem(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "WrapItem":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/media/__init__.py b/reflex/components/chakra/media/__init__.py
deleted file mode 100644
index 8346a37a6..000000000
--- a/reflex/components/chakra/media/__init__.py
+++ /dev/null
@@ -1,7 +0,0 @@
-"""Media components."""
-
-from .avatar import Avatar, AvatarBadge, AvatarGroup
-from .icon import Icon
-from .image import Image
-
-__all__ = [f for f in dir() if f[0].isupper()] # type: ignore
diff --git a/reflex/components/chakra/media/avatar.py b/reflex/components/chakra/media/avatar.py
deleted file mode 100644
index 6152da730..000000000
--- a/reflex/components/chakra/media/avatar.py
+++ /dev/null
@@ -1,58 +0,0 @@
-"""Avatar components."""
-
-from __future__ import annotations
-
-from reflex.components.chakra import ChakraComponent, LiteralAvatarSize
-from reflex.event import EventHandler
-from reflex.vars import Var
-
-
-class Avatar(ChakraComponent):
- """The image that represents the user."""
-
- tag = "Avatar"
-
- # The default avatar used as fallback when name, and src is not specified.
- icon: Var[str]
-
- # The label of the icon.
- icon_label: Var[str]
-
- # If true, opt out of the avatar's fallback logic and renders the img at all times.
- ignore_fallback: Var[bool]
-
- # The name of the person in the avatar.
- name: Var[str]
-
- # If true, the Avatar will show a border around it. Best for a group of avatars.
- show_border: Var[bool]
-
- # The image url of the Avatar.
- src: Var[str]
-
- # List of sources to use for different screen resolutions.
- src_set: Var[str]
-
- # "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "full"
- size: Var[LiteralAvatarSize]
-
- # Fired when the image fails to load.
- on_error: EventHandler[lambda: []]
-
-
-class AvatarBadge(ChakraComponent):
- """A wrapper that displays its content on the right corner of the avatar."""
-
- tag = "AvatarBadge"
-
-
-class AvatarGroup(ChakraComponent):
- """A wrapper to stack multiple Avatars together."""
-
- tag = "AvatarGroup"
-
- # The maximum number of visible avatars.
- max_: Var[int]
-
- # The space between the avatars in the group.
- spacing: Var[int]
diff --git a/reflex/components/chakra/media/avatar.pyi b/reflex/components/chakra/media/avatar.pyi
deleted file mode 100644
index c93ad72b7..000000000
--- a/reflex/components/chakra/media/avatar.pyi
+++ /dev/null
@@ -1,267 +0,0 @@
-"""Stub file for reflex/components/chakra/media/avatar.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Avatar(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- icon: Optional[Union[Var[str], str]] = None,
- icon_label: Optional[Union[Var[str], str]] = None,
- ignore_fallback: Optional[Union[Var[bool], bool]] = None,
- name: Optional[Union[Var[str], str]] = None,
- show_border: Optional[Union[Var[bool], bool]] = None,
- src: Optional[Union[Var[str], str]] = None,
- src_set: Optional[Union[Var[str], str]] = None,
- size: Optional[
- Union[
- Var[Literal["sm", "md", "lg", "xl", "xs", "2xl", "full", "2xs"]],
- Literal["sm", "md", "lg", "xl", "xs", "2xl", "full", "2xs"],
- ]
- ] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_error: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Avatar":
- """Create the component.
-
- Args:
- *children: The children of the component.
- icon: The default avatar used as fallback when name, and src is not specified.
- icon_label: The label of the icon.
- ignore_fallback: If true, opt out of the avatar's fallback logic and renders the img at all times.
- name: The name of the person in the avatar.
- show_border: If true, the Avatar will show a border around it. Best for a group of avatars.
- src: The image url of the Avatar.
- src_set: List of sources to use for different screen resolutions.
- size: "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "full"
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class AvatarBadge(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "AvatarBadge":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class AvatarGroup(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- max_: Optional[Union[Var[int], int]] = None,
- spacing: Optional[Union[Var[int], int]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "AvatarGroup":
- """Create the component.
-
- Args:
- *children: The children of the component.
- max_: The maximum number of visible avatars.
- spacing: The space between the avatars in the group.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/media/icon.py b/reflex/components/chakra/media/icon.py
deleted file mode 100644
index 989ddd111..000000000
--- a/reflex/components/chakra/media/icon.py
+++ /dev/null
@@ -1,111 +0,0 @@
-"""An icon component."""
-
-from typing import List
-
-from reflex.components.chakra import ChakraComponent
-from reflex.utils import format
-
-
-class ChakraIconComponent(ChakraComponent):
- """A component that wraps a Chakra icon component."""
-
- library = "@chakra-ui/icons@2.0.19"
-
-
-class Icon(ChakraIconComponent):
- """An image icon."""
-
- tag = "None"
-
- @classmethod
- def create(cls, *children, **props):
- """Initialize the Icon component.
-
- Run some additional checks on Icon component.
-
- Args:
- *children: The positional arguments
- **props: The keyword arguments
-
- Raises:
- AttributeError: The errors tied to bad usage of the Icon component.
- ValueError: If the icon tag is invalid.
-
- Returns:
- The created component.
- """
- if children:
- raise AttributeError(
- f"Passing children to Icon component is not allowed: remove positional arguments {children} to fix"
- )
- if "tag" not in props:
- raise AttributeError("Missing 'tag' keyword-argument for Icon")
- if not isinstance(props["tag"], str) or props["tag"].lower() not in ICON_LIST:
- raise ValueError(
- f"Invalid icon tag: {props['tag']}. Please use one of the following: {sorted(ICON_LIST)}"
- )
- props["tag"] = format.to_title_case(props["tag"]) + "Icon"
- return super().create(*children, **props)
-
-
-# List of all icons.
-ICON_LIST: List[str] = [
- "add",
- "arrow_back",
- "arrow_down",
- "arrow_forward",
- "arrow_left",
- "arrow_right",
- "arrow_up",
- "arrow_up_down",
- "at_sign",
- "attachment",
- "bell",
- "calendar",
- "chat",
- "check_circle",
- "check",
- "chevron_down",
- "chevron_left",
- "chevron_right",
- "chevron_up",
- "close",
- "copy",
- "delete",
- "download",
- "drag_handle",
- "edit",
- "email",
- "external_link",
- "hamburger",
- "info",
- "info_outline",
- "link",
- "lock",
- "minus",
- "moon",
- "not_allowed",
- "phone",
- "plus_square",
- "question",
- "question_outline",
- "repeat",
- "repeat_clock",
- "search",
- "search2",
- "settings",
- "small_add",
- "small_close",
- "spinner",
- "star",
- "sun",
- "time",
- "triangle_down",
- "triangle_up",
- "unlock",
- "up_down",
- "view",
- "view_off",
- "warning",
- "warning_two",
-]
diff --git a/reflex/components/chakra/media/icon.pyi b/reflex/components/chakra/media/icon.pyi
deleted file mode 100644
index bbd20f673..000000000
--- a/reflex/components/chakra/media/icon.pyi
+++ /dev/null
@@ -1,171 +0,0 @@
-"""Stub file for reflex/components/chakra/media/icon.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class ChakraIconComponent(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "ChakraIconComponent":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class Icon(ChakraIconComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Icon":
- """Initialize the Icon component.
-
- Run some additional checks on Icon component.
-
- Args:
- *children: The positional arguments
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The keyword arguments
-
- Raises:
- AttributeError: The errors tied to bad usage of the Icon component.
- ValueError: If the icon tag is invalid.
-
- Returns:
- The created component.
- """
- ...
-
-ICON_LIST: List[str]
diff --git a/reflex/components/chakra/media/image.py b/reflex/components/chakra/media/image.py
deleted file mode 100644
index b68fe8e6a..000000000
--- a/reflex/components/chakra/media/image.py
+++ /dev/null
@@ -1,74 +0,0 @@
-"""An image component."""
-
-from __future__ import annotations
-
-from typing import Any, Optional
-
-from reflex.components.chakra import ChakraComponent, LiteralImageLoading
-from reflex.components.component import Component
-from reflex.event import EventHandler
-from reflex.vars import Var
-
-
-class Image(ChakraComponent):
- """Display an image."""
-
- tag = "Image"
- alias = "ChakraImage"
- # How to align the image within its bounds. It maps to css `object-position` property.
- align: Var[str]
-
- # Fallback Reflex component to show if image is loading or image fails.
- fallback: Optional[Component] = None
-
- # Fallback image src to show if image is loading or image fails.
- fallback_src: Var[str]
-
- # How the image to fit within its bounds. It maps to css `object-fit` property.
- fit: Var[str]
-
- # The native HTML height attribute to the passed to the img.
- html_height: Var[str]
-
- # The native HTML width attribute to the passed to the img.
- html_width: Var[str]
-
- # If true, opt out of the fallbackSrc logic and use as img.
- ignore_fallback: Var[bool]
-
- # "eager" | "lazy"
- loading: Var[LiteralImageLoading]
-
- # The path/url to the image or PIL image object.
- src: Var[Any]
-
- # The alt text of the image.
- alt: Var[str]
-
- # Provide multiple sources for an image, allowing the browser
- # to select the most appropriate source based on factors like
- # screen resolution and device capabilities.
- # Learn more _[here](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images)_
- src_set: Var[str]
-
- # Fired when the image fails to load.
- on_error: EventHandler[lambda: []]
-
- # Fired when the image is loaded.
- on_load: EventHandler[lambda: []]
-
- @classmethod
- def create(cls, *children, **props) -> Component:
- """Create an Image component.
-
- Args:
- *children: The children of the image.
- **props: The props of the image.
-
- Returns:
- The Image component.
- """
- src = props.get("src", None)
- if src is not None and not isinstance(src, (Var)):
- props["src"] = Var.create(value=src, _var_is_string=True)
- return super().create(*children, **props)
diff --git a/reflex/components/chakra/media/image.pyi b/reflex/components/chakra/media/image.pyi
deleted file mode 100644
index 9e659e856..000000000
--- a/reflex/components/chakra/media/image.pyi
+++ /dev/null
@@ -1,118 +0,0 @@
-"""Stub file for reflex/components/chakra/media/image.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Image(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- align: Optional[Union[Var[str], str]] = None,
- fallback: Optional[Component] = None,
- fallback_src: Optional[Union[Var[str], str]] = None,
- fit: Optional[Union[Var[str], str]] = None,
- html_height: Optional[Union[Var[str], str]] = None,
- html_width: Optional[Union[Var[str], str]] = None,
- ignore_fallback: Optional[Union[Var[bool], bool]] = None,
- loading: Optional[
- Union[Var[Literal["eager", "lazy"]], Literal["eager", "lazy"]]
- ] = None,
- src: Optional[Union[Var[Any], Any]] = None,
- alt: Optional[Union[Var[str], str]] = None,
- src_set: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_error: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_load: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Image":
- """Create an Image component.
-
- Args:
- *children: The children of the image.
- align: How to align the image within its bounds. It maps to css `object-position` property.
- fallback: Fallback Reflex component to show if image is loading or image fails.
- fallback_src: Fallback image src to show if image is loading or image fails.
- fit: How the image to fit within its bounds. It maps to css `object-fit` property.
- html_height: The native HTML height attribute to the passed to the img.
- html_width: The native HTML width attribute to the passed to the img.
- ignore_fallback: If true, opt out of the fallbackSrc logic and use as img.
- loading: "eager" | "lazy"
- src: The path/url to the image or PIL image object.
- alt: The alt text of the image.
- src_set: Provide multiple sources for an image, allowing the browser to select the most appropriate source based on factors like screen resolution and device capabilities. Learn more _[here](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images)_
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the image.
-
- Returns:
- The Image component.
- """
- ...
diff --git a/reflex/components/chakra/navigation/__init__.py b/reflex/components/chakra/navigation/__init__.py
deleted file mode 100644
index 4b61ad8db..000000000
--- a/reflex/components/chakra/navigation/__init__.py
+++ /dev/null
@@ -1,18 +0,0 @@
-"""Navigation components."""
-
-from .breadcrumb import Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbSeparator
-from .link import Link
-from .linkoverlay import LinkBox, LinkOverlay
-from .stepper import (
- Step,
- StepDescription,
- StepIcon,
- StepIndicator,
- StepNumber,
- Stepper,
- StepSeparator,
- StepStatus,
- StepTitle,
-)
-
-__all__ = [f for f in dir() if f[0].isupper()] # type: ignore
diff --git a/reflex/components/chakra/navigation/breadcrumb.py b/reflex/components/chakra/navigation/breadcrumb.py
deleted file mode 100644
index 7c902bf1a..000000000
--- a/reflex/components/chakra/navigation/breadcrumb.py
+++ /dev/null
@@ -1,98 +0,0 @@
-"""Breadcrumb components."""
-
-from reflex.components.chakra import ChakraComponent
-from reflex.components.chakra.navigation.link import Link
-from reflex.components.component import Component
-from reflex.components.core.foreach import Foreach
-from reflex.vars import Var
-
-
-class Breadcrumb(ChakraComponent):
- """The parent container for breadcrumbs."""
-
- tag = "Breadcrumb"
-
- # The visual separator between each breadcrumb item
- separator: Var[str]
-
- # The left and right margin applied to the separator
- separator_margin: Var[str]
-
- @classmethod
- def create(cls, *children, items=None, **props) -> Component:
- """Create a breadcrumb component.
-
- If the kw-args `items` is provided and is a list, they will be added as children.
-
- Args:
- *children: The children of the component.
- items (list): The items of the breadcrumb: (label, link)
- **props: The properties of the component.
-
- Returns:
- The breadcrumb component.
- """
- if len(children) == 0:
- if isinstance(items, Var):
- children = [
- Foreach.create(
- items,
- lambda item: BreadcrumbItem.create(label=item[0], href=item[1]),
- ),
- ]
-
- else:
- children = []
- for label, link in items or []:
- children.append(BreadcrumbItem.create(label=label, href=link))
- return super().create(*children, **props)
-
-
-class BreadcrumbItem(ChakraComponent):
- """Individual breadcrumb element containing a link and a divider."""
-
- tag = "BreadcrumbItem"
-
- # Is the current page of the breadcrumb.
- is_current_page: Var[bool]
-
- # Is the last child of the breadcrumb.
- is_last_child: Var[bool]
-
- # The visual separator between each breadcrumb item
- separator: Var[str]
-
- # The left and right margin applied to the separator
- spacing: Var[str]
-
- @classmethod
- def create(cls, *children, label=None, href=None, **props):
- """Create a Breadcrumb Item component.
-
- Args:
- *children: The children of the component.
- label: The label used in the link. Defaults to None.
- href: The URL of the link. Defaults to None.
- **props: The properties of the component.
-
- Returns:
- The BreadcrumbItem component
- """
- if len(children) == 0:
- children = [BreadcrumbLink.create(label or "", href=href or "")] # type: ignore
- return super().create(*children, **props)
-
-
-class BreadcrumbSeparator(ChakraComponent):
- """The visual separator between each breadcrumb."""
-
- tag = "BreadcrumbSeparator"
-
-
-class BreadcrumbLink(Link):
- """The breadcrumb link."""
-
- tag = "BreadcrumbLink"
-
- # Is the current page of the breadcrumb.
- is_current_page: Var[bool]
diff --git a/reflex/components/chakra/navigation/breadcrumb.pyi b/reflex/components/chakra/navigation/breadcrumb.pyi
deleted file mode 100644
index 3593f4128..000000000
--- a/reflex/components/chakra/navigation/breadcrumb.pyi
+++ /dev/null
@@ -1,351 +0,0 @@
-"""Stub file for reflex/components/chakra/navigation/breadcrumb.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.components.chakra.navigation.link import Link
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Breadcrumb(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- items=None,
- separator: Optional[Union[Var[str], str]] = None,
- separator_margin: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Breadcrumb":
- """Create a breadcrumb component.
-
- If the kw-args `items` is provided and is a list, they will be added as children.
-
- Args:
- *children: The children of the component.
- items (list): The items of the breadcrumb: (label, link)
- separator: The visual separator between each breadcrumb item
- separator_margin: The left and right margin applied to the separator
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Returns:
- The breadcrumb component.
- """
- ...
-
-class BreadcrumbItem(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- label=None,
- href=None,
- is_current_page: Optional[Union[Var[bool], bool]] = None,
- is_last_child: Optional[Union[Var[bool], bool]] = None,
- separator: Optional[Union[Var[str], str]] = None,
- spacing: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "BreadcrumbItem":
- """Create a Breadcrumb Item component.
-
- Args:
- *children: The children of the component.
- label: The label used in the link. Defaults to None.
- href: The URL of the link. Defaults to None.
- is_current_page: Is the current page of the breadcrumb.
- is_last_child: Is the last child of the breadcrumb.
- separator: The visual separator between each breadcrumb item
- spacing: The left and right margin applied to the separator
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Returns:
- The BreadcrumbItem component
- """
- ...
-
-class BreadcrumbSeparator(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "BreadcrumbSeparator":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class BreadcrumbLink(Link):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- is_current_page: Optional[Union[Var[bool], bool]] = None,
- rel: Optional[Union[Var[str], str]] = None,
- href: Optional[Union[Var[str], str]] = None,
- text: Optional[Union[Var[str], str]] = None,
- as_: Optional[Union[Var[str], str]] = None,
- is_external: Optional[Union[Var[bool], bool]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "BreadcrumbLink":
- """Create a Link component.
-
- Args:
- *children: The children of the component.
- is_current_page: Is the current page of the breadcrumb.
- rel: The rel.
- href: The page to link to.
- text: The text to display.
- as_: What the link renders to.
- is_external: If true, the link will open in new tab.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Raises:
- ValueError: in case of missing children
-
- Returns:
- Component: The link component
- """
- ...
diff --git a/reflex/components/chakra/navigation/link.py b/reflex/components/chakra/navigation/link.py
deleted file mode 100644
index e30644acd..000000000
--- a/reflex/components/chakra/navigation/link.py
+++ /dev/null
@@ -1,62 +0,0 @@
-"""A link component."""
-
-from reflex.components.chakra import ChakraComponent
-from reflex.components.component import Component
-from reflex.components.next.link import NextLink
-from reflex.utils.imports import ImportDict
-from reflex.vars import BaseVar, Var
-
-next_link = NextLink.create()
-
-
-class Link(ChakraComponent):
- """Link to another page."""
-
- tag = "Link"
-
- # The rel.
- rel: Var[str]
-
- # The page to link to.
- href: Var[str]
-
- # The text to display.
- text: Var[str]
-
- # What the link renders to.
- as_: Var[str] = BaseVar.create(
- value="{NextLink}", _var_is_local=False, _var_is_string=False
- ) # type: ignore
-
- # If true, the link will open in new tab.
- is_external: Var[bool]
-
- def add_imports(self) -> ImportDict:
- """Add imports for the link component.
-
- Returns:
- The import dict.
- """
- return next_link._get_imports() # type: ignore
-
- @classmethod
- def create(cls, *children, **props) -> Component:
- """Create a Link component.
-
- Args:
- *children: The children of the component.
- **props: The props of the component.
-
- Raises:
- ValueError: in case of missing children
-
- Returns:
- Component: The link component
- """
- if props.get("href") is not None:
- if not len(children):
- raise ValueError("Link without a child will not display")
- else:
- # Don't use a NextLink if there is no href.
- props["as_"] = ""
- return super().create(*children, **props)
diff --git a/reflex/components/chakra/navigation/link.pyi b/reflex/components/chakra/navigation/link.pyi
deleted file mode 100644
index be8f53fec..000000000
--- a/reflex/components/chakra/navigation/link.pyi
+++ /dev/null
@@ -1,105 +0,0 @@
-"""Stub file for reflex/components/chakra/navigation/link.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.components.next.link import NextLink
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.utils.imports import ImportDict
-from reflex.vars import BaseVar, Var
-
-next_link = NextLink.create()
-
-class Link(ChakraComponent):
- def add_imports(self) -> ImportDict: ...
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- rel: Optional[Union[Var[str], str]] = None,
- href: Optional[Union[Var[str], str]] = None,
- text: Optional[Union[Var[str], str]] = None,
- as_: Optional[Union[Var[str], str]] = None,
- is_external: Optional[Union[Var[bool], bool]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Link":
- """Create a Link component.
-
- Args:
- *children: The children of the component.
- rel: The rel.
- href: The page to link to.
- text: The text to display.
- as_: What the link renders to.
- is_external: If true, the link will open in new tab.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Raises:
- ValueError: in case of missing children
-
- Returns:
- Component: The link component
- """
- ...
diff --git a/reflex/components/chakra/navigation/linkoverlay.py b/reflex/components/chakra/navigation/linkoverlay.py
deleted file mode 100644
index 370e3df48..000000000
--- a/reflex/components/chakra/navigation/linkoverlay.py
+++ /dev/null
@@ -1,22 +0,0 @@
-"""Link overlay components."""
-
-from reflex.components.chakra import ChakraComponent
-from reflex.vars import Var
-
-
-class LinkOverlay(ChakraComponent):
- """Wraps child component in a link."""
-
- tag = "LinkOverlay"
-
- # If true, the link will open in new tab
- is_external: Var[bool]
-
- # Href of the link overlay.
- href: Var[str]
-
-
-class LinkBox(ChakraComponent):
- """The LinkBox lifts any nested links to the top using z-index to ensure proper keyboard navigation between links."""
-
- tag = "LinkBox"
diff --git a/reflex/components/chakra/navigation/linkoverlay.pyi b/reflex/components/chakra/navigation/linkoverlay.pyi
deleted file mode 100644
index bac747c2b..000000000
--- a/reflex/components/chakra/navigation/linkoverlay.pyi
+++ /dev/null
@@ -1,167 +0,0 @@
-"""Stub file for reflex/components/chakra/navigation/linkoverlay.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class LinkOverlay(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- is_external: Optional[Union[Var[bool], bool]] = None,
- href: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "LinkOverlay":
- """Create the component.
-
- Args:
- *children: The children of the component.
- is_external: If true, the link will open in new tab
- href: Href of the link overlay.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class LinkBox(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "LinkBox":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/navigation/stepper.py b/reflex/components/chakra/navigation/stepper.py
deleted file mode 100644
index 7c47760e5..000000000
--- a/reflex/components/chakra/navigation/stepper.py
+++ /dev/null
@@ -1,113 +0,0 @@
-"""A component to indicate progress through a multi-step process."""
-
-from typing import List, Literal, Optional, Tuple
-
-from reflex.components.chakra import ChakraComponent, LiteralColorScheme
-from reflex.components.component import Component
-from reflex.vars import Var
-
-
-class Stepper(ChakraComponent):
- """The parent container for a stepper."""
-
- tag = "Stepper"
-
- orientation: Var[Literal["vertical", "horizontal"]]
-
- # The color scheme to use for the stepper; default is blue.
- colorScheme: Var[LiteralColorScheme]
-
- # Chakra provides a useSteps hook to control the stepper.
- # Instead, use an integer state value to set progress in the stepper.
-
- # The index of the current step.
- index: Var[int]
-
- # The size of the steps in the stepper.
- size: Var[str]
-
- @classmethod
- def create(
- cls, *children, items: Optional[List[Tuple]] = None, **props
- ) -> Component:
- """Create a Stepper component.
-
- If the kw-args `items` is provided and is a list, they will be added as children.
-
- Args:
- *children: The children of the component.
- items (list): The child components for each step.
- **props: The properties of the component.
-
- Returns:
- The stepper component.
- """
- if len(children) == 0:
- children = []
- for indicator, layout, separator in items or []:
- children.append(
- Step.create(
- StepIndicator.create(indicator),
- layout,
- StepSeparator.create(separator),
- )
- )
- return super().create(*children, **props)
-
-
-class Step(ChakraComponent):
- """A component for an individual step in the stepper."""
-
- tag = "Step"
-
-
-class StepDescription(ChakraComponent):
- """The description text for a step component."""
-
- tag = "StepDescription"
-
-
-class StepIcon(ChakraComponent):
- """The icon displayed in a step indicator component."""
-
- tag = "StepIcon"
-
-
-class StepIndicator(ChakraComponent):
- """The component displaying the status of a step."""
-
- tag = "StepIndicator"
-
-
-class StepNumber(ChakraComponent):
- """The number of a step displayed in a step indicator component."""
-
- tag = "StepNumber"
-
-
-class StepSeparator(ChakraComponent):
- """The component separting steps."""
-
- tag = "StepSeparator"
-
-
-class StepStatus(ChakraComponent):
- """A component that displays a number or icon based on the status of a step."""
-
- # [not working yet]
- # active, complete, and incomplete should also be able to accept StepIcon or StepNumber components
- # currently, these props only support strings
-
- active: Var[str]
-
- complete: Var[str]
-
- incomplete: Var[str]
-
- tag = "StepStatus"
-
-
-class StepTitle(ChakraComponent):
- """The title text for a step component."""
-
- tag = "StepTitle"
diff --git a/reflex/components/chakra/navigation/stepper.pyi b/reflex/components/chakra/navigation/stepper.pyi
deleted file mode 100644
index ce365f994..000000000
--- a/reflex/components/chakra/navigation/stepper.pyi
+++ /dev/null
@@ -1,762 +0,0 @@
-"""Stub file for reflex/components/chakra/navigation/stepper.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Stepper(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- items: Optional[List[Tuple]] = None,
- orientation: Optional[
- Union[
- Var[Literal["vertical", "horizontal"]],
- Literal["vertical", "horizontal"],
- ]
- ] = None,
- colorScheme: Optional[
- Union[
- Var[
- Literal[
- "none",
- "gray",
- "red",
- "orange",
- "yellow",
- "green",
- "teal",
- "blue",
- "cyan",
- "purple",
- "pink",
- "whiteAlpha",
- "blackAlpha",
- "linkedin",
- "facebook",
- "messenger",
- "whatsapp",
- "twitter",
- "telegram",
- ]
- ],
- Literal[
- "none",
- "gray",
- "red",
- "orange",
- "yellow",
- "green",
- "teal",
- "blue",
- "cyan",
- "purple",
- "pink",
- "whiteAlpha",
- "blackAlpha",
- "linkedin",
- "facebook",
- "messenger",
- "whatsapp",
- "twitter",
- "telegram",
- ],
- ]
- ] = None,
- index: Optional[Union[Var[int], int]] = None,
- size: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Stepper":
- """Create a Stepper component.
-
- If the kw-args `items` is provided and is a list, they will be added as children.
-
- Args:
- *children: The children of the component.
- items (list): The child components for each step.
- colorScheme: The color scheme to use for the stepper; default is blue.
- index: Chakra provides a useSteps hook to control the stepper. Instead, use an integer state value to set progress in the stepper. The index of the current step.
- size: The size of the steps in the stepper.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Returns:
- The stepper component.
- """
- ...
-
-class Step(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Step":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class StepDescription(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "StepDescription":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class StepIcon(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "StepIcon":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class StepIndicator(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "StepIndicator":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class StepNumber(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "StepNumber":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class StepSeparator(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "StepSeparator":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class StepStatus(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- active: Optional[Union[Var[str], str]] = None,
- complete: Optional[Union[Var[str], str]] = None,
- incomplete: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "StepStatus":
- """Create the component.
-
- Args:
- *children: The children of the component.
- active: [not working yet] active, complete, and incomplete should also be able to accept StepIcon or StepNumber components currently, these props only support strings
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class StepTitle(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "StepTitle":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/overlay/__init__.py b/reflex/components/chakra/overlay/__init__.py
deleted file mode 100644
index 322d09318..000000000
--- a/reflex/components/chakra/overlay/__init__.py
+++ /dev/null
@@ -1,50 +0,0 @@
-"""Overlay components."""
-
-from .alertdialog import (
- AlertDialog,
- AlertDialogBody,
- AlertDialogContent,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogOverlay,
-)
-from .drawer import (
- Drawer,
- DrawerBody,
- DrawerCloseButton,
- DrawerContent,
- DrawerFooter,
- DrawerHeader,
- DrawerOverlay,
-)
-from .menu import (
- Menu,
- MenuButton,
- MenuDivider,
- MenuGroup,
- MenuItem,
- MenuItemOption,
- MenuList,
- MenuOptionGroup,
-)
-from .modal import (
- Modal,
- ModalBody,
- ModalCloseButton,
- ModalContent,
- ModalFooter,
- ModalHeader,
- ModalOverlay,
-)
-from .popover import (
- Popover,
- PopoverAnchor,
- PopoverArrow,
- PopoverBody,
- PopoverCloseButton,
- PopoverContent,
- PopoverFooter,
- PopoverHeader,
- PopoverTrigger,
-)
-from .tooltip import Tooltip
diff --git a/reflex/components/chakra/overlay/alertdialog.py b/reflex/components/chakra/overlay/alertdialog.py
deleted file mode 100644
index 72f3ad642..000000000
--- a/reflex/components/chakra/overlay/alertdialog.py
+++ /dev/null
@@ -1,153 +0,0 @@
-"""Alert dialog components."""
-
-from __future__ import annotations
-
-from reflex.components.chakra import ChakraComponent, LiteralAlertDialogSize
-from reflex.components.chakra.media.icon import Icon
-from reflex.components.component import Component
-from reflex.event import EventHandler
-from reflex.vars import Var
-
-
-class AlertDialog(ChakraComponent):
- """Provides context and state for the dialog."""
-
- tag = "AlertDialog"
-
- # If true, the modal will be open.
- is_open: Var[bool]
-
- # The least destructive element to focus when the dialog opens.
- least_destructive_ref: Var[str]
-
- # Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. Defaults to false.
- allow_pinch_zoom: Var[bool]
-
- # If true, the modal will autofocus the first enabled and interactive element within the ModalContent
- auto_focus: Var[bool]
-
- # If true, scrolling will be disabled on the body when the modal opens.
- block_scroll_on_mount: Var[bool]
-
- # If true, the modal will close when the Esc key is pressed
- close_on_esc: Var[bool]
-
- # If true, the modal will close when the overlay is clicked
- close_on_overlay_click: Var[bool]
-
- # If true, the modal will be centered on screen.
- is_centered: Var[bool]
-
- # Enables aggressive focus capturing within iframes. If true, keep focus in the lock, no matter where lock is active. If false, allows focus to move outside of iframe.
- lock_focus_across_frames: Var[bool]
-
- # If true, a `padding-right` will be applied to the body element that's equal to the width of the scrollbar. This can help prevent some unpleasant flickering effect and content adjustment when the modal opens
- preserve_scroll_bar_gap: Var[bool]
-
- # If true, the modal will return focus to the element that triggered it when it closes.
- return_focus_on_close: Var[bool]
-
- # "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "full"
- size: Var[LiteralAlertDialogSize]
-
- # If true, the siblings of the modal will have `aria-hidden` set to true so that screen readers can only see the modal. This is commonly known as making the other elements **inert**
- use_inert: Var[bool]
-
- # Fired when the modal is closing.
- on_close: EventHandler[lambda: []]
-
- # Fired when the modal is closed and the exit animation is complete.
- on_close_complete: EventHandler[lambda: []]
-
- # Fired when the Esc key is pressed.
- on_esc: EventHandler[lambda: []]
-
- # Fired when the overlay is clicked.
- on_overlay_click: EventHandler[lambda: []]
-
- @classmethod
- def create(
- cls, *children, header=None, body=None, footer=None, close_button=None, **props
- ) -> Component:
- """Create an alert dialog component.
-
- Args:
- *children: The children of the alert dialog component.
- header: The header of the alert dialog.
- body: The body of the alert dialog.
- footer: The footer of the alert dialog.
- close_button: The close button of the alert dialog.
- **props: The properties of the alert dialog component.
-
- Raises:
- AttributeError: if there is a conflict between the props used.
-
- Returns:
- The alert dialog component.
- """
- if len(children) == 0:
- contents = []
-
- if header:
- contents.append(AlertDialogHeader.create(header))
-
- if body:
- contents.append(AlertDialogBody.create(body))
-
- if footer:
- contents.append(AlertDialogFooter.create(footer))
-
- # add AlertDialogCloseButton if either a prop for one was passed, or if on_close callback is present
- if props.get("on_close"):
- # get user defined close button or use default one
- if not close_button:
- close_button = Icon.create(tag="close")
- contents.append(AlertDialogCloseButton.create(close_button))
- elif close_button:
- raise AttributeError(
- "Close button can not be used if on_close event handler is not defined"
- )
-
- children = [
- AlertDialogOverlay.create(
- AlertDialogContent.create(*contents),
- )
- ]
-
- return super().create(*children, **props)
-
-
-class AlertDialogBody(ChakraComponent):
- """Should contain the description announced by screen readers."""
-
- tag = "AlertDialogBody"
-
-
-class AlertDialogHeader(ChakraComponent):
- """Should contain the title announced by screen readers."""
-
- tag = "AlertDialogHeader"
-
-
-class AlertDialogFooter(ChakraComponent):
- """Should contain the events of the dialog."""
-
- tag = "AlertDialogFooter"
-
-
-class AlertDialogContent(ChakraComponent):
- """The wrapper for the alert dialog's content."""
-
- tag = "AlertDialogContent"
-
-
-class AlertDialogOverlay(ChakraComponent):
- """The dimmed overlay behind the dialog."""
-
- tag = "AlertDialogOverlay"
-
-
-class AlertDialogCloseButton(ChakraComponent):
- """The button that closes the dialog."""
-
- tag = "AlertDialogCloseButton"
diff --git a/reflex/components/chakra/overlay/alertdialog.pyi b/reflex/components/chakra/overlay/alertdialog.pyi
deleted file mode 100644
index 490684ce4..000000000
--- a/reflex/components/chakra/overlay/alertdialog.pyi
+++ /dev/null
@@ -1,612 +0,0 @@
-"""Stub file for reflex/components/chakra/overlay/alertdialog.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class AlertDialog(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- header=None,
- body=None,
- footer=None,
- close_button=None,
- is_open: Optional[Union[Var[bool], bool]] = None,
- least_destructive_ref: Optional[Union[Var[str], str]] = None,
- allow_pinch_zoom: Optional[Union[Var[bool], bool]] = None,
- auto_focus: Optional[Union[Var[bool], bool]] = None,
- block_scroll_on_mount: Optional[Union[Var[bool], bool]] = None,
- close_on_esc: Optional[Union[Var[bool], bool]] = None,
- close_on_overlay_click: Optional[Union[Var[bool], bool]] = None,
- is_centered: Optional[Union[Var[bool], bool]] = None,
- lock_focus_across_frames: Optional[Union[Var[bool], bool]] = None,
- preserve_scroll_bar_gap: Optional[Union[Var[bool], bool]] = None,
- return_focus_on_close: Optional[Union[Var[bool], bool]] = None,
- size: Optional[
- Union[
- Var[
- Literal[
- "sm",
- "md",
- "lg",
- "xs",
- "2xl",
- "full",
- "3xl",
- "4xl",
- "5xl",
- "6xl",
- ]
- ],
- Literal[
- "sm", "md", "lg", "xs", "2xl", "full", "3xl", "4xl", "5xl", "6xl"
- ],
- ]
- ] = None,
- use_inert: Optional[Union[Var[bool], bool]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close_complete: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_esc: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_overlay_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "AlertDialog":
- """Create an alert dialog component.
-
- Args:
- *children: The children of the alert dialog component.
- header: The header of the alert dialog.
- body: The body of the alert dialog.
- footer: The footer of the alert dialog.
- close_button: The close button of the alert dialog.
- is_open: If true, the modal will be open.
- least_destructive_ref: The least destructive element to focus when the dialog opens.
- allow_pinch_zoom: Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. Defaults to false.
- auto_focus: If true, the modal will autofocus the first enabled and interactive element within the ModalContent
- block_scroll_on_mount: If true, scrolling will be disabled on the body when the modal opens.
- close_on_esc: If true, the modal will close when the Esc key is pressed
- close_on_overlay_click: If true, the modal will close when the overlay is clicked
- is_centered: If true, the modal will be centered on screen.
- lock_focus_across_frames: Enables aggressive focus capturing within iframes. If true, keep focus in the lock, no matter where lock is active. If false, allows focus to move outside of iframe.
- preserve_scroll_bar_gap: If true, a `padding-right` will be applied to the body element that's equal to the width of the scrollbar. This can help prevent some unpleasant flickering effect and content adjustment when the modal opens
- return_focus_on_close: If true, the modal will return focus to the element that triggered it when it closes.
- size: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "full"
- use_inert: If true, the siblings of the modal will have `aria-hidden` set to true so that screen readers can only see the modal. This is commonly known as making the other elements **inert**
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the alert dialog component.
-
- Raises:
- AttributeError: if there is a conflict between the props used.
-
- Returns:
- The alert dialog component.
- """
- ...
-
-class AlertDialogBody(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "AlertDialogBody":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class AlertDialogHeader(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "AlertDialogHeader":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class AlertDialogFooter(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "AlertDialogFooter":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class AlertDialogContent(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "AlertDialogContent":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class AlertDialogOverlay(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "AlertDialogOverlay":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class AlertDialogCloseButton(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "AlertDialogCloseButton":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/overlay/drawer.py b/reflex/components/chakra/overlay/drawer.py
deleted file mode 100644
index b8f286855..000000000
--- a/reflex/components/chakra/overlay/drawer.py
+++ /dev/null
@@ -1,168 +0,0 @@
-"""Container to stack elements with spacing."""
-
-from __future__ import annotations
-
-from reflex.components.chakra import (
- ChakraComponent,
- LiteralColorScheme,
- LiteralDrawerSize,
-)
-from reflex.components.chakra.media.icon import Icon
-from reflex.components.component import Component
-from reflex.event import EventHandler
-from reflex.vars import Var
-
-
-class Drawer(ChakraComponent):
- """A drawer component."""
-
- tag = "Drawer"
-
- # If true, the modal will be open.
- is_open: Var[bool]
-
- # Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. Defaults to false.
- allow_pinch_zoom: Var[bool]
-
- # If true, the modal will autofocus the first enabled and interactive element within the ModalContent
- auto_focus: Var[bool]
-
- # If true, scrolling will be disabled on the body when the modal opens.
- block_scroll_on_mount: Var[bool]
-
- # If true, the modal will close when the Esc key is pressed
- close_on_esc: Var[bool]
-
- # If true, the modal will close when the overlay is clicked
- close_on_overlay_click: Var[bool]
-
- # If true, the modal will be centered on screen.
- is_centered: Var[bool]
-
- # If true and drawer's placement is top or bottom, the drawer will occupy the viewport height (100vh)
- is_full_height: Var[bool]
-
- # Enables aggressive focus capturing within iframes. - If true: keep focus in the lock, no matter where lock is active - If false: allows focus to move outside of iframe
- lock_focus_across_frames: Var[bool]
-
- # The placement of the drawer
- placement: Var[str]
-
- # If true, a `padding-right` will be applied to the body element that's equal to the width of the scrollbar. This can help prevent some unpleasant flickering effect and content adjustment when the modal opens
- preserve_scroll_bar_gap: Var[bool]
-
- # If true, the modal will return focus to the element that triggered it when it closes.
- return_focus_on_close: Var[bool]
-
- # "xs" | "sm" | "md" | "lg" | "xl" | "full"
- size: Var[LiteralDrawerSize]
-
- # A11y: If true, the siblings of the modal will have `aria-hidden` set to true so that screen readers can only see the modal. This is commonly known as making the other elements **inert**
- use_inert: Var[bool]
-
- # Variant of drawer
- variant: Var[str]
-
- # Color scheme of the Drawer
- # Options:
- # "whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan"
- # | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram"
- color_scheme: Var[LiteralColorScheme]
-
- # Fired when the modal is closing.
- on_close: EventHandler[lambda: []]
-
- # Fired when the modal is closed and the exit animation is complete.
- on_close_complete: EventHandler[lambda: []]
-
- # Fired when the Esc key is pressed.
- on_esc: EventHandler[lambda: []]
-
- # Fired when the overlay is clicked.
- on_overlay_click: EventHandler[lambda: []]
-
- @classmethod
- def create(
- cls, *children, header=None, body=None, footer=None, close_button=None, **props
- ) -> Component:
- """Create a drawer component.
-
- Args:
- *children: The children of the drawer component.
- header: The header of the drawer.
- body: The body of the drawer.
- footer: The footer of the drawer.
- close_button: The close button of the drawer.
- **props: The properties of the drawer component.
-
- Raises:
- AttributeError: error that occurs if conflicting props are passed
-
- Returns:
- The drawer component.
- """
- if len(children) == 0:
- contents = []
-
- if header:
- contents.append(DrawerHeader.create(header))
-
- if body:
- contents.append(DrawerBody.create(body))
-
- if footer:
- contents.append(DrawerFooter.create(footer))
-
- if props.get("on_close"):
- # use default close button if undefined
- if not close_button:
- close_button = Icon.create(tag="close")
- contents.append(DrawerCloseButton.create(close_button))
- elif close_button:
- raise AttributeError(
- "Close button can not be used if on_close event handler is not defined"
- )
-
- children = [
- DrawerOverlay.create(
- DrawerContent.create(*contents),
- )
- ]
-
- return super().create(*children, **props)
-
-
-class DrawerBody(ChakraComponent):
- """Drawer body."""
-
- tag = "DrawerBody"
-
-
-class DrawerHeader(ChakraComponent):
- """Drawer header."""
-
- tag = "DrawerHeader"
-
-
-class DrawerFooter(ChakraComponent):
- """Drawer footer."""
-
- tag = "DrawerFooter"
-
-
-class DrawerOverlay(ChakraComponent):
- """Drawer overlay."""
-
- tag = "DrawerOverlay"
-
-
-class DrawerContent(ChakraComponent):
- """Drawer content."""
-
- tag = "DrawerContent"
-
-
-class DrawerCloseButton(ChakraComponent):
- """Drawer close button."""
-
- tag = "DrawerCloseButton"
diff --git a/reflex/components/chakra/overlay/drawer.pyi b/reflex/components/chakra/overlay/drawer.pyi
deleted file mode 100644
index 1adc43f3e..000000000
--- a/reflex/components/chakra/overlay/drawer.pyi
+++ /dev/null
@@ -1,652 +0,0 @@
-"""Stub file for reflex/components/chakra/overlay/drawer.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import (
- ChakraComponent,
-)
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Drawer(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- header=None,
- body=None,
- footer=None,
- close_button=None,
- is_open: Optional[Union[Var[bool], bool]] = None,
- allow_pinch_zoom: Optional[Union[Var[bool], bool]] = None,
- auto_focus: Optional[Union[Var[bool], bool]] = None,
- block_scroll_on_mount: Optional[Union[Var[bool], bool]] = None,
- close_on_esc: Optional[Union[Var[bool], bool]] = None,
- close_on_overlay_click: Optional[Union[Var[bool], bool]] = None,
- is_centered: Optional[Union[Var[bool], bool]] = None,
- is_full_height: Optional[Union[Var[bool], bool]] = None,
- lock_focus_across_frames: Optional[Union[Var[bool], bool]] = None,
- placement: Optional[Union[Var[str], str]] = None,
- preserve_scroll_bar_gap: Optional[Union[Var[bool], bool]] = None,
- return_focus_on_close: Optional[Union[Var[bool], bool]] = None,
- size: Optional[
- Union[
- Var[Literal["sm", "md", "lg", "xs", "xl", "full"]],
- Literal["sm", "md", "lg", "xs", "xl", "full"],
- ]
- ] = None,
- use_inert: Optional[Union[Var[bool], bool]] = None,
- variant: Optional[Union[Var[str], str]] = None,
- color_scheme: Optional[
- Union[
- Var[
- Literal[
- "none",
- "gray",
- "red",
- "orange",
- "yellow",
- "green",
- "teal",
- "blue",
- "cyan",
- "purple",
- "pink",
- "whiteAlpha",
- "blackAlpha",
- "linkedin",
- "facebook",
- "messenger",
- "whatsapp",
- "twitter",
- "telegram",
- ]
- ],
- Literal[
- "none",
- "gray",
- "red",
- "orange",
- "yellow",
- "green",
- "teal",
- "blue",
- "cyan",
- "purple",
- "pink",
- "whiteAlpha",
- "blackAlpha",
- "linkedin",
- "facebook",
- "messenger",
- "whatsapp",
- "twitter",
- "telegram",
- ],
- ]
- ] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close_complete: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_esc: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_overlay_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Drawer":
- """Create a drawer component.
-
- Args:
- *children: The children of the drawer component.
- header: The header of the drawer.
- body: The body of the drawer.
- footer: The footer of the drawer.
- close_button: The close button of the drawer.
- is_open: If true, the modal will be open.
- allow_pinch_zoom: Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. Defaults to false.
- auto_focus: If true, the modal will autofocus the first enabled and interactive element within the ModalContent
- block_scroll_on_mount: If true, scrolling will be disabled on the body when the modal opens.
- close_on_esc: If true, the modal will close when the Esc key is pressed
- close_on_overlay_click: If true, the modal will close when the overlay is clicked
- is_centered: If true, the modal will be centered on screen.
- is_full_height: If true and drawer's placement is top or bottom, the drawer will occupy the viewport height (100vh)
- lock_focus_across_frames: Enables aggressive focus capturing within iframes. - If true: keep focus in the lock, no matter where lock is active - If false: allows focus to move outside of iframe
- placement: The placement of the drawer
- preserve_scroll_bar_gap: If true, a `padding-right` will be applied to the body element that's equal to the width of the scrollbar. This can help prevent some unpleasant flickering effect and content adjustment when the modal opens
- return_focus_on_close: If true, the modal will return focus to the element that triggered it when it closes.
- size: "xs" | "sm" | "md" | "lg" | "xl" | "full"
- use_inert: A11y: If true, the siblings of the modal will have `aria-hidden` set to true so that screen readers can only see the modal. This is commonly known as making the other elements **inert**
- variant: Variant of drawer
- color_scheme: Color scheme of the Drawer Options: "whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram"
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the drawer component.
-
- Raises:
- AttributeError: error that occurs if conflicting props are passed
-
- Returns:
- The drawer component.
- """
- ...
-
-class DrawerBody(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "DrawerBody":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class DrawerHeader(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "DrawerHeader":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class DrawerFooter(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "DrawerFooter":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class DrawerOverlay(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "DrawerOverlay":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class DrawerContent(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "DrawerContent":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class DrawerCloseButton(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "DrawerCloseButton":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/overlay/menu.py b/reflex/components/chakra/overlay/menu.py
deleted file mode 100644
index 88ccf8a35..000000000
--- a/reflex/components/chakra/overlay/menu.py
+++ /dev/null
@@ -1,225 +0,0 @@
-"""Menu components."""
-
-from __future__ import annotations
-
-from typing import List, Optional
-
-from reflex.components.chakra import (
- ChakraComponent,
- LiteralChakraDirection,
- LiteralMenuOption,
- LiteralMenuStrategy,
-)
-from reflex.components.chakra.forms.button import Button
-from reflex.components.component import Component
-from reflex.event import EventHandler
-from reflex.vars import Var
-
-
-class Menu(ChakraComponent):
- """The wrapper component provides context, state, and focus management."""
-
- tag = "Menu"
-
- # The padding required to prevent the arrow from reaching the very edge of the popper.
- arrow_padding: Var[int]
-
- # If true, the first enabled menu item will receive focus and be selected when the menu opens.
- auto_select: Var[bool]
-
- # The boundary area for the popper. Used within the preventOverflow modifier
- boundary: Var[str]
-
- # If true, the menu will close when you click outside the menu list
- close_on_blur: Var[bool]
-
- # If true, the menu will close when a menu item is clicked
- close_on_select: Var[bool]
-
- # If by default the menu is open.
- default_is_open: Var[bool]
-
- # If rtl, popper placement positions will be flipped i.e. 'top-right' will become 'top-left' and vice-verse ("ltr" | "rtl")
- direction: Var[LiteralChakraDirection]
-
- # If true, the popper will change its placement and flip when it's about to overflow its boundary area.
- flip: Var[bool]
-
- # The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter.
- gutter: Var[int]
-
- # Performance 🚀: If true, the MenuItem rendering will be deferred until the menu is open.
- is_lazy: Var[bool]
-
- # Performance 🚀: The lazy behavior of menu's content when not visible. Only works when `isLazy={true}` - "unmount": The menu's content is always unmounted when not open. - "keepMounted": The menu's content initially unmounted, but stays mounted when menu is open.
- lazy_behavior: Var[str]
-
- # Determines if the menu is open or not.
- is_open: Var[bool]
-
- # If true, the popper will match the width of the reference at all times. It's useful for autocomplete, `date-picker` and select patterns.
- match_width: Var[bool]
-
- # The placement of the popper relative to its reference.
- placement: Var[str]
-
- # If true, will prevent the popper from being cut off and ensure it's visible within the boundary area.
- prevent_overflow: Var[bool]
-
- # The CSS positioning strategy to use. ("fixed" | "absolute")
- strategy: Var[LiteralMenuStrategy]
-
- # Fired when the menu is closed.
- on_close: EventHandler[lambda: []]
-
- # Fired when the menu is opened.
- on_open: EventHandler[lambda: []]
-
- @classmethod
- def create(
- cls,
- *children,
- button: Optional[Component] = None,
- items: Optional[List] = None,
- **props,
- ) -> Component:
- """Create a menu component.
-
- Args:
- *children: The children of the component.
- button: the button that open the menu.
- items (list): The items of the menu.
- **props: The properties of the component.
-
- Returns:
- The menu component.
- """
- if len(children) == 0:
- children = []
-
- if button:
- if not isinstance(button, (MenuButton, Button)):
- children.append(MenuButton.create(button))
- else:
- children.append(button)
- if not items:
- items = []
- children.append(MenuList.create(items=items))
- return super().create(*children, **props)
-
-
-class MenuButton(ChakraComponent):
- """The trigger for the menu list. Must be a direct child of Menu."""
-
- tag = "MenuButton"
-
- # The variant of the menu button.
- variant: Var[str]
-
- # Components that are not allowed as children.
- _invalid_children: List[str] = ["Button", "MenuButton"]
-
- # The tag to use for the menu button.
- as_: Var[str]
-
-
-class MenuList(ChakraComponent):
- """The wrapper for the menu items. Must be a direct child of Menu."""
-
- tag = "MenuList"
-
- @classmethod
- def create(cls, *children, items: Optional[list] = None, **props) -> Component:
- """Create a MenuList component, and automatically wrap in MenuItem if not already one.
-
- Args:
- *children: The children of the component.
- items: A list of item to add as child of the component.
- **props: The properties of the component.
-
- Returns:
- The MenuList component.
- """
- if len(children) == 0:
- if items is None:
- items = []
- children = [
- child if isinstance(child, MenuItem) else MenuItem.create(child)
- for child in items
- ]
- return super().create(*children, **props)
-
-
-class MenuItem(ChakraComponent):
- """The trigger that handles menu selection. Must be a direct child of a MenuList."""
-
- tag = "MenuItem"
-
- # Overrides the parent menu's closeOnSelect prop.
- close_on_select: Var[bool]
-
- # Right-aligned label text content, useful for displaying hotkeys.
- command: Var[str]
-
- # The spacing between the command and menu item's label.
- command_spacing: Var[int]
-
- # If true, the menuitem will be disabled.
- is_disabled: Var[bool]
-
- # If true and the menuitem is disabled, it'll remain keyboard-focusable
- is_focusable: Var[bool]
-
-
-class MenuItemOption(ChakraComponent):
- """The checkable menu item, to be used with MenuOptionGroup."""
-
- tag = "MenuItemOption"
-
- # Overrides the parent menu's closeOnSelect prop.
- close_on_select: Var[bool]
-
- # Right-aligned label text content, useful for displaying hotkeys.
- command: Var[str]
-
- # The spacing between the command and menu item's label.
- command_spacing: Var[int]
-
- # Determines if menu item is checked.
- is_checked: Var[bool]
-
- # If true, the menuitem will be disabled.
- is_disabled: Var[bool]
-
- # If true and the menuitem is disabled, it'll remain keyboard-focusable
- is_focusable: Var[bool]
-
- # "checkbox" | "radio"
- type_: Var[LiteralMenuOption]
-
- # Value of the menu item.
- value: Var[str]
-
-
-class MenuGroup(ChakraComponent):
- """A wrapper to group related menu items."""
-
- tag = "MenuGroup"
-
-
-class MenuOptionGroup(ChakraComponent):
- """A wrapper for checkable menu items (radio and checkbox)."""
-
- tag = "MenuOptionGroup"
-
- # "checkbox" | "radio"
- type_: Var[LiteralMenuOption]
-
- # Value of the option group.
- value: Var[str]
-
-
-class MenuDivider(ChakraComponent):
- """A visual separator for menu items and groups."""
-
- tag = "MenuDivider"
diff --git a/reflex/components/chakra/overlay/menu.pyi b/reflex/components/chakra/overlay/menu.pyi
deleted file mode 100644
index 5288251e0..000000000
--- a/reflex/components/chakra/overlay/menu.pyi
+++ /dev/null
@@ -1,708 +0,0 @@
-"""Stub file for reflex/components/chakra/overlay/menu.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
-
-from reflex.components.chakra import (
- ChakraComponent,
-)
-from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Menu(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- button: Optional[Component] = None,
- items: Optional[List] = None,
- arrow_padding: Optional[Union[Var[int], int]] = None,
- auto_select: Optional[Union[Var[bool], bool]] = None,
- boundary: Optional[Union[Var[str], str]] = None,
- close_on_blur: Optional[Union[Var[bool], bool]] = None,
- close_on_select: Optional[Union[Var[bool], bool]] = None,
- default_is_open: Optional[Union[Var[bool], bool]] = None,
- direction: Optional[
- Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]
- ] = None,
- flip: Optional[Union[Var[bool], bool]] = None,
- gutter: Optional[Union[Var[int], int]] = None,
- is_lazy: Optional[Union[Var[bool], bool]] = None,
- lazy_behavior: Optional[Union[Var[str], str]] = None,
- is_open: Optional[Union[Var[bool], bool]] = None,
- match_width: Optional[Union[Var[bool], bool]] = None,
- placement: Optional[Union[Var[str], str]] = None,
- prevent_overflow: Optional[Union[Var[bool], bool]] = None,
- strategy: Optional[
- Union[Var[Literal["fixed", "absolute"]], Literal["fixed", "absolute"]]
- ] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_open: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Menu":
- """Create a menu component.
-
- Args:
- *children: The children of the component.
- button: the button that open the menu.
- items (list): The items of the menu.
- arrow_padding: The padding required to prevent the arrow from reaching the very edge of the popper.
- auto_select: If true, the first enabled menu item will receive focus and be selected when the menu opens.
- boundary: The boundary area for the popper. Used within the preventOverflow modifier
- close_on_blur: If true, the menu will close when you click outside the menu list
- close_on_select: If true, the menu will close when a menu item is clicked
- default_is_open: If by default the menu is open.
- direction: If rtl, popper placement positions will be flipped i.e. 'top-right' will become 'top-left' and vice-verse ("ltr" | "rtl")
- flip: If true, the popper will change its placement and flip when it's about to overflow its boundary area.
- gutter: The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter.
- is_lazy: Performance 🚀: If true, the MenuItem rendering will be deferred until the menu is open.
- lazy_behavior: Performance 🚀: The lazy behavior of menu's content when not visible. Only works when `isLazy={true}` - "unmount": The menu's content is always unmounted when not open. - "keepMounted": The menu's content initially unmounted, but stays mounted when menu is open.
- is_open: Determines if the menu is open or not.
- match_width: If true, the popper will match the width of the reference at all times. It's useful for autocomplete, `date-picker` and select patterns.
- placement: The placement of the popper relative to its reference.
- prevent_overflow: If true, will prevent the popper from being cut off and ensure it's visible within the boundary area.
- strategy: The CSS positioning strategy to use. ("fixed" | "absolute")
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Returns:
- The menu component.
- """
- ...
-
-class MenuButton(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- variant: Optional[Union[Var[str], str]] = None,
- as_: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "MenuButton":
- """Create the component.
-
- Args:
- *children: The children of the component.
- variant: The variant of the menu button.
- as_: The tag to use for the menu button.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class MenuList(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- items: Optional[list] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "MenuList":
- """Create a MenuList component, and automatically wrap in MenuItem if not already one.
-
- Args:
- *children: The children of the component.
- items: A list of item to add as child of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Returns:
- The MenuList component.
- """
- ...
-
-class MenuItem(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- close_on_select: Optional[Union[Var[bool], bool]] = None,
- command: Optional[Union[Var[str], str]] = None,
- command_spacing: Optional[Union[Var[int], int]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_focusable: Optional[Union[Var[bool], bool]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "MenuItem":
- """Create the component.
-
- Args:
- *children: The children of the component.
- close_on_select: Overrides the parent menu's closeOnSelect prop.
- command: Right-aligned label text content, useful for displaying hotkeys.
- command_spacing: The spacing between the command and menu item's label.
- is_disabled: If true, the menuitem will be disabled.
- is_focusable: If true and the menuitem is disabled, it'll remain keyboard-focusable
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class MenuItemOption(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- close_on_select: Optional[Union[Var[bool], bool]] = None,
- command: Optional[Union[Var[str], str]] = None,
- command_spacing: Optional[Union[Var[int], int]] = None,
- is_checked: Optional[Union[Var[bool], bool]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_focusable: Optional[Union[Var[bool], bool]] = None,
- type_: Optional[
- Union[Var[Literal["checkbox", "radio"]], Literal["checkbox", "radio"]]
- ] = None,
- value: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "MenuItemOption":
- """Create the component.
-
- Args:
- *children: The children of the component.
- close_on_select: Overrides the parent menu's closeOnSelect prop.
- command: Right-aligned label text content, useful for displaying hotkeys.
- command_spacing: The spacing between the command and menu item's label.
- is_checked: Determines if menu item is checked.
- is_disabled: If true, the menuitem will be disabled.
- is_focusable: If true and the menuitem is disabled, it'll remain keyboard-focusable
- type_: "checkbox" | "radio"
- value: Value of the menu item.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class MenuGroup(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "MenuGroup":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class MenuOptionGroup(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- type_: Optional[
- Union[Var[Literal["checkbox", "radio"]], Literal["checkbox", "radio"]]
- ] = None,
- value: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "MenuOptionGroup":
- """Create the component.
-
- Args:
- *children: The children of the component.
- type_: "checkbox" | "radio"
- value: Value of the option group.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class MenuDivider(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "MenuDivider":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/overlay/modal.py b/reflex/components/chakra/overlay/modal.py
deleted file mode 100644
index 522327058..000000000
--- a/reflex/components/chakra/overlay/modal.py
+++ /dev/null
@@ -1,166 +0,0 @@
-"""Modal components."""
-
-from __future__ import annotations
-
-from typing import Literal, Optional, Union
-
-from reflex.components.chakra import ChakraComponent
-from reflex.components.chakra.media import Icon
-from reflex.components.component import Component
-from reflex.event import EventHandler
-from reflex.vars import Var
-
-ModalSizes = Literal["xs", "sm", "md", "lg", "xl", "full"]
-
-
-class Modal(ChakraComponent):
- """The wrapper that provides context for its children."""
-
- tag = "Modal"
-
- # If true, the modal will be open.
- is_open: Var[bool]
-
- # Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. Defaults to false.
- allow_pinch_zoom: Var[bool]
-
- # If true, the modal will autofocus the first enabled and interactive element within the ModalContent
- auto_focus: Var[bool]
-
- # If true, scrolling will be disabled on the body when the modal opens.
- block_scroll_on_mount: Var[bool]
-
- # If true, the modal will close when the Esc key is pressed
- close_on_esc: Var[bool]
-
- # If true, the modal will close when the overlay is clicked
- close_on_overlay_click: Var[bool]
-
- # If true, the modal will be centered on screen.
- is_centered: Var[bool]
-
- # Enables aggressive focus capturing within iframes. - If true: keep focus in the lock, no matter where lock is active - If false: allows focus to move outside of iframe
- lock_focus_across_frames: Var[bool]
-
- # The transition that should be used for the modal
- motion_preset: Var[str]
-
- # If true, a `padding-right` will be applied to the body element that's equal to the width of the scrollbar. This can help prevent some unpleasant flickering effect and content adjustment when the modal opens
- preserve_scroll_bar_gap: Var[bool]
-
- # If true, the modal will return focus to the element that triggered it when it closes.
- return_focus_on_close: Var[bool]
-
- # "xs" | "sm" | "md" | "lg" | "xl" | "full"
- size: Var[ModalSizes]
-
- # A11y: If true, the siblings of the modal will have `aria-hidden` set to true so that screen readers can only see the modal. This is commonly known as making the other elements **inert**
- use_inert: Var[bool]
-
- # Fired when the modal is closing.
- on_close: EventHandler[lambda: []]
-
- # Fired when the modal is closed and the exit animation is complete.
- on_close_complete: EventHandler[lambda: []]
-
- # Fired when the Esc key is pressed.
- on_esc: EventHandler[lambda: []]
-
- # Fired when the overlay is clicked.
- on_overlay_click: EventHandler[lambda: []]
-
- @classmethod
- def create(
- cls,
- *children,
- header: Optional[Union[Component, str]] = None,
- body: Optional[Union[Component, str]] = None,
- footer: Optional[Union[Component, str]] = None,
- close_button: Optional[Component] = None,
- **props,
- ) -> Component:
- """Create a modal component.
-
- Args:
- *children: The children of the component.
- header: The header of the modal.
- body: The body of the modal.
- footer: The footer of the modal.
- close_button: The close button of the modal.
- **props: The properties of the component.
-
- Raises:
- AttributeError: error that occurs if conflicting props are passed
-
- Returns:
- The modal component.
- """
- if len(children) == 0:
- contents = []
-
- # add header if present in props
- if header:
- contents.append(ModalHeader.create(header))
-
- # add ModalBody if present in props
- if body:
- contents.append(ModalBody.create(body))
-
- # add ModalFooter if present in props
- if footer:
- contents.append(ModalFooter.create(footer))
-
- # add ModalCloseButton if either a prop for one was passed, or if
- if props.get("on_close"):
- # get user defined close button or use default one
- if not close_button:
- close_button = Icon.create(tag="close")
- contents.append(ModalCloseButton.create(close_button))
- elif close_button:
- raise AttributeError(
- "Close button can not be used if on_close event handler is not defined"
- )
-
- children = [
- ModalOverlay.create(
- ModalContent.create(*contents),
- )
- ]
-
- return super().create(*children, **props)
-
-
-class ModalOverlay(ChakraComponent):
- """The dimmed overlay behind the modal dialog."""
-
- tag = "ModalOverlay"
-
-
-class ModalHeader(ChakraComponent):
- """The header that labels the modal dialog."""
-
- tag = "ModalHeader"
-
-
-class ModalFooter(ChakraComponent):
- """The footer that houses the modal events."""
-
- tag = "ModalFooter"
-
-
-class ModalContent(ChakraComponent):
- """The container for the modal dialog's content."""
-
- tag = "ModalContent"
-
-
-class ModalBody(ChakraComponent):
- """The wrapper that houses the modal's main content."""
-
- tag = "ModalBody"
-
-
-class ModalCloseButton(ChakraComponent):
- """The button that closes the modal."""
-
- tag = "ModalCloseButton"
diff --git a/reflex/components/chakra/overlay/modal.pyi b/reflex/components/chakra/overlay/modal.pyi
deleted file mode 100644
index 396c4a7a7..000000000
--- a/reflex/components/chakra/overlay/modal.pyi
+++ /dev/null
@@ -1,600 +0,0 @@
-"""Stub file for reflex/components/chakra/overlay/modal.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-ModalSizes = Literal["xs", "sm", "md", "lg", "xl", "full"]
-
-class Modal(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- header: Optional[Union[Component, str]] = None,
- body: Optional[Union[Component, str]] = None,
- footer: Optional[Union[Component, str]] = None,
- close_button: Optional[Component] = None,
- is_open: Optional[Union[Var[bool], bool]] = None,
- allow_pinch_zoom: Optional[Union[Var[bool], bool]] = None,
- auto_focus: Optional[Union[Var[bool], bool]] = None,
- block_scroll_on_mount: Optional[Union[Var[bool], bool]] = None,
- close_on_esc: Optional[Union[Var[bool], bool]] = None,
- close_on_overlay_click: Optional[Union[Var[bool], bool]] = None,
- is_centered: Optional[Union[Var[bool], bool]] = None,
- lock_focus_across_frames: Optional[Union[Var[bool], bool]] = None,
- motion_preset: Optional[Union[Var[str], str]] = None,
- preserve_scroll_bar_gap: Optional[Union[Var[bool], bool]] = None,
- return_focus_on_close: Optional[Union[Var[bool], bool]] = None,
- size: Optional[
- Union[
- Var[Literal["xs", "sm", "md", "lg", "xl", "full"]],
- Literal["xs", "sm", "md", "lg", "xl", "full"],
- ]
- ] = None,
- use_inert: Optional[Union[Var[bool], bool]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close_complete: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_esc: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_overlay_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Modal":
- """Create a modal component.
-
- Args:
- *children: The children of the component.
- header: The header of the modal.
- body: The body of the modal.
- footer: The footer of the modal.
- close_button: The close button of the modal.
- is_open: If true, the modal will be open.
- allow_pinch_zoom: Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. Defaults to false.
- auto_focus: If true, the modal will autofocus the first enabled and interactive element within the ModalContent
- block_scroll_on_mount: If true, scrolling will be disabled on the body when the modal opens.
- close_on_esc: If true, the modal will close when the Esc key is pressed
- close_on_overlay_click: If true, the modal will close when the overlay is clicked
- is_centered: If true, the modal will be centered on screen.
- lock_focus_across_frames: Enables aggressive focus capturing within iframes. - If true: keep focus in the lock, no matter where lock is active - If false: allows focus to move outside of iframe
- motion_preset: The transition that should be used for the modal
- preserve_scroll_bar_gap: If true, a `padding-right` will be applied to the body element that's equal to the width of the scrollbar. This can help prevent some unpleasant flickering effect and content adjustment when the modal opens
- return_focus_on_close: If true, the modal will return focus to the element that triggered it when it closes.
- size: "xs" | "sm" | "md" | "lg" | "xl" | "full"
- use_inert: A11y: If true, the siblings of the modal will have `aria-hidden` set to true so that screen readers can only see the modal. This is commonly known as making the other elements **inert**
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Raises:
- AttributeError: error that occurs if conflicting props are passed
-
- Returns:
- The modal component.
- """
- ...
-
-class ModalOverlay(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "ModalOverlay":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class ModalHeader(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "ModalHeader":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class ModalFooter(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "ModalFooter":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class ModalContent(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "ModalContent":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class ModalBody(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "ModalBody":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class ModalCloseButton(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "ModalCloseButton":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/overlay/popover.py b/reflex/components/chakra/overlay/popover.py
deleted file mode 100644
index 76b74600c..000000000
--- a/reflex/components/chakra/overlay/popover.py
+++ /dev/null
@@ -1,183 +0,0 @@
-"""Popover components."""
-
-from __future__ import annotations
-
-from reflex.components.chakra import (
- ChakraComponent,
- LiteralChakraDirection,
- LiteralMenuStrategy,
- LiteralPopOverTrigger,
-)
-from reflex.components.component import Component
-from reflex.event import EventHandler
-from reflex.vars import Var
-
-
-class Popover(ChakraComponent):
- """The wrapper that provides props, state, and context to its children."""
-
- tag = "Popover"
-
- # The padding required to prevent the arrow from reaching the very edge of the popper.
- arrow_padding: Var[int]
-
- # The `box-shadow` of the popover arrow
- arrow_shadow_color: Var[str]
-
- # The size of the popover arrow
- arrow_size: Var[int]
-
- # If true, focus will be transferred to the first interactive element when the popover opens
- auto_focus: Var[bool]
-
- # The boundary area for the popper. Used within the preventOverflow modifier
- boundary: Var[str]
-
- # If true, the popover will close when you blur out it by clicking outside or tabbing out
- close_on_blur: Var[bool]
-
- # If true, the popover will close when you hit the Esc key
- close_on_esc: Var[bool]
-
- # If true, the popover will be initially opened.
- default_is_open: Var[bool]
-
- # Theme direction ltr or rtl. Popper's placement will be set accordingly
- direction: Var[LiteralChakraDirection]
-
- # If true, the popper will change its placement and flip when it's about to overflow its boundary area.
- flip: Var[bool]
-
- # The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter.
- gutter: Var[int]
-
- # The html id attribute of the popover. If not provided, we generate a unique id. This id is also used to auto-generate the `aria-labelledby` and `aria-describedby` attributes that points to the PopoverHeader and PopoverBody
- id_: Var[str]
-
- # Performance 🚀: If true, the PopoverContent rendering will be deferred until the popover is open.
- is_lazy: Var[bool]
-
- # Performance 🚀: The lazy behavior of popover's content when not visible. Only works when `isLazy={true}` - "unmount": The popover's content is always unmounted when not open. - "keepMounted": The popover's content initially unmounted, but stays mounted when popover is open.
- lazy_behavior: Var[str]
-
- # If true, the popover will be opened in controlled mode.
- is_open: Var[bool]
-
- # If true, the popper will match the width of the reference at all times. It's useful for autocomplete, `date-picker` and select patterns.
- match_width: Var[bool]
-
- # The placement of the popover. It's used internally by Popper.js.
- placement: Var[str]
-
- # If true, will prevent the popper from being cut off and ensure it's visible within the boundary area.
- prevent_overflow: Var[bool]
-
- # If true, focus will be returned to the element that triggers the popover when it closes
- return_focus_on_close: Var[bool]
-
- # The CSS positioning strategy to use. ("fixed" | "absolute")
- strategy: Var[LiteralMenuStrategy]
-
- # The interaction that triggers the popover. hover - means the popover will open when you hover with mouse or focus with keyboard on the popover trigger click - means the popover will open on click or press Enter to Space on keyboard ("click" | "hover")
- trigger: Var[LiteralPopOverTrigger]
-
- # Fired when the popover is closed.
- on_close: EventHandler[lambda: []]
-
- # Fired when the popover is opened.
- on_open: EventHandler[lambda: []]
-
- @classmethod
- def create(
- cls,
- *children,
- trigger=None,
- header=None,
- body=None,
- footer=None,
- use_close_button=False,
- **props,
- ) -> Component:
- """Create a popover component.
-
- Args:
- *children: The children of the component.
- trigger: The trigger that opens the popover.
- header: The header of the popover.
- body: The body of the popover.
- footer: The footer of the popover.
- use_close_button: Whether to add a close button on the popover.
- **props: The properties of the component.
-
- Returns:
- The popover component.
- """
- if len(children) == 0:
- contents = []
-
- trigger = PopoverTrigger.create(trigger)
-
- # add header if present in props
- if header:
- contents.append(PopoverHeader.create(header))
-
- if body:
- contents.append(PopoverBody.create(body))
-
- if footer:
- contents.append(PopoverFooter.create(footer))
-
- if use_close_button:
- contents.append(PopoverCloseButton.create())
-
- children = [trigger, PopoverContent.create(*contents)]
-
- return super().create(*children, **props)
-
-
-class PopoverContent(ChakraComponent):
- """The popover itself."""
-
- tag = "PopoverContent"
-
-
-class PopoverHeader(ChakraComponent):
- """The header of the popover."""
-
- tag = "PopoverHeader"
-
-
-class PopoverFooter(ChakraComponent):
- """Display a popover footer."""
-
- tag = "PopoverFooter"
-
-
-class PopoverBody(ChakraComponent):
- """The body of the popover."""
-
- tag = "PopoverBody"
-
-
-class PopoverArrow(ChakraComponent):
- """A visual arrow that points to the reference (or trigger)."""
-
- tag = "PopoverArrow"
-
-
-class PopoverCloseButton(ChakraComponent):
- """A button to close the popover."""
-
- tag = "PopoverCloseButton"
-
-
-class PopoverAnchor(ChakraComponent):
- """Used to wrap the position-reference element."""
-
- tag = "PopoverAnchor"
-
-
-class PopoverTrigger(ChakraComponent):
- """Used to wrap the reference (or trigger) element."""
-
- tag = "PopoverTrigger"
diff --git a/reflex/components/chakra/overlay/popover.pyi b/reflex/components/chakra/overlay/popover.pyi
deleted file mode 100644
index eacf54197..000000000
--- a/reflex/components/chakra/overlay/popover.pyi
+++ /dev/null
@@ -1,757 +0,0 @@
-"""Stub file for reflex/components/chakra/overlay/popover.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import (
- ChakraComponent,
-)
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Popover(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- trigger=None,
- header=None,
- body=None,
- footer=None,
- use_close_button=False,
- arrow_padding: Optional[Union[Var[int], int]] = None,
- arrow_shadow_color: Optional[Union[Var[str], str]] = None,
- arrow_size: Optional[Union[Var[int], int]] = None,
- auto_focus: Optional[Union[Var[bool], bool]] = None,
- boundary: Optional[Union[Var[str], str]] = None,
- close_on_blur: Optional[Union[Var[bool], bool]] = None,
- close_on_esc: Optional[Union[Var[bool], bool]] = None,
- default_is_open: Optional[Union[Var[bool], bool]] = None,
- direction: Optional[
- Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]
- ] = None,
- flip: Optional[Union[Var[bool], bool]] = None,
- gutter: Optional[Union[Var[int], int]] = None,
- id_: Optional[Union[Var[str], str]] = None,
- is_lazy: Optional[Union[Var[bool], bool]] = None,
- lazy_behavior: Optional[Union[Var[str], str]] = None,
- is_open: Optional[Union[Var[bool], bool]] = None,
- match_width: Optional[Union[Var[bool], bool]] = None,
- placement: Optional[Union[Var[str], str]] = None,
- prevent_overflow: Optional[Union[Var[bool], bool]] = None,
- return_focus_on_close: Optional[Union[Var[bool], bool]] = None,
- strategy: Optional[
- Union[Var[Literal["fixed", "absolute"]], Literal["fixed", "absolute"]]
- ] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_open: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Popover":
- """Create a popover component.
-
- Args:
- *children: The children of the component.
- trigger: The trigger that opens the popover.
- header: The header of the popover.
- body: The body of the popover.
- footer: The footer of the popover.
- use_close_button: Whether to add a close button on the popover.
- arrow_padding: The padding required to prevent the arrow from reaching the very edge of the popper.
- arrow_shadow_color: The `box-shadow` of the popover arrow
- arrow_size: The size of the popover arrow
- auto_focus: If true, focus will be transferred to the first interactive element when the popover opens
- boundary: The boundary area for the popper. Used within the preventOverflow modifier
- close_on_blur: If true, the popover will close when you blur out it by clicking outside or tabbing out
- close_on_esc: If true, the popover will close when you hit the Esc key
- default_is_open: If true, the popover will be initially opened.
- direction: Theme direction ltr or rtl. Popper's placement will be set accordingly
- flip: If true, the popper will change its placement and flip when it's about to overflow its boundary area.
- gutter: The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter.
- id_: The html id attribute of the popover. If not provided, we generate a unique id. This id is also used to auto-generate the `aria-labelledby` and `aria-describedby` attributes that points to the PopoverHeader and PopoverBody
- is_lazy: Performance 🚀: If true, the PopoverContent rendering will be deferred until the popover is open.
- lazy_behavior: Performance 🚀: The lazy behavior of popover's content when not visible. Only works when `isLazy={true}` - "unmount": The popover's content is always unmounted when not open. - "keepMounted": The popover's content initially unmounted, but stays mounted when popover is open.
- is_open: If true, the popover will be opened in controlled mode.
- match_width: If true, the popper will match the width of the reference at all times. It's useful for autocomplete, `date-picker` and select patterns.
- placement: The placement of the popover. It's used internally by Popper.js.
- prevent_overflow: If true, will prevent the popper from being cut off and ensure it's visible within the boundary area.
- return_focus_on_close: If true, focus will be returned to the element that triggers the popover when it closes
- strategy: The CSS positioning strategy to use. ("fixed" | "absolute")
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The properties of the component.
-
- Returns:
- The popover component.
- """
- ...
-
-class PopoverContent(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "PopoverContent":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class PopoverHeader(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "PopoverHeader":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class PopoverFooter(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "PopoverFooter":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class PopoverBody(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "PopoverBody":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class PopoverArrow(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "PopoverArrow":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class PopoverCloseButton(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "PopoverCloseButton":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class PopoverAnchor(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "PopoverAnchor":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
-
-class PopoverTrigger(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "PopoverTrigger":
- """Create the component.
-
- Args:
- *children: The children of the component.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/overlay/tooltip.py b/reflex/components/chakra/overlay/tooltip.py
deleted file mode 100644
index e0734251f..000000000
--- a/reflex/components/chakra/overlay/tooltip.py
+++ /dev/null
@@ -1,70 +0,0 @@
-"""Tooltip components."""
-
-from __future__ import annotations
-
-from reflex.components.chakra import ChakraComponent, LiteralChakraDirection
-from reflex.event import EventHandler
-from reflex.vars import Var
-
-
-class Tooltip(ChakraComponent):
- """A tooltip message to appear."""
-
- tag = "Tooltip"
-
- # The padding required to prevent the arrow from reaching the very edge of the popper.
- arrow_padding: Var[int]
-
- # The color of the arrow shadow.
- arrow_shadow_color: Var[str]
-
- # Size of the arrow.
- arrow_size: Var[int]
-
- # Delay (in ms) before hiding the tooltip
- delay: Var[int]
-
- # If true, the tooltip will hide on click
- close_on_click: Var[bool]
-
- # If true, the tooltip will hide on pressing Esc key
- close_on_esc: Var[bool]
-
- # If true, the tooltip will hide while the mouse is down
- close_on_mouse_down: Var[bool]
-
- # If true, the tooltip will be initially shown
- default_is_open: Var[bool]
-
- # Theme direction ltr or rtl. Popper's placement will be set accordingly
- direction: Var[LiteralChakraDirection]
-
- # The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter.
- gutter: Var[int]
-
- # If true, the tooltip will show an arrow tip
- has_arrow: Var[bool]
-
- # If true, the tooltip with be disabled.
- is_disabled: Var[bool]
-
- # If true, the tooltip will be open.
- is_open: Var[bool]
-
- # The label of the tooltip
- label: Var[str]
-
- # Delay (in ms) before showing the tooltip
- open_delay: Var[int]
-
- # The placement of the popper relative to its reference.
- placement: Var[str]
-
- # If true, the tooltip will wrap its children in a ` ` with `tabIndex=0`
- should_wrap_children: Var[bool]
-
- # Fired when the tooltip is closing.
- on_close: EventHandler[lambda: []]
-
- # Fired when the tooltip is opened.
- on_open: EventHandler[lambda: []]
diff --git a/reflex/components/chakra/overlay/tooltip.pyi b/reflex/components/chakra/overlay/tooltip.pyi
deleted file mode 100644
index 76e144d3f..000000000
--- a/reflex/components/chakra/overlay/tooltip.pyi
+++ /dev/null
@@ -1,129 +0,0 @@
-"""Stub file for reflex/components/chakra/overlay/tooltip.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Tooltip(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- arrow_padding: Optional[Union[Var[int], int]] = None,
- arrow_shadow_color: Optional[Union[Var[str], str]] = None,
- arrow_size: Optional[Union[Var[int], int]] = None,
- delay: Optional[Union[Var[int], int]] = None,
- close_on_click: Optional[Union[Var[bool], bool]] = None,
- close_on_esc: Optional[Union[Var[bool], bool]] = None,
- close_on_mouse_down: Optional[Union[Var[bool], bool]] = None,
- default_is_open: Optional[Union[Var[bool], bool]] = None,
- direction: Optional[
- Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]
- ] = None,
- gutter: Optional[Union[Var[int], int]] = None,
- has_arrow: Optional[Union[Var[bool], bool]] = None,
- is_disabled: Optional[Union[Var[bool], bool]] = None,
- is_open: Optional[Union[Var[bool], bool]] = None,
- label: Optional[Union[Var[str], str]] = None,
- open_delay: Optional[Union[Var[int], int]] = None,
- placement: Optional[Union[Var[str], str]] = None,
- should_wrap_children: Optional[Union[Var[bool], bool]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_open: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Tooltip":
- """Create the component.
-
- Args:
- *children: The children of the component.
- arrow_padding: The padding required to prevent the arrow from reaching the very edge of the popper.
- arrow_shadow_color: The color of the arrow shadow.
- arrow_size: Size of the arrow.
- delay: Delay (in ms) before hiding the tooltip
- close_on_click: If true, the tooltip will hide on click
- close_on_esc: If true, the tooltip will hide on pressing Esc key
- close_on_mouse_down: If true, the tooltip will hide while the mouse is down
- default_is_open: If true, the tooltip will be initially shown
- direction: Theme direction ltr or rtl. Popper's placement will be set accordingly
- gutter: The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter.
- has_arrow: If true, the tooltip will show an arrow tip
- is_disabled: If true, the tooltip with be disabled.
- is_open: If true, the tooltip will be open.
- label: The label of the tooltip
- open_delay: Delay (in ms) before showing the tooltip
- placement: The placement of the popper relative to its reference.
- should_wrap_children: If true, the tooltip will wrap its children in a ` ` with `tabIndex=0`
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/typography/__init__.py b/reflex/components/chakra/typography/__init__.py
deleted file mode 100644
index be06b137b..000000000
--- a/reflex/components/chakra/typography/__init__.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""Typography components."""
-
-from reflex.components.component import Component
-
-from .heading import Heading
-from .highlight import Highlight
-from .span import Span
-from .text import Text
-
-__all__ = [f for f in dir() if f[0].isupper() or f in ("span",)] # type: ignore
diff --git a/reflex/components/chakra/typography/heading.py b/reflex/components/chakra/typography/heading.py
deleted file mode 100644
index 29ddd7de2..000000000
--- a/reflex/components/chakra/typography/heading.py
+++ /dev/null
@@ -1,16 +0,0 @@
-"""A heading component."""
-
-from reflex.components.chakra import ChakraComponent, LiteralHeadingSize
-from reflex.vars import Var
-
-
-class Heading(ChakraComponent):
- """A page heading."""
-
- tag = "Heading"
-
- # Override the tag. The default tag is `
`.
- as_: Var[str]
-
- # "4xl" | "3xl" | "2xl" | "xl" | "lg" | "md" | "sm" | "xs"
- size: Var[LiteralHeadingSize]
diff --git a/reflex/components/chakra/typography/heading.pyi b/reflex/components/chakra/typography/heading.pyi
deleted file mode 100644
index 5f4300d9a..000000000
--- a/reflex/components/chakra/typography/heading.pyi
+++ /dev/null
@@ -1,96 +0,0 @@
-"""Stub file for reflex/components/chakra/typography/heading.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Heading(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- as_: Optional[Union[Var[str], str]] = None,
- size: Optional[
- Union[
- Var[Literal["lg", "md", "sm", "xs", "xl", "2xl", "3xl", "4xl"]],
- Literal["lg", "md", "sm", "xs", "xl", "2xl", "3xl", "4xl"],
- ]
- ] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Heading":
- """Create the component.
-
- Args:
- *children: The children of the component.
- as_: Override the tag. The default tag is ``.
- size: "4xl" | "3xl" | "2xl" | "xl" | "lg" | "md" | "sm" | "xs"
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/typography/highlight.py b/reflex/components/chakra/typography/highlight.py
deleted file mode 100644
index 0308c091e..000000000
--- a/reflex/components/chakra/typography/highlight.py
+++ /dev/null
@@ -1,23 +0,0 @@
-"""A highlight component."""
-
-from typing import Dict, List
-
-from reflex.components.chakra import ChakraComponent
-from reflex.components.tags import Tag
-from reflex.vars import Var
-
-
-class Highlight(ChakraComponent):
- """Highlights a specific part of a string."""
-
- tag = "Highlight"
-
- # A query for the text to highlight. Can be a string or a list of strings.
- query: Var[List[str]]
-
- # The style of the content.
- # Note: styles and style are different prop.
- styles: Var[Dict] = {"px": "2", "py": "1", "rounded": "full", "bg": "teal.100"} # type: ignore
-
- def _render(self) -> Tag:
- return super()._render().add_props(styles=self.style)
diff --git a/reflex/components/chakra/typography/highlight.pyi b/reflex/components/chakra/typography/highlight.pyi
deleted file mode 100644
index 8d768cb5e..000000000
--- a/reflex/components/chakra/typography/highlight.pyi
+++ /dev/null
@@ -1,91 +0,0 @@
-"""Stub file for reflex/components/chakra/typography/highlight.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Highlight(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- query: Optional[Union[Var[List[str]], List[str]]] = None,
- styles: Optional[Union[Var[Dict], Dict]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Highlight":
- """Create the component.
-
- Args:
- *children: The children of the component.
- query: A query for the text to highlight. Can be a string or a list of strings.
- styles: The style of the content. Note: styles and style are different prop.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/typography/span.py b/reflex/components/chakra/typography/span.py
deleted file mode 100644
index 247be1447..000000000
--- a/reflex/components/chakra/typography/span.py
+++ /dev/null
@@ -1,15 +0,0 @@
-"""A span component."""
-
-from __future__ import annotations
-
-from reflex.components.chakra import ChakraComponent
-from reflex.vars import Var
-
-
-class Span(ChakraComponent):
- """Render an inline span of text."""
-
- tag = "Text"
-
- # Override the tag. The default tag is ``.
- as_: Var[str] = "span" # type: ignore
diff --git a/reflex/components/chakra/typography/span.pyi b/reflex/components/chakra/typography/span.pyi
deleted file mode 100644
index 1e9d065ad..000000000
--- a/reflex/components/chakra/typography/span.pyi
+++ /dev/null
@@ -1,89 +0,0 @@
-"""Stub file for reflex/components/chakra/typography/span.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Span(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- as_: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Span":
- """Create the component.
-
- Args:
- *children: The children of the component.
- as_: Override the tag. The default tag is ``.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/chakra/typography/text.py b/reflex/components/chakra/typography/text.py
deleted file mode 100644
index b2cd2356f..000000000
--- a/reflex/components/chakra/typography/text.py
+++ /dev/null
@@ -1,18 +0,0 @@
-"""A text component."""
-
-from __future__ import annotations
-
-from reflex.components.chakra import ChakraComponent
-from reflex.vars import Var
-
-
-class Text(ChakraComponent):
- """Render a paragraph of text."""
-
- tag = "Text"
-
- # Override the tag. The default tag is ``.
- as_: Var[str]
-
- # Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop.
- no_of_lines: Var[int]
diff --git a/reflex/components/chakra/typography/text.pyi b/reflex/components/chakra/typography/text.pyi
deleted file mode 100644
index f707bae36..000000000
--- a/reflex/components/chakra/typography/text.pyi
+++ /dev/null
@@ -1,91 +0,0 @@
-"""Stub file for reflex/components/chakra/typography/text.py"""
-
-# ------------------- DO NOT EDIT ----------------------
-# This file was generated by `reflex/utils/pyi_generator.py`!
-# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
-
-from reflex.components.chakra import ChakraComponent
-from reflex.event import EventHandler, EventSpec
-from reflex.style import Style
-from reflex.vars import BaseVar, Var
-
-class Text(ChakraComponent):
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- as_: Optional[Union[Var[str], str]] = None,
- no_of_lines: Optional[Union[Var[int], int]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "Text":
- """Create the component.
-
- Args:
- *children: The children of the component.
- as_: Override the tag. The default tag is `
`.
- no_of_lines: Truncate text after a specific number of lines. It will render an ellipsis when the text exceeds the width of the viewport or max_width prop.
- style: The style of the component.
- key: A unique key for the component.
- id: The id for the component.
- class_name: The class name for the component.
- autofocus: Whether the component should take the focus once the page is loaded
- custom_attrs: custom attribute
- **props: The props of the component.
-
- Returns:
- The component.
- """
- ...
diff --git a/reflex/components/component.py b/reflex/components/component.py
index bb3e9053f..34800ab6e 100644
--- a/reflex/components/component.py
+++ b/reflex/components/component.py
@@ -3,6 +3,7 @@
from __future__ import annotations
import copy
+import dataclasses
import typing
from abc import ABC, abstractmethod
from functools import lru_cache, wraps
@@ -16,6 +17,7 @@ from typing import (
Iterator,
List,
Optional,
+ Sequence,
Set,
Type,
Union,
@@ -25,6 +27,7 @@ import reflex.state
from reflex.base import Base
from reflex.compiler.templates import STATEFUL_COMPONENT
from reflex.components.core.breakpoints import Breakpoints
+from reflex.components.dynamic import load_dynamic_serializer
from reflex.components.tags import Tag
from reflex.constants import (
Dirs,
@@ -35,19 +38,40 @@ from reflex.constants import (
MemoizationMode,
PageNames,
)
+from reflex.constants.compiler import SpecialAttributes
+from reflex.constants.state import FRONTEND_EVENT_STATE
from reflex.event import (
+ EventCallback,
EventChain,
+ EventChainVar,
EventHandler,
EventSpec,
+ EventVar,
call_event_fn,
call_event_handler,
get_handler_args,
+ no_args_event_spec,
)
from reflex.style import Style, format_as_emotion
-from reflex.utils import console, format, imports, types
-from reflex.utils.imports import ImportDict, ImportVar, ParsedImportDict, parse_imports
-from reflex.utils.serializers import serializer
-from reflex.vars import BaseVar, Var, VarData
+from reflex.utils import format, imports, types
+from reflex.utils.imports import (
+ ImmutableParsedImportDict,
+ ImportDict,
+ ImportVar,
+ ParsedImportDict,
+ parse_imports,
+)
+from reflex.vars import VarData
+from reflex.vars.base import (
+ CachedVarOperation,
+ LiteralVar,
+ Var,
+ cached_property_no_lock,
+)
+from reflex.vars.function import ArgsFunctionOperation, FunctionStringVar
+from reflex.vars.number import ternary_operation
+from reflex.vars.object import ObjectVar
+from reflex.vars.sequence import LiteralArrayVar
class BaseComponent(Base, ABC):
@@ -134,11 +158,10 @@ class ComponentNamespace(SimpleNamespace):
def __hash__(self) -> int:
"""Get the hash of the namespace.
-
Returns:
The hash of the namespace.
"""
- return hash(self.__class__.__name__)
+ return hash(type(self).__name__)
def evaluate_style_namespaces(style: ComponentStyle) -> dict:
@@ -163,6 +186,23 @@ ComponentStyle = Dict[
ComponentChild = Union[types.PrimitiveType, Var, BaseComponent]
+def satisfies_type_hint(obj: Any, type_hint: Any) -> bool:
+ """Check if an object satisfies a type hint.
+
+ Args:
+ obj: The object to check.
+ type_hint: The type hint to check against.
+
+ Returns:
+ Whether the object satisfies the type hint.
+ """
+ if isinstance(obj, LiteralVar):
+ return types._isinstance(obj._var_value, type_hint)
+ if isinstance(obj, Var):
+ return types._issubclass(obj._var_type, type_hint)
+ return types._isinstance(obj, type_hint)
+
+
class Component(BaseComponent, ABC):
"""A component with style, event trigger and other props."""
@@ -188,7 +228,7 @@ class Component(BaseComponent, ABC):
class_name: Any = None
# Special component props.
- special_props: Set[Var] = set()
+ special_props: List[Var] = []
# Whether the component should take the focus once the page is loaded
autofocus: bool = False
@@ -206,7 +246,7 @@ class Component(BaseComponent, ABC):
_rename_props: Dict[str, str] = {}
# custom attribute
- custom_attrs: Dict[str, Union[Var, str]] = {}
+ custom_attrs: Dict[str, Union[Var, Any]] = {}
# When to memoize this component and its children.
_memoization_mode: MemoizationMode = MemoizationMode()
@@ -320,9 +360,8 @@ class Component(BaseComponent, ABC):
# Set default values for any props.
if types._issubclass(field.type_, Var):
field.required = False
- field.default = Var.create(
- field.default, _var_is_string=isinstance(field.default, str)
- )
+ if field.default is not None:
+ field.default = LiteralVar.create(field.default)
elif types._issubclass(field.type_, EventHandler):
field.required = False
@@ -351,10 +390,7 @@ class Component(BaseComponent, ABC):
"id": kwargs.get("id"),
"children": children,
**{
- prop: Var.create(
- kwargs[prop],
- _var_is_string=False if isinstance(kwargs[prop], str) else None,
- )
+ prop: LiteralVar.create(kwargs[prop])
for prop in self.get_initial_props()
if prop in kwargs
},
@@ -401,10 +437,10 @@ class Component(BaseComponent, ABC):
passed_types = None
try:
# Try to create a var from the value.
- kwargs[key] = Var.create(
- value,
- _var_is_string=False if isinstance(value, str) else None,
- )
+ if isinstance(value, Var):
+ kwargs[key] = value
+ else:
+ kwargs[key] = LiteralVar.create(value)
# Check that the var type is not None.
if kwargs[key] is None:
@@ -441,33 +477,51 @@ class Component(BaseComponent, ABC):
)
) or (
# Else just check if the passed var type is valid.
- not passed_types
- and not types._issubclass(passed_type, expected_type, value)
+ not passed_types and not satisfies_type_hint(value, expected_type)
):
- value_name = value._var_name if isinstance(value, Var) else value
- raise TypeError(
- f"Invalid var passed for prop {type(self).__name__}.{key}, expected type {expected_type}, got value {value_name} of type {passed_types or passed_type}."
+ value_name = value._js_expr if isinstance(value, Var) else value
+
+ additional_info = (
+ " You can call `.bool()` on the value to convert it to a boolean."
+ if expected_type is bool and isinstance(value, Var)
+ else ""
)
+ raise TypeError(
+ f"Invalid var passed for prop {type(self).__name__}.{key}, expected type {expected_type}, got value {value_name} of type {passed_type}."
+ + additional_info
+ )
# Check if the key is an event trigger.
if key in component_specific_triggers:
# Temporarily disable full control for event triggers.
kwargs["event_triggers"][key] = self._create_event_chain(
value=value, # type: ignore
args_spec=component_specific_triggers[key],
+ key=key,
)
# Remove any keys that were added as events.
for key in kwargs["event_triggers"]:
del kwargs[key]
+ # Place data_ and aria_ attributes into custom_attrs
+ special_attributes = tuple(
+ key
+ for key in kwargs
+ if key not in fields and SpecialAttributes.is_special(key)
+ )
+ if special_attributes:
+ custom_attrs = kwargs.setdefault("custom_attrs", {})
+ for key in special_attributes:
+ custom_attrs[format.to_kebab_case(key)] = kwargs.pop(key)
+
# Add style props to the component.
style = kwargs.get("style", {})
if isinstance(style, List):
# Merge styles, the later ones overriding keys in the earlier ones.
style = {k: v for style_dict in style for k, v in style_dict.items()}
- if isinstance(style, Breakpoints):
+ if isinstance(style, (Breakpoints, Var)):
style = {
# Assign the Breakpoints to the self-referential selector to avoid squashing down to a regular dict.
"&": style,
@@ -480,29 +534,38 @@ class Component(BaseComponent, ABC):
**{attr: value for attr, value in kwargs.items() if attr not in fields},
}
)
- if "custom_attrs" not in kwargs:
- kwargs["custom_attrs"] = {}
# Convert class_name to str if it's list
class_name = kwargs.get("class_name", "")
if isinstance(class_name, (List, tuple)):
- kwargs["class_name"] = " ".join(class_name)
+ if any(isinstance(c, Var) for c in class_name):
+ kwargs["class_name"] = LiteralArrayVar.create(
+ class_name, _var_type=List[str]
+ ).join(" ")
+ else:
+ kwargs["class_name"] = " ".join(class_name)
# Construct the component.
super().__init__(*args, **kwargs)
def _create_event_chain(
self,
- args_spec: Any,
+ args_spec: types.ArgsSpec | Sequence[types.ArgsSpec],
value: Union[
- Var, EventHandler, EventSpec, List[Union[EventHandler, EventSpec]], Callable
+ Var,
+ EventHandler,
+ EventSpec,
+ List[Union[EventHandler, EventSpec, EventVar]],
+ Callable,
],
+ key: Optional[str] = None,
) -> Union[EventChain, Var]:
"""Create an event chain from a variety of input types.
Args:
args_spec: The args_spec of the event trigger being bound.
value: The value to create the event chain from.
+ key: The key of the event trigger being bound.
Returns:
The event chain.
@@ -512,9 +575,16 @@ class Component(BaseComponent, ABC):
"""
# If it's an event chain var, return it.
if isinstance(value, Var):
- if value._var_type is not EventChain:
- raise ValueError(f"Invalid event chain: {value}")
- return value
+ if isinstance(value, EventChainVar):
+ return value
+ elif isinstance(value, EventVar):
+ value = [value]
+ elif issubclass(value._var_type, (EventChain, EventSpec)):
+ return self._create_event_chain(args_spec, value.guess_type(), key=key)
+ else:
+ raise ValueError(
+ f"Invalid event chain: {value!s} of type {value._var_type}"
+ )
elif isinstance(value, EventChain):
# Trust that the caller knows what they're doing passing an EventChain directly
return value
@@ -525,99 +595,92 @@ class Component(BaseComponent, ABC):
# If the input is a list of event handlers, create an event chain.
if isinstance(value, List):
- events: list[EventSpec] = []
+ events: List[Union[EventSpec, EventVar]] = []
for v in value:
if isinstance(v, (EventHandler, EventSpec)):
# Call the event handler to get the event.
- try:
- event = call_event_handler(v, args_spec)
- except ValueError as err:
- raise ValueError(
- f" {err} defined in the `{type(self).__name__}` component"
- ) from err
-
- # Add the event to the chain.
- events.append(event)
+ events.append(call_event_handler(v, args_spec, key=key))
elif isinstance(v, Callable):
# Call the lambda to get the event chain.
- result = call_event_fn(v, args_spec)
+ result = call_event_fn(v, args_spec, key=key)
if isinstance(result, Var):
raise ValueError(
f"Invalid event chain: {v}. Cannot use a Var-returning "
"lambda inside an EventChain list."
)
events.extend(result)
+ elif isinstance(v, EventVar):
+ events.append(v)
else:
raise ValueError(f"Invalid event: {v}")
# If the input is a callable, create an event chain.
elif isinstance(value, Callable):
- result = call_event_fn(value, args_spec)
+ result = call_event_fn(value, args_spec, key=key)
if isinstance(result, Var):
# Recursively call this function if the lambda returned an EventChain Var.
- return self._create_event_chain(args_spec, result)
- events = result
+ return self._create_event_chain(args_spec, result, key=key)
+ events = [*result]
# Otherwise, raise an error.
else:
raise ValueError(f"Invalid event chain: {value}")
# Add args to the event specs if necessary.
- events = [e.with_args(get_handler_args(e)) for e in events]
-
- # Collect event_actions from each spec
- event_actions = {}
- for e in events:
- event_actions.update(e.event_actions)
+ events = [
+ (e.with_args(get_handler_args(e)) if isinstance(e, EventSpec) else e)
+ for e in events
+ ]
# Return the event chain.
if isinstance(args_spec, Var):
return EventChain(
events=events,
args_spec=None,
- event_actions=event_actions,
+ event_actions={},
)
else:
return EventChain(
events=events,
args_spec=args_spec,
- event_actions=event_actions,
+ event_actions={},
)
- def get_event_triggers(self) -> Dict[str, Any]:
+ def get_event_triggers(
+ self,
+ ) -> Dict[str, types.ArgsSpec | Sequence[types.ArgsSpec]]:
"""Get the event triggers for the component.
Returns:
The event triggers.
-
"""
- default_triggers = {
- EventTriggers.ON_FOCUS: lambda: [],
- EventTriggers.ON_BLUR: lambda: [],
- EventTriggers.ON_CLICK: lambda: [],
- EventTriggers.ON_CONTEXT_MENU: lambda: [],
- EventTriggers.ON_DOUBLE_CLICK: lambda: [],
- EventTriggers.ON_MOUSE_DOWN: lambda: [],
- EventTriggers.ON_MOUSE_ENTER: lambda: [],
- EventTriggers.ON_MOUSE_LEAVE: lambda: [],
- EventTriggers.ON_MOUSE_MOVE: lambda: [],
- EventTriggers.ON_MOUSE_OUT: lambda: [],
- EventTriggers.ON_MOUSE_OVER: lambda: [],
- EventTriggers.ON_MOUSE_UP: lambda: [],
- EventTriggers.ON_SCROLL: lambda: [],
- EventTriggers.ON_MOUNT: lambda: [],
- EventTriggers.ON_UNMOUNT: lambda: [],
+ default_triggers: Dict[str, types.ArgsSpec | Sequence[types.ArgsSpec]] = {
+ EventTriggers.ON_FOCUS: no_args_event_spec,
+ EventTriggers.ON_BLUR: no_args_event_spec,
+ EventTriggers.ON_CLICK: no_args_event_spec,
+ EventTriggers.ON_CONTEXT_MENU: no_args_event_spec,
+ EventTriggers.ON_DOUBLE_CLICK: no_args_event_spec,
+ EventTriggers.ON_MOUSE_DOWN: no_args_event_spec,
+ EventTriggers.ON_MOUSE_ENTER: no_args_event_spec,
+ EventTriggers.ON_MOUSE_LEAVE: no_args_event_spec,
+ EventTriggers.ON_MOUSE_MOVE: no_args_event_spec,
+ EventTriggers.ON_MOUSE_OUT: no_args_event_spec,
+ EventTriggers.ON_MOUSE_OVER: no_args_event_spec,
+ EventTriggers.ON_MOUSE_UP: no_args_event_spec,
+ EventTriggers.ON_SCROLL: no_args_event_spec,
+ EventTriggers.ON_MOUNT: no_args_event_spec,
+ EventTriggers.ON_UNMOUNT: no_args_event_spec,
}
# Look for component specific triggers,
# e.g. variable declared as EventHandler types.
for field in self.get_fields().values():
- if types._issubclass(field.type_, EventHandler):
+ if types._issubclass(field.outer_type_, EventHandler):
args_spec = None
annotation = field.annotation
- if hasattr(annotation, "__metadata__"):
- args_spec = annotation.__metadata__[0]
- default_triggers[field.name] = args_spec or (lambda: [])
+ if (metadata := getattr(annotation, "__metadata__", None)) is not None:
+ args_spec = metadata[0]
+ default_triggers[field.name] = args_spec or (no_args_event_spec) # type: ignore
return default_triggers
def __repr__(self) -> str:
@@ -638,27 +701,6 @@ class Component(BaseComponent, ABC):
return _compile_component(self)
- def _apply_theme(self, theme: Optional[Component]):
- """Apply the theme to this component.
-
- Deprecated. Use add_style instead.
-
- Args:
- theme: The theme to apply.
- """
- pass
-
- def apply_theme(self, theme: Optional[Component]):
- """Apply a theme to the component and its children.
-
- Args:
- theme: The theme to apply.
- """
- self._apply_theme(theme)
- for child in self.children:
- if isinstance(child, Component):
- child.apply_theme(theme)
-
def _exclude_props(self) -> list[str]:
"""Props to exclude when adding the component props to the Tag.
@@ -678,7 +720,7 @@ class Component(BaseComponent, ABC):
"""
# Create the base tag.
tag = Tag(
- name=self.tag if not self.alias else self.alias,
+ name=(self.tag if not self.alias else self.alias) or "",
special_props=self.special_props,
)
@@ -692,9 +734,7 @@ class Component(BaseComponent, ABC):
# Add ref to element if `id` is not None.
ref = self.get_ref()
if ref is not None:
- props["ref"] = Var.create(
- ref, _var_is_local=False, _var_is_string=False
- )
+ props["ref"] = Var(_js_expr=ref)
else:
props = props.copy()
@@ -768,22 +808,6 @@ class Component(BaseComponent, ABC):
from reflex.components.base.fragment import Fragment
from reflex.utils.exceptions import ComponentTypeError
- # Translate deprecated props to new names.
- new_prop_names = [
- prop for prop in cls.get_props() if prop in ["type", "min", "max"]
- ]
- for prop in new_prop_names:
- under_prop = f"{prop}_"
- if under_prop in props:
- console.deprecate(
- f"Underscore suffix for prop `{under_prop}`",
- reason=f"for consistency. Use `{prop}` instead.",
- deprecation_version="0.4.0",
- removal_version="0.6.0",
- dedupe=False,
- )
- props[prop] = props.pop(under_prop)
-
# Filter out None props
props = {key: value for key, value in props.items() if value is not None}
@@ -809,7 +833,7 @@ class Component(BaseComponent, ABC):
else (
Fragment.create(*child)
if isinstance(child, tuple)
- else Bare.create(contents=Var.create(child, _var_is_string=True))
+ else Bare.create(contents=LiteralVar.create(child))
)
)
for child in children
@@ -900,17 +924,6 @@ class Component(BaseComponent, ABC):
new_style.update(component_style)
style_vars.append(component_style._var_data)
- # 3. User-defined style from `Component.style`.
- # Apply theme for retro-compatibility with deprecated _apply_theme API
- if type(self)._apply_theme != Component._apply_theme:
- console.deprecate(
- f"{self.__class__.__name__}._apply_theme",
- reason="use add_style instead",
- deprecation_version="0.5.0",
- removal_version="0.6.0",
- )
- self._apply_theme(theme)
-
# 4. style dict and css props passed to the component instance.
new_style.update(self.style)
style_vars.append(self.style._var_data)
@@ -936,7 +949,12 @@ class Component(BaseComponent, ABC):
"""
if isinstance(self.style, Var):
return {"css": self.style}
- return {"css": Var.create(format_as_emotion(self.style))}
+ emotion_style = format_as_emotion(self.style)
+ return (
+ {"css": LiteralVar.create(emotion_style)}
+ if emotion_style is not None
+ else {}
+ )
def render(self) -> Dict:
"""Render the component.
@@ -1061,8 +1079,11 @@ class Component(BaseComponent, ABC):
elif isinstance(event, EventChain):
event_args = []
for spec in event.events:
- for args in spec.args:
- event_args.extend(args)
+ if isinstance(spec, EventSpec):
+ for args in spec.args:
+ event_args.extend(args)
+ else:
+ event_args.append(spec)
yield event_trigger, event_args
def _get_vars(self, include_children: bool = False) -> list[Var]:
@@ -1089,12 +1110,12 @@ class Component(BaseComponent, ABC):
vars.append(prop_var)
# Style keeps track of its own VarData instance, so embed in a temp Var that is yielded.
- if isinstance(self.style, dict) and self.style or isinstance(self.style, Var):
+ if (isinstance(self.style, dict) and self.style) or isinstance(self.style, Var):
vars.append(
- BaseVar(
- _var_name="style",
+ Var(
+ _js_expr="style",
_var_type=str,
- _var_data=self.style._var_data,
+ _var_data=VarData.merge(self.style._var_data),
)
)
@@ -1113,10 +1134,8 @@ class Component(BaseComponent, ABC):
vars.append(comp_prop)
elif isinstance(comp_prop, str):
# Collapse VarData encoded in f-strings.
- var = Var.create_safe(
- comp_prop, _var_is_string=isinstance(comp_prop, str)
- )
- if var._var_data is not None:
+ var = LiteralVar.create(comp_prop)
+ if var._get_all_var_data() is not None:
vars.append(var)
# Get Vars associated with children.
@@ -1124,7 +1143,8 @@ class Component(BaseComponent, ABC):
for child in self.children:
if not isinstance(child, Component):
continue
- vars.extend(child._get_vars(include_children=include_children))
+ child_vars = child._get_vars(include_children=include_children)
+ vars.extend(child_vars)
return vars
@@ -1137,8 +1157,17 @@ class Component(BaseComponent, ABC):
for trigger in self.event_triggers.values():
if isinstance(trigger, EventChain):
for event in trigger.events:
- if event.handler.state_full_name:
- return True
+ if isinstance(event, EventCallback):
+ continue
+ if isinstance(event, EventSpec):
+ if (
+ event.handler.state_full_name
+ and event.handler.state_full_name != FRONTEND_EVENT_STATE
+ ):
+ return True
+ else:
+ if event._var_state:
+ return True
elif isinstance(trigger, Var) and trigger._var_state:
return True
return False
@@ -1179,7 +1208,7 @@ class Component(BaseComponent, ABC):
Yields:
The parent classes that define the method (differently than the base).
"""
- seen_methods = set([getattr(Component, method)])
+ seen_methods = {getattr(Component, method)}
for clz in cls.mro():
if clz is Component:
break
@@ -1312,7 +1341,9 @@ class Component(BaseComponent, ABC):
if self._get_ref_hook():
# Handle hooks needed for attaching react refs to DOM nodes.
_imports.setdefault("react", set()).add(ImportVar(tag="useRef"))
- _imports.setdefault(f"/{Dirs.STATE_PATH}", set()).add(ImportVar(tag="refs"))
+ _imports.setdefault(f"$/{Dirs.STATE_PATH}", set()).add(
+ ImportVar(tag="refs")
+ )
if self._get_mount_lifecycle_hook():
# Handle hooks for `on_mount` / `on_unmount`.
@@ -1329,15 +1360,17 @@ class Component(BaseComponent, ABC):
other_imports = []
user_hooks = self._get_hooks()
- if (
- user_hooks is not None
- and isinstance(user_hooks, Var)
- and user_hooks._var_data is not None
- and user_hooks._var_data.imports
- ):
- other_imports.append(user_hooks._var_data.imports)
+ user_hooks_data = (
+ VarData.merge(user_hooks._get_all_var_data())
+ if user_hooks is not None and isinstance(user_hooks, Var)
+ else None
+ )
+ if user_hooks_data is not None:
+ other_imports.append(user_hooks_data.imports)
other_imports.extend(
- hook_imports for hook_imports in self._get_added_hooks().values()
+ hook_vardata.imports
+ for hook_vardata in self._get_added_hooks().values()
+ if hook_vardata is not None
)
return imports.merge_imports(_imports, *other_imports)
@@ -1358,8 +1391,9 @@ class Component(BaseComponent, ABC):
event_imports = Imports.EVENTS if self.event_triggers else {}
# Collect imports from Vars used directly by this component.
- var_imports = [
- var._var_data.imports for var in self._get_vars() if var._var_data
+ var_datas = [var._get_all_var_data() for var in self._get_vars()]
+ var_imports: List[ImmutableParsedImportDict] = [
+ var_data.imports for var_data in var_datas if var_data is not None
]
added_import_dicts: list[ParsedImportDict] = []
@@ -1369,8 +1403,9 @@ class Component(BaseComponent, ABC):
if not isinstance(list_of_import_dict, list):
list_of_import_dict = [list_of_import_dict]
- for import_dict in list_of_import_dict:
- added_import_dicts.append(parse_imports(import_dict))
+ added_import_dicts.extend(
+ [parse_imports(import_dict) for import_dict in list_of_import_dict]
+ )
return imports.merge_imports(
*self._get_props_imports(),
@@ -1407,9 +1442,9 @@ class Component(BaseComponent, ABC):
on_mount = self.event_triggers.get(EventTriggers.ON_MOUNT, None)
on_unmount = self.event_triggers.get(EventTriggers.ON_UNMOUNT, None)
if on_mount is not None:
- on_mount = format.format_event_chain(on_mount)
+ on_mount = str(LiteralVar.create(on_mount)) + "()"
if on_unmount is not None:
- on_unmount = format.format_event_chain(on_unmount)
+ on_unmount = str(LiteralVar.create(on_unmount)) + "()"
if on_mount is not None or on_unmount is not None:
return f"""
useEffect(() => {{
@@ -1427,7 +1462,9 @@ class Component(BaseComponent, ABC):
"""
ref = self.get_ref()
if ref is not None:
- return f"const {ref} = useRef(null); {str(Var.create_safe(ref, _var_is_string=False).as_ref())} = {ref};"
+ return (
+ f"const {ref} = useRef(null); {Var(_js_expr=ref)._as_ref()!s} = {ref};"
+ )
def _get_vars_hooks(self) -> dict[str, None]:
"""Get the hooks required by vars referenced in this component.
@@ -1437,8 +1474,13 @@ class Component(BaseComponent, ABC):
"""
vars_hooks = {}
for var in self._get_vars():
- if var._var_data:
- vars_hooks.update(var._var_data.hooks)
+ var_data = var._get_all_var_data()
+ if var_data is not None:
+ vars_hooks.update(
+ var_data.hooks
+ if isinstance(var_data.hooks, dict)
+ else {k: None for k in var_data.hooks}
+ )
return vars_hooks
def _get_events_hooks(self) -> dict[str, None]:
@@ -1477,7 +1519,7 @@ class Component(BaseComponent, ABC):
**self._get_special_hooks(),
}
- def _get_added_hooks(self) -> dict[str, ImportDict]:
+ def _get_added_hooks(self) -> dict[str, VarData | None]:
"""Get the hooks added via `add_hooks` method.
Returns:
@@ -1486,16 +1528,15 @@ class Component(BaseComponent, ABC):
code = {}
def extract_var_hooks(hook: Var):
- _imports = {}
- if hook._var_data is not None:
- for sub_hook in hook._var_data.hooks:
- code[sub_hook] = {}
- if hook._var_data.imports:
- _imports = hook._var_data.imports
+ var_data = VarData.merge(hook._get_all_var_data())
+ if var_data is not None:
+ for sub_hook in var_data.hooks:
+ code[sub_hook] = None
+
if str(hook) in code:
- code[str(hook)] = imports.merge_imports(code[str(hook)], _imports)
+ code[str(hook)] = VarData.merge(var_data, code[str(hook)])
else:
- code[str(hook)] = _imports
+ code[str(hook)] = var_data
# Add the hook code from add_hooks for each parent class (this is reversed to preserve
# the order of the hooks in the final output)
@@ -1504,7 +1545,8 @@ class Component(BaseComponent, ABC):
if isinstance(hook, Var):
extract_var_hooks(hook)
else:
- code[hook] = {}
+ code[hook] = None
+
return code
def _get_hooks(self) -> str | None:
@@ -1545,8 +1587,7 @@ class Component(BaseComponent, ABC):
if hooks is not None:
code[hooks] = None
- for hook in self._get_added_hooks():
- code[hook] = None
+ code.update(self._get_added_hooks())
# Add the hook code for the children.
for child in self.children:
@@ -1561,7 +1602,7 @@ class Component(BaseComponent, ABC):
The ref name.
"""
# do not create a ref if the id is dynamic or unspecified
- if self.id is None or isinstance(self.id, BaseVar):
+ if self.id is None or isinstance(self.id, Var):
return None
return format.format_ref(self.id)
@@ -1655,7 +1696,7 @@ class CustomComponent(Component):
"""A custom user-defined component."""
# Use the components library.
- library = f"/{Dirs.COMPONENTS_PATH}"
+ library = f"$/{Dirs.COMPONENTS_PATH}"
# The function that creates the component.
component_fn: Callable[..., Component] = Component.create
@@ -1699,15 +1740,16 @@ class CustomComponent(Component):
value = self._create_event_chain(
value=value,
args_spec=event_triggers_in_component_declaration.get(
- key, lambda: []
+ key, no_args_event_spec
),
+ key=key,
)
self.props[format.to_camel_case(key)] = value
continue
# Handle subclasses of Base.
if isinstance(value, Base):
- base_value = Var.create(value)
+ base_value = LiteralVar.create(value)
# Track hooks and imports associated with Component instances.
if base_value is not None and isinstance(value, Component):
@@ -1721,7 +1763,7 @@ class CustomComponent(Component):
else:
value = base_value
else:
- value = Var.create(value, _var_is_string=isinstance(value, str))
+ value = LiteralVar.create(value)
# Set the prop.
self.props[format.to_camel_case(key)] = value
@@ -1762,10 +1804,14 @@ class CustomComponent(Component):
Args:
seen: The tags of the components that have already been seen.
+ Raises:
+ ValueError: If the tag is not set.
+
Returns:
The set of custom components.
"""
- assert self.tag is not None, "The tag must be set."
+ if self.tag is None:
+ raise ValueError("The tag must be set.")
# Store the seen components in a set to avoid infinite recursion.
if seen is None:
@@ -1800,19 +1846,19 @@ class CustomComponent(Component):
"""
return super()._render(props=self.props)
- def get_prop_vars(self) -> List[BaseVar]:
+ def get_prop_vars(self) -> List[Var]:
"""Get the prop vars.
Returns:
The prop vars.
"""
return [
- BaseVar(
- _var_name=name,
+ Var(
+ _js_expr=name,
_var_type=(
prop._var_type if types._isinstance(prop, Var) else type(prop)
),
- )
+ ).guess_type()
for name, prop in self.props.items()
]
@@ -1825,9 +1871,11 @@ class CustomComponent(Component):
Returns:
Each var referenced by the component (props, styles, event handlers).
"""
- return super()._get_vars(include_children=include_children) + [
- prop for prop in self.props.values() if isinstance(prop, Var)
- ]
+ return (
+ super()._get_vars(include_children=include_children)
+ + [prop for prop in self.props.values() if isinstance(prop, Var)]
+ + self.get_component(self)._get_vars(include_children=include_children)
+ )
@lru_cache(maxsize=None) # noqa
def get_component(self) -> Component:
@@ -1867,6 +1915,11 @@ memo = custom_component
class NoSSRComponent(Component):
"""A dynamic component that is not rendered on the server."""
+ def _get_import_name(self) -> None | str:
+ if not self.library:
+ return None
+ return f"${self.library}" if self.library.startswith("/") else self.library
+
def _get_imports(self) -> ParsedImportDict:
"""Get the imports for the component.
@@ -1880,8 +1933,9 @@ class NoSSRComponent(Component):
_imports = super()._get_imports()
# Do NOT import the main library/tag statically.
- if self.library is not None:
- _imports[self.library] = [
+ import_name = self._get_import_name()
+ if import_name is not None:
+ _imports[import_name] = [
imports.ImportVar(
tag=None,
render=False,
@@ -1899,10 +1953,10 @@ class NoSSRComponent(Component):
opts_fragment = ", { ssr: false });"
# extract the correct import name from library name
- if self.library is None:
+ base_import_name = self._get_import_name()
+ if base_import_name is None:
raise ValueError("Undefined library for NoSSRComponent")
-
- import_name = format.format_library_name(self.library)
+ import_name = format.format_library_name(base_import_name)
library_import = f"const {self.alias if self.alias else self.tag} = dynamic(() => import('{import_name}')"
mod_import = (
@@ -1912,19 +1966,6 @@ class NoSSRComponent(Component):
return "".join((library_import, mod_import, opts_fragment))
-@serializer
-def serialize_component(comp: Component):
- """Serialize a component.
-
- Args:
- comp: The component to serialize.
-
- Returns:
- The serialized component.
- """
- return str(comp)
-
-
class StatefulComponent(BaseComponent):
"""A component that depends on state and is rendered outside of the page component.
@@ -1981,7 +2022,7 @@ class StatefulComponent(BaseComponent):
if not should_memoize:
# Determine if any Vars have associated data.
for prop_var in component._get_vars():
- if prop_var._var_data:
+ if prop_var._get_all_var_data():
should_memoize = True
break
@@ -1996,7 +2037,7 @@ class StatefulComponent(BaseComponent):
should_memoize = True
break
child = cls._child_var(child)
- if isinstance(child, Var) and child._var_data:
+ if isinstance(child, Var) and child._get_all_var_data():
should_memoize = True
break
@@ -2148,6 +2189,31 @@ class StatefulComponent(BaseComponent):
]
return [var_name]
+ @staticmethod
+ def _get_deps_from_event_trigger(event: EventChain | EventSpec | Var) -> set[str]:
+ """Get the dependencies accessed by event triggers.
+
+ Args:
+ event: The event trigger to extract deps from.
+
+ Returns:
+ The dependencies accessed by the event triggers.
+ """
+ events: list = [event]
+ deps = set()
+
+ if isinstance(event, EventChain):
+ events.extend(event.events)
+
+ for ev in events:
+ if isinstance(ev, EventSpec):
+ for arg in ev.args:
+ for a in arg:
+ var_datas = VarData.merge(a._get_all_var_data())
+ if var_datas and var_datas.deps is not None:
+ deps |= {str(dep) for dep in var_datas.deps}
+ return deps
+
@classmethod
def _get_memoized_event_triggers(
cls,
@@ -2176,9 +2242,7 @@ class StatefulComponent(BaseComponent):
# Get the actual EventSpec and render it.
event = component.event_triggers[event_trigger]
- rendered_chain = format.format_prop(event)
- if isinstance(rendered_chain, str):
- rendered_chain = rendered_chain.strip("{}")
+ rendered_chain = str(LiteralVar.create(event))
# Hash the rendered EventChain to get a deterministic function name.
chain_hash = md5(str(rendered_chain).encode("utf-8")).hexdigest()
@@ -2186,13 +2250,19 @@ class StatefulComponent(BaseComponent):
# Calculate Var dependencies accessed by the handler for useCallback dep array.
var_deps = ["addEvents", "Event"]
+
+ # Get deps from event trigger var data.
+ var_deps.extend(cls._get_deps_from_event_trigger(event))
+
+ # Get deps from hooks.
for arg in event_args:
- if arg._var_data is None:
+ var_data = arg._get_all_var_data()
+ if var_data is None:
continue
- for hook in arg._var_data.hooks:
+ for hook in var_data.hooks:
var_deps.extend(cls._get_hook_deps(hook))
memo_var_data = VarData.merge(
- *[var._var_data for var in event_args],
+ *[var._get_all_var_data() for var in event_args],
VarData(
imports={"react": [ImportVar(tag="useCallback")]},
),
@@ -2200,7 +2270,7 @@ class StatefulComponent(BaseComponent):
# Store the memoized function name and hook code for this event trigger.
trigger_memo[event_trigger] = (
- Var.create_safe(memo_name, _var_is_string=False)._replace(
+ Var(_js_expr=memo_name)._replace(
_var_type=EventChain, merge_var_data=memo_var_data
),
f"const {memo_name} = useCallback({rendered_chain}, [{', '.join(var_deps)}])",
@@ -2231,7 +2301,7 @@ class StatefulComponent(BaseComponent):
"""
if self.rendered_as_shared:
return {
- f"/{Dirs.UTILS}/{PageNames.STATEFUL_COMPONENTS}": [
+ f"$/{Dirs.UTILS}/{PageNames.STATEFUL_COMPONENTS}": [
ImportVar(tag=self.tag)
]
}
@@ -2273,7 +2343,7 @@ class StatefulComponent(BaseComponent):
Returns:
The tag to render.
"""
- return dict(Tag(name=self.tag))
+ return dict(Tag(name=self.tag or ""))
def __str__(self) -> str:
"""Represent the component in React.
@@ -2338,3 +2408,206 @@ class MemoizationLeaf(Component):
update={"disposition": MemoizationDisposition.ALWAYS}
)
return comp
+
+
+load_dynamic_serializer()
+
+
+class ComponentVar(Var[Component], python_types=BaseComponent):
+ """A Var that represents a Component."""
+
+
+def empty_component() -> Component:
+ """Create an empty component.
+
+ Returns:
+ An empty component.
+ """
+ from reflex.components.base.bare import Bare
+
+ return Bare.create("")
+
+
+def render_dict_to_var(tag: dict | Component | str, imported_names: set[str]) -> Var:
+ """Convert a render dict to a Var.
+
+ Args:
+ tag: The render dict.
+ imported_names: The names of the imported components.
+
+ Returns:
+ The Var.
+ """
+ if not isinstance(tag, dict):
+ if isinstance(tag, Component):
+ return render_dict_to_var(tag.render(), imported_names)
+ return Var.create(tag)
+
+ if "iterable" in tag:
+ function_return = Var.create(
+ [
+ render_dict_to_var(child.render(), imported_names)
+ for child in tag["children"]
+ ]
+ )
+
+ func = ArgsFunctionOperation.create(
+ (tag["arg_var_name"], tag["index_var_name"]),
+ function_return,
+ )
+
+ return FunctionStringVar.create("Array.prototype.map.call").call(
+ tag["iterable"]
+ if not isinstance(tag["iterable"], ObjectVar)
+ else tag["iterable"].items(),
+ func,
+ )
+
+ if tag["name"] == "match":
+ element = tag["cond"]
+
+ conditionals = tag["default"]
+
+ for case in tag["match_cases"][::-1]:
+ condition = case[0].to_string() == element.to_string()
+ for pattern in case[1:-1]:
+ condition = condition | (pattern.to_string() == element.to_string())
+
+ conditionals = ternary_operation(
+ condition,
+ case[-1],
+ conditionals,
+ )
+
+ return conditionals
+
+ if "cond" in tag:
+ return ternary_operation(
+ tag["cond"],
+ render_dict_to_var(tag["true_value"], imported_names),
+ render_dict_to_var(tag["false_value"], imported_names)
+ if tag["false_value"] is not None
+ else Var.create(None),
+ )
+
+ props = {}
+
+ special_props = []
+
+ for prop_str in tag["props"]:
+ if "=" not in prop_str:
+ special_props.append(Var(prop_str).to(ObjectVar))
+ continue
+ prop = prop_str.index("=")
+ key = prop_str[:prop]
+ value = prop_str[prop + 2 : -1]
+ props[key] = value
+
+ props = Var.create({Var.create(k): Var(v) for k, v in props.items()})
+
+ for prop in special_props:
+ props = props.merge(prop)
+
+ contents = tag["contents"][1:-1] if tag["contents"] else None
+
+ raw_tag_name = tag.get("name")
+ tag_name = Var(raw_tag_name or "Fragment")
+
+ tag_name = (
+ Var.create(raw_tag_name)
+ if raw_tag_name
+ and raw_tag_name.split(".")[0] not in imported_names
+ and raw_tag_name.lower() == raw_tag_name
+ else tag_name
+ )
+
+ return FunctionStringVar.create(
+ "jsx",
+ ).call(
+ tag_name,
+ props,
+ *([Var(contents)] if contents is not None else []),
+ *[render_dict_to_var(child, imported_names) for child in tag["children"]],
+ )
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+)
+class LiteralComponentVar(CachedVarOperation, LiteralVar, ComponentVar):
+ """A Var that represents a Component."""
+
+ _var_value: BaseComponent = dataclasses.field(default_factory=empty_component)
+
+ @cached_property_no_lock
+ def _cached_var_name(self) -> str:
+ """Get the name of the var.
+
+ Returns:
+ The name of the var.
+ """
+ var_data = self._get_all_var_data()
+ if var_data is not None:
+ # flatten imports
+ imported_names = {j.alias or j.name for i in var_data.imports for j in i[1]}
+ else:
+ imported_names = set()
+ return str(render_dict_to_var(self._var_value.render(), imported_names))
+
+ @cached_property_no_lock
+ def _cached_get_all_var_data(self) -> VarData | None:
+ """Get the VarData for the var.
+
+ Returns:
+ The VarData for the var.
+ """
+ return VarData.merge(
+ VarData(
+ imports={
+ "@emotion/react": [
+ ImportVar(tag="jsx"),
+ ],
+ }
+ ),
+ VarData(
+ imports=self._var_value._get_all_imports(),
+ ),
+ VarData(
+ imports={
+ "react": [
+ ImportVar(tag="Fragment"),
+ ],
+ }
+ ),
+ )
+
+ def __hash__(self) -> int:
+ """Get the hash of the var.
+
+ Returns:
+ The hash of the var.
+ """
+ return hash((type(self).__name__, self._js_expr))
+
+ @classmethod
+ def create(
+ cls,
+ value: Component,
+ _var_data: VarData | None = None,
+ ):
+ """Create a var from a value.
+
+ Args:
+ value: The value of the var.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The var.
+ """
+ return LiteralComponentVar(
+ _js_expr="",
+ _var_type=type(value),
+ _var_data=_var_data,
+ _var_value=value,
+ )
diff --git a/reflex/components/core/banner.py b/reflex/components/core/banner.py
index c6b46696c..b7b6fae6c 100644
--- a/reflex/components/core/banner.py
+++ b/reflex/components/core/banner.py
@@ -4,7 +4,6 @@ from __future__ import annotations
from typing import Optional
-from reflex.components.base.bare import Bare
from reflex.components.component import Component
from reflex.components.core.cond import cond
from reflex.components.el.elements.typography import Div
@@ -19,71 +18,60 @@ from reflex.components.radix.themes.typography.text import Text
from reflex.components.sonner.toast import Toaster, ToastProps
from reflex.constants import Dirs, Hooks, Imports
from reflex.constants.compiler import CompileVars
-from reflex.utils.imports import ImportDict, ImportVar
-from reflex.utils.serializers import serialize
-from reflex.vars import Var, VarData
+from reflex.utils.imports import ImportVar
+from reflex.vars import VarData
+from reflex.vars.base import LiteralVar, Var
+from reflex.vars.function import FunctionStringVar
+from reflex.vars.number import BooleanVar
+from reflex.vars.sequence import LiteralArrayVar
connect_error_var_data: VarData = VarData( # type: ignore
imports=Imports.EVENTS,
hooks={Hooks.EVENTS: None},
)
-connect_errors: Var = Var.create_safe(
- value=CompileVars.CONNECT_ERROR,
- _var_is_local=True,
- _var_is_string=False,
+connect_errors = Var(
+ _js_expr=CompileVars.CONNECT_ERROR, _var_data=connect_error_var_data
+)
+
+connection_error = Var(
+ _js_expr="((connectErrors.length > 0) ? connectErrors[connectErrors.length - 1].message : '')",
_var_data=connect_error_var_data,
)
-connection_error: Var = Var.create_safe(
- value="(connectErrors.length > 0) ? connectErrors[connectErrors.length - 1].message : ''",
- _var_is_local=False,
- _var_is_string=False,
- _var_data=connect_error_var_data,
+connection_errors_count = Var(
+ _js_expr="connectErrors.length", _var_data=connect_error_var_data
)
-connection_errors_count: Var = Var.create_safe(
- value="connectErrors.length",
- _var_is_string=False,
- _var_is_local=False,
- _var_data=connect_error_var_data,
-)
+has_connection_errors = Var(
+ _js_expr="(connectErrors.length > 0)", _var_data=connect_error_var_data
+).to(BooleanVar)
-has_connection_errors: Var = Var.create_safe(
- value="connectErrors.length > 0",
- _var_is_string=False,
- _var_data=connect_error_var_data,
-).to(bool)
-
-has_too_many_connection_errors: Var = Var.create_safe(
- value="connectErrors.length >= 2",
- _var_is_string=False,
- _var_data=connect_error_var_data,
-).to(bool)
+has_too_many_connection_errors = Var(
+ _js_expr="(connectErrors.length >= 2)", _var_data=connect_error_var_data
+).to(BooleanVar)
-class WebsocketTargetURL(Bare):
+class WebsocketTargetURL(Var):
"""A component that renders the websocket target URL."""
- def add_imports(self) -> ImportDict:
- """Add imports for the websocket target URL component.
-
- Returns:
- The import dict.
- """
- return {
- f"/{Dirs.STATE_PATH}": [ImportVar(tag="getBackendURL")],
- "/env.json": [ImportVar(tag="env", is_default=True)],
- }
-
@classmethod
- def create(cls) -> Component:
+ def create(cls) -> Var:
"""Create a websocket target URL component.
Returns:
The websocket target URL component.
"""
- return super().create(contents="{getBackendURL(env.EVENT).href}")
+ return Var(
+ _js_expr="getBackendURL(env.EVENT).href",
+ _var_data=VarData(
+ imports={
+ "$/env.json": [ImportVar(tag="env", is_default=True)],
+ f"$/{Dirs.STATE_PATH}": [ImportVar(tag="getBackendURL")],
+ },
+ ),
+ _var_type=WebsocketTargetURL,
+ )
def default_connection_error() -> list[str | Var | Component]:
@@ -112,24 +100,34 @@ class ConnectionToaster(Toaster):
toast_id = "websocket-error"
target_url = WebsocketTargetURL.create()
props = ToastProps( # type: ignore
- description=Var.create(
- f"`Check if server is reachable at ${target_url}`",
- _var_is_string=False,
- _var_is_local=False,
+ description=LiteralVar.create(
+ f"Check if server is reachable at {target_url}",
),
close_button=True,
duration=120000,
id=toast_id,
)
- hook = Var.create_safe(
- f"""
-const toast_props = {serialize(props)};
-const [userDismissed, setUserDismissed] = useState(false);
-useEffect(() => {{
- if ({has_too_many_connection_errors}) {{
+
+ individual_hooks = [
+ f"const toast_props = {LiteralVar.create(props)!s};",
+ "const [userDismissed, setUserDismissed] = useState(false);",
+ FunctionStringVar(
+ "useEffect",
+ _var_data=VarData(
+ imports={
+ "react": ["useEffect", "useState"],
+ **dict(target_url._get_all_var_data().imports), # type: ignore
+ }
+ ),
+ ).call(
+ # TODO: This breaks the assumption that Vars are JS expressions
+ Var(
+ _js_expr=f"""
+() => {{
+ if ({has_too_many_connection_errors!s}) {{
if (!userDismissed) {{
toast.error(
- `Cannot connect to server: {connection_error}.`,
+ `Cannot connect to server: ${{{connection_error}}}.`,
{{...toast_props, onDismiss: () => setUserDismissed(true)}},
)
}}
@@ -137,20 +135,16 @@ useEffect(() => {{
toast.dismiss("{toast_id}");
setUserDismissed(false); // after reconnection reset dismissed state
}}
-}}, [{connect_errors}]);""",
- _var_is_string=False,
- )
- imports: ImportDict = {
- "react": ["useEffect", "useState"],
- **target_url._get_imports(), # type: ignore
- }
- hook._var_data = VarData.merge(
- connect_errors._var_data,
- VarData(imports=imports),
- )
+}}
+"""
+ ),
+ LiteralArrayVar.create([connect_errors]),
+ ),
+ ]
+
return [
Hooks.EVENTS,
- hook,
+ *individual_hooks,
]
@classmethod
@@ -240,15 +234,16 @@ class WifiOffPulse(Icon):
Returns:
The icon component with default props applied.
"""
+ pulse_var = Var(_js_expr="pulse")
return super().create(
"wifi_off",
color=props.pop("color", "crimson"),
size=props.pop("size", 32),
z_index=props.pop("z_index", 9999),
position=props.pop("position", "fixed"),
- bottom=props.pop("botton", "33px"),
+ bottom=props.pop("bottom", "33px"),
right=props.pop("right", "33px"),
- animation=Var.create(f"${{pulse}} 1s infinite", _var_is_string=True),
+ animation=LiteralVar.create(f"{pulse_var} 1s infinite"),
**props,
)
diff --git a/reflex/components/core/banner.pyi b/reflex/components/core/banner.pyi
index b9b6d506f..f44ee7992 100644
--- a/reflex/components/core/banner.pyi
+++ b/reflex/components/core/banner.pyi
@@ -3,92 +3,41 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
-from reflex.components.base.bare import Bare
from reflex.components.component import Component
from reflex.components.el.elements.typography import Div
from reflex.components.lucide.icon import Icon
from reflex.components.sonner.toast import Toaster, ToastProps
-from reflex.event import EventHandler, EventSpec
+from reflex.constants.compiler import CompileVars
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.utils.imports import ImportDict, ImportVar
-from reflex.vars import BaseVar, Var, VarData
+from reflex.utils.imports import ImportVar
+from reflex.vars import VarData
+from reflex.vars.base import Var
+from reflex.vars.number import BooleanVar
connect_error_var_data: VarData
-connect_errors: Var
-connection_error: Var
-connection_errors_count: Var
-has_connection_errors: Var
-has_too_many_connection_errors: Var
+connect_errors = Var(
+ _js_expr=CompileVars.CONNECT_ERROR, _var_data=connect_error_var_data
+)
+connection_error = Var(
+ _js_expr="((connectErrors.length > 0) ? connectErrors[connectErrors.length - 1].message : '')",
+ _var_data=connect_error_var_data,
+)
+connection_errors_count = Var(
+ _js_expr="connectErrors.length", _var_data=connect_error_var_data
+)
+has_connection_errors = Var(
+ _js_expr="(connectErrors.length > 0)", _var_data=connect_error_var_data
+).to(BooleanVar)
+has_too_many_connection_errors = Var(
+ _js_expr="(connectErrors.length >= 2)", _var_data=connect_error_var_data
+).to(BooleanVar)
-class WebsocketTargetURL(Bare):
- def add_imports(self) -> ImportDict: ...
- @overload
+class WebsocketTargetURL(Var):
@classmethod
- def create( # type: ignore
- cls,
- *children,
- contents: Optional[Union[Var[str], str]] = None,
- style: Optional[Style] = None,
- key: Optional[Any] = None,
- id: Optional[Any] = None,
- class_name: Optional[Any] = None,
- autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- **props,
- ) -> "WebsocketTargetURL":
- """Create a websocket target URL component.
-
- Returns:
- The websocket target URL component.
- """
- ...
+ def create(cls) -> Var: ... # type: ignore
def default_connection_error() -> list[str | Var | Component]: ...
@@ -105,24 +54,24 @@ class ConnectionToaster(Toaster):
visible_toasts: Optional[Union[Var[int], int]] = None,
position: Optional[
Union[
+ Literal[
+ "bottom-center",
+ "bottom-left",
+ "bottom-right",
+ "top-center",
+ "top-left",
+ "top-right",
+ ],
Var[
Literal[
- "top-left",
- "top-center",
- "top-right",
- "bottom-left",
"bottom-center",
+ "bottom-left",
"bottom-right",
+ "top-center",
+ "top-left",
+ "top-right",
]
],
- Literal[
- "top-left",
- "top-center",
- "top-right",
- "bottom-left",
- "bottom-center",
- "bottom-right",
- ],
]
] = None,
close_button: Optional[Union[Var[bool], bool]] = None,
@@ -130,61 +79,31 @@ class ConnectionToaster(Toaster):
dir: Optional[Union[Var[str], str]] = None,
hotkey: Optional[Union[Var[str], str]] = None,
invert: Optional[Union[Var[bool], bool]] = None,
- toast_options: Optional[Union[Var[ToastProps], ToastProps]] = None,
+ toast_options: Optional[Union[ToastProps, Var[ToastProps]]] = None,
gap: Optional[Union[Var[int], int]] = None,
- loading_icon: Optional[Union[Var[Icon], Icon]] = None,
+ loading_icon: Optional[Union[Icon, Var[Icon]]] = None,
pause_when_page_is_hidden: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ConnectionToaster":
"""Create a connection toaster component.
@@ -229,52 +148,22 @@ class ConnectionBanner(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ConnectionBanner":
"""Create a connection banner component.
@@ -298,52 +187,22 @@ class ConnectionModal(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ConnectionModal":
"""Create a connection banner component.
@@ -368,52 +227,22 @@ class WifiOffPulse(Icon):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "WifiOffPulse":
"""Create a wifi_off icon with an animated opacity pulse.
@@ -442,87 +271,57 @@ class ConnectionPulser(Div):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ConnectionPulser":
"""Create a connection pulser component.
Args:
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a
element which will serve as the element's context menu.
diff --git a/reflex/components/core/breakpoints.py b/reflex/components/core/breakpoints.py
index 4b2372a70..25396ecd9 100644
--- a/reflex/components/core/breakpoints.py
+++ b/reflex/components/core/breakpoints.py
@@ -58,7 +58,7 @@ class Breakpoints(Dict[K, V]):
Args:
custom: Custom mapping using CSS values or variables.
- initial: Styling when in the inital width
+ initial: Styling when in the initial width
xs: Styling when in the extra-small width
sm: Styling when in the small width
md: Styling when in the medium width
diff --git a/reflex/components/core/client_side_routing.py b/reflex/components/core/client_side_routing.py
index 618467f39..a10b90de8 100644
--- a/reflex/components/core/client_side_routing.py
+++ b/reflex/components/core/client_side_routing.py
@@ -13,18 +13,18 @@ from __future__ import annotations
from reflex import constants
from reflex.components.component import Component
from reflex.components.core.cond import cond
-from reflex.vars import Var
+from reflex.vars.base import Var
-route_not_found: Var = Var.create_safe(constants.ROUTE_NOT_FOUND, _var_is_string=False)
+route_not_found: Var = Var(_js_expr=constants.ROUTE_NOT_FOUND)
class ClientSideRouting(Component):
"""The client-side routing component."""
- library = "/utils/client_side_routing"
+ library = "$/utils/client_side_routing"
tag = "useClientSideRouting"
- def add_hooks(self) -> list[str]:
+ def add_hooks(self) -> list[str | Var]:
"""Get the hooks to render.
Returns:
@@ -66,4 +66,4 @@ class Default404Page(Component):
tag = "Error"
is_default = True
- status_code: Var[int] = 404 # type: ignore
+ status_code: Var[int] = Var.create(404)
diff --git a/reflex/components/core/client_side_routing.pyi b/reflex/components/core/client_side_routing.pyi
index 7562f6f5c..581b0e120 100644
--- a/reflex/components/core/client_side_routing.pyi
+++ b/reflex/components/core/client_side_routing.pyi
@@ -3,17 +3,17 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
route_not_found: Var
class ClientSideRouting(Component):
- def add_hooks(self) -> list[str]: ...
+ def add_hooks(self) -> list[str | Var]: ...
def render(self) -> str: ...
@overload
@classmethod
@@ -25,52 +25,22 @@ class ClientSideRouting(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ClientSideRouting":
"""Create the component.
@@ -104,52 +74,22 @@ class Default404Page(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Default404Page":
"""Create the component.
diff --git a/reflex/components/core/clipboard.py b/reflex/components/core/clipboard.py
index 9b0edcc29..644de80d0 100644
--- a/reflex/components/core/clipboard.py
+++ b/reflex/components/core/clipboard.py
@@ -2,14 +2,16 @@
from __future__ import annotations
-from typing import Dict, List, Union
+from typing import Dict, List, Tuple, Union
from reflex.components.base.fragment import Fragment
from reflex.components.tags.tag import Tag
-from reflex.event import EventChain, EventHandler
+from reflex.constants.compiler import Hooks
+from reflex.event import EventChain, EventHandler, passthrough_event_spec
from reflex.utils.format import format_prop, wrap
from reflex.utils.imports import ImportVar
-from reflex.vars import Var, get_unique_variable_name
+from reflex.vars import get_unique_variable_name
+from reflex.vars.base import Var, VarData
class Clipboard(Fragment):
@@ -19,7 +21,7 @@ class Clipboard(Fragment):
targets: Var[List[str]]
# Called when the user pastes data into the document. Data is a list of tuples of (mime_type, data). Binary types will be base64 encoded as a data uri.
- on_paste: EventHandler[lambda data: [data]]
+ on_paste: EventHandler[passthrough_event_spec(List[Tuple[str, str]])]
# Save the original event actions for the on_paste event.
on_paste_event_actions: Var[Dict[str, Union[bool, int]]]
@@ -50,7 +52,7 @@ class Clipboard(Fragment):
return super().create(*children, **props)
def _exclude_props(self) -> list[str]:
- return super()._exclude_props() + ["on_paste", "on_paste_event_actions"]
+ return [*super()._exclude_props(), "on_paste", "on_paste_event_actions"]
def _render(self) -> Tag:
tag = super()._render()
@@ -66,12 +68,12 @@ class Clipboard(Fragment):
The import dict for the component.
"""
return {
- "/utils/helpers/paste.js": ImportVar(
+ "$/utils/helpers/paste.js": ImportVar(
tag="usePasteHandler", is_default=True
),
}
- def add_hooks(self) -> list[str]:
+ def add_hooks(self) -> list[str | Var[str]]:
"""Add hook to register paste event listener.
Returns:
@@ -82,13 +84,14 @@ class Clipboard(Fragment):
return []
if isinstance(on_paste, EventChain):
on_paste = wrap(str(format_prop(on_paste)).strip("{}"), "(")
+ hook_expr = f"usePasteHandler({self.targets!s}, {self.on_paste_event_actions!s}, {on_paste!s})"
+
return [
- "usePasteHandler(%s, %s, %s)"
- % (
- self.targets._var_name_unwrapped,
- self.on_paste_event_actions._var_name_unwrapped,
- on_paste,
- )
+ Var(
+ hook_expr,
+ _var_type="str",
+ _var_data=VarData(position=Hooks.HookPosition.POST_TRIGGER),
+ ),
]
diff --git a/reflex/components/core/clipboard.pyi b/reflex/components/core/clipboard.pyi
index 29ad80c2f..328554f2a 100644
--- a/reflex/components/core/clipboard.pyi
+++ b/reflex/components/core/clipboard.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Optional, Union, overload
+from typing import Any, Dict, List, Optional, Union, overload
from reflex.components.base.fragment import Fragment
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
from reflex.utils.imports import ImportVar
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class Clipboard(Fragment):
@overload
@@ -17,64 +17,37 @@ class Clipboard(Fragment):
def create( # type: ignore
cls,
*children,
- targets: Optional[Union[Var[List[str]], List[str]]] = None,
+ targets: Optional[Union[List[str], Var[List[str]]]] = None,
on_paste_event_actions: Optional[
- Union[Var[Dict[str, Union[bool, int]]], Dict[str, Union[bool, int]]]
+ Union[Dict[str, Union[bool, int]], Var[Dict[str, Union[bool, int]]]]
] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_paste: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[list[tuple[str, str]]], BASE_STATE],
+ ]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Clipboard":
"""Create a Clipboard component.
@@ -82,6 +55,7 @@ class Clipboard(Fragment):
Args:
*children: The children of the component.
targets: The element ids to attach the event listener to. Defaults to all child components or the document.
+ on_paste: Called when the user pastes data into the document. Data is a list of tuples of (mime_type, data). Binary types will be base64 encoded as a data uri.
on_paste_event_actions: Save the original event actions for the on_paste event.
style: The style of the component.
key: A unique key for the component.
@@ -97,6 +71,6 @@ class Clipboard(Fragment):
...
def add_imports(self) -> dict[str, ImportVar]: ...
- def add_hooks(self) -> list[str]: ...
+ def add_hooks(self) -> list[str | Var[str]]: ...
clipboard = Clipboard.create
diff --git a/reflex/components/core/cond.py b/reflex/components/core/cond.py
index 5d9ab7544..488990f54 100644
--- a/reflex/components/core/cond.py
+++ b/reflex/components/core/cond.py
@@ -2,20 +2,20 @@
from __future__ import annotations
-from typing import Any, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, overload
from reflex.components.base.fragment import Fragment
from reflex.components.component import BaseComponent, Component, MemoizationLeaf
from reflex.components.tags import CondTag, Tag
from reflex.constants import Dirs
-from reflex.constants.colors import Color
from reflex.style import LIGHT_COLOR_MODE, resolved_color_mode
-from reflex.utils import format
from reflex.utils.imports import ImportDict, ImportVar
-from reflex.vars import BaseVar, Var, VarData
+from reflex.vars import VarData
+from reflex.vars.base import LiteralVar, Var
+from reflex.vars.number import ternary_operation
_IS_TRUE_IMPORT: ImportDict = {
- f"/{Dirs.STATE_PATH}": [ImportVar(tag="isTrue")],
+ f"$/{Dirs.STATE_PATH}": [ImportVar(tag="isTrue")],
}
@@ -49,9 +49,9 @@ class Cond(MemoizationLeaf):
The conditional component.
"""
# Wrap everything in fragments.
- if comp1.__class__.__name__ != "Fragment":
+ if type(comp1).__name__ != "Fragment":
comp1 = Fragment.create(comp1)
- if comp2 is None or comp2.__class__.__name__ != "Fragment":
+ if comp2 is None or type(comp2).__name__ != "Fragment":
comp2 = Fragment.create(comp2) if comp2 else Fragment.create()
return Fragment.create(
cls(
@@ -94,7 +94,7 @@ class Cond(MemoizationLeaf):
).set(
props=tag.format_props(),
),
- cond_state=f"isTrue({self.cond._var_full_name})",
+ cond_state=f"isTrue({self.cond!s})",
)
def add_imports(self) -> ImportDict:
@@ -103,10 +103,11 @@ class Cond(MemoizationLeaf):
Returns:
The import dict for the component.
"""
- cond_imports: dict[str, str | ImportVar | list[str | ImportVar]] = getattr(
- self.cond._var_data, "imports", {}
- )
- return {**cond_imports, **_IS_TRUE_IMPORT}
+ var_data = VarData.merge(self.cond._get_all_var_data())
+
+ imports = var_data.old_school_imports() if var_data else {}
+
+ return {**imports, **_IS_TRUE_IMPORT}
@overload
@@ -118,10 +119,10 @@ def cond(condition: Any, c1: Component) -> Component: ...
@overload
-def cond(condition: Any, c1: Any, c2: Any) -> BaseVar: ...
+def cond(condition: Any, c1: Any, c2: Any) -> Var: ...
-def cond(condition: Any, c1: Any, c2: Any = None):
+def cond(condition: Any, c1: Any, c2: Any = None) -> Component | Var:
"""Create a conditional component or Prop.
Args:
@@ -135,24 +136,16 @@ def cond(condition: Any, c1: Any, c2: Any = None):
Raises:
ValueError: If the arguments are invalid.
"""
- var_datas: list[VarData | None] = [
- VarData( # type: ignore
- imports=_IS_TRUE_IMPORT,
- ),
- ]
-
# Convert the condition to a Var.
- cond_var = Var.create(condition)
- assert cond_var is not None, "The condition must be set."
+ cond_var = LiteralVar.create(condition)
+ if cond_var is None:
+ raise ValueError("The condition must be set.")
# If the first component is a component, create a Cond component.
if isinstance(c1, BaseComponent):
- assert c2 is None or isinstance(
- c2, BaseComponent
- ), "Both arguments must be components."
+ if c2 is not None and not isinstance(c2, BaseComponent):
+ raise ValueError("Both arguments must be components.")
return Cond.create(cond_var, c1, c2)
- if isinstance(c1, Var):
- var_datas.append(c1._var_data)
# Otherwise, create a conditional Var.
# Check that the second argument is valid.
@@ -160,40 +153,32 @@ def cond(condition: Any, c1: Any, c2: Any = None):
raise ValueError("Both arguments must be props.")
if c2 is None:
raise ValueError("For conditional vars, the second argument must be set.")
- if isinstance(c2, Var):
- var_datas.append(c2._var_data)
def create_var(cond_part):
- return Var.create_safe(
- cond_part,
- _var_is_string=isinstance(cond_part, (str, Color)),
- )
+ return LiteralVar.create(cond_part)
# convert the truth and false cond parts into vars so the _var_data can be obtained.
c1 = create_var(c1)
c2 = create_var(c2)
- var_datas.extend([c1._var_data, c2._var_data])
-
- c1_type = c1._var_type if isinstance(c1, Var) else type(c1)
- c2_type = c2._var_type if isinstance(c2, Var) else type(c2)
-
- var_type = c1_type if c1_type == c2_type else Union[c1_type, c2_type]
# Create the conditional var.
- return cond_var._replace(
- _var_name=format.format_cond(
- cond=cond_var._var_full_name,
- true_value=c1,
- false_value=c2,
- is_prop=True,
- ),
- _var_type=var_type,
- _var_is_local=False,
- _var_full_name_needs_state_prefix=False,
- merge_var_data=VarData.merge(*var_datas),
+ return ternary_operation(
+ cond_var.bool()._replace( # type: ignore
+ merge_var_data=VarData(imports=_IS_TRUE_IMPORT),
+ ), # type: ignore
+ c1,
+ c2,
)
+@overload
+def color_mode_cond(light: Component, dark: Component | None = None) -> Component: ... # type: ignore
+
+
+@overload
+def color_mode_cond(light: Any, dark: Any = None) -> Var: ...
+
+
def color_mode_cond(light: Any, dark: Any = None) -> Var | Component:
"""Create a component or Prop based on color_mode.
@@ -205,7 +190,7 @@ def color_mode_cond(light: Any, dark: Any = None) -> Var | Component:
The conditional component or prop.
"""
return cond(
- resolved_color_mode == Var.create(LIGHT_COLOR_MODE, _var_is_string=True),
+ resolved_color_mode == LiteralVar.create(LIGHT_COLOR_MODE),
light,
dark,
)
diff --git a/reflex/components/core/debounce.py b/reflex/components/core/debounce.py
index 4dc7c14a1..12cc94426 100644
--- a/reflex/components/core/debounce.py
+++ b/reflex/components/core/debounce.py
@@ -6,8 +6,9 @@ from typing import Any, Type, Union
from reflex.components.component import Component
from reflex.constants import EventTriggers
-from reflex.event import EventHandler
-from reflex.vars import Var, VarData
+from reflex.event import EventHandler, no_args_event_spec
+from reflex.vars import VarData
+from reflex.vars.base import Var
DEFAULT_DEBOUNCE_TIMEOUT = 300
@@ -45,7 +46,7 @@ class DebounceInput(Component):
element: Var[Type[Component]]
# Fired when the input value changes
- on_change: EventHandler[lambda e0: [e0.value]]
+ on_change: EventHandler[no_args_event_spec]
@classmethod
def create(cls, *children: Component, **props: Any) -> Component:
@@ -106,23 +107,20 @@ class DebounceInput(Component):
props[field] = getattr(child, field)
child_ref = child.get_ref()
if props.get("input_ref") is None and child_ref:
- props["input_ref"] = Var.create_safe(
- child_ref, _var_is_local=False, _var_is_string=False
- )
+ props["input_ref"] = Var(_js_expr=child_ref, _var_type=str)
props["id"] = child.id
# Set the child element to wrap, including any imports/hooks from the child.
props.setdefault(
"element",
- Var.create_safe(
- "{%s}" % (child.alias or child.tag),
- _var_is_local=False,
- _var_is_string=False,
+ Var(
+ _js_expr=str(child.alias or child.tag),
+ _var_type=Type[Component],
_var_data=VarData(
imports=child._get_imports(),
- hooks=child._get_hooks_internal(),
+ hooks=child._get_all_hooks(),
),
- ).to(Type[Component]),
+ ),
)
component = super().create(**props)
@@ -130,6 +128,10 @@ class DebounceInput(Component):
component.event_triggers.update(child.event_triggers)
component.children = child.children
component._rename_props = child._rename_props
+ outer_get_all_custom_code = component._get_all_custom_code
+ component._get_all_custom_code = lambda: outer_get_all_custom_code().union(
+ child._get_all_custom_code()
+ )
return component
def _render(self):
diff --git a/reflex/components/core/debounce.pyi b/reflex/components/core/debounce.pyi
index 59e87f366..9e61af6e3 100644
--- a/reflex/components/core/debounce.pyi
+++ b/reflex/components/core/debounce.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Type, Union, overload
+from typing import Any, Dict, Optional, Type, Union, overload
from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
DEFAULT_DEBOUNCE_TIMEOUT = 300
@@ -22,63 +22,31 @@ class DebounceInput(Component):
debounce_timeout: Optional[Union[Var[int], int]] = None,
force_notify_by_enter: Optional[Union[Var[bool], bool]] = None,
force_notify_on_blur: Optional[Union[Var[bool], bool]] = None,
- value: Optional[Union[Var[Union[float, int, str]], str, int, float]] = None,
+ value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None,
input_ref: Optional[Union[Var[str], str]] = None,
- element: Optional[Union[Var[Type[Component]], Type[Component]]] = None,
+ element: Optional[Union[Type[Component], Var[Type[Component]]]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_change: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DebounceInput":
"""Create a DebounceInput component.
diff --git a/reflex/components/core/foreach.py b/reflex/components/core/foreach.py
index 44e0685dd..c9fbe5bc5 100644
--- a/reflex/components/core/foreach.py
+++ b/reflex/components/core/foreach.py
@@ -10,8 +10,7 @@ from reflex.components.component import Component
from reflex.components.tags import IterTag
from reflex.constants import MemoizationMode
from reflex.state import ComponentState
-from reflex.utils import console
-from reflex.vars import Var
+from reflex.vars.base import LiteralVar, Var
class ForeachVarError(TypeError):
@@ -38,14 +37,12 @@ class Foreach(Component):
cls,
iterable: Var[Iterable] | Iterable,
render_fn: Callable,
- **props,
) -> Foreach:
"""Create a foreach component.
Args:
iterable: The iterable to create components from.
render_fn: A function from the render args to the component.
- **props: The attributes to pass to each child component (deprecated).
Returns:
The foreach component.
@@ -54,17 +51,10 @@ class Foreach(Component):
ForeachVarError: If the iterable is of type Any.
TypeError: If the render function is a ComponentState.
"""
- if props:
- console.deprecate(
- feature_name="Passing props to rx.foreach",
- reason="it does not have the intended effect and may be confusing",
- deprecation_version="0.5.0",
- removal_version="0.6.0",
- )
- iterable = Var.create_safe(iterable, _var_is_string=False)
+ iterable = LiteralVar.create(iterable)
if iterable._var_type == Any:
raise ForeachVarError(
- f"Could not foreach over var `{iterable._var_full_name}` of type Any. "
+ f"Could not foreach over var `{iterable!s}` of type Any. "
"(If you are trying to foreach over a state var, add a type annotation to the var). "
"See https://reflex.dev/docs/library/dynamic-rendering/foreach/"
)
@@ -136,7 +126,7 @@ class Foreach(Component):
return dict(
tag,
- iterable_state=tag.iterable._var_full_name,
+ iterable_state=str(tag.iterable),
arg_name=tag.arg_var_name,
arg_index=tag.get_index_var_arg(),
iterable_type=tag.iterable._var_type.mro()[0].__name__,
diff --git a/reflex/components/core/html.py b/reflex/components/core/html.py
index 812bf64be..cfe46e591 100644
--- a/reflex/components/core/html.py
+++ b/reflex/components/core/html.py
@@ -3,7 +3,7 @@
from typing import Dict
from reflex.components.el.elements.typography import Div
-from reflex.vars import Var
+from reflex.vars.base import Var
class Html(Div):
diff --git a/reflex/components/core/html.pyi b/reflex/components/core/html.pyi
index 62bec0063..e65549d0f 100644
--- a/reflex/components/core/html.pyi
+++ b/reflex/components/core/html.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
from reflex.components.el.elements.typography import Div
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class Html(Div):
@overload
@@ -17,83 +17,53 @@ class Html(Div):
cls,
*children,
dangerouslySetInnerHTML: Optional[
- Union[Var[Dict[str, str]], Dict[str, str]]
+ Union[Dict[str, str], Var[Dict[str, str]]]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Html":
"""Create a html component.
@@ -101,7 +71,7 @@ class Html(Div):
Args:
*children: The children of the component.
dangerouslySetInnerHTML: The HTML to render.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/core/match.py b/reflex/components/core/match.py
index e85739605..8b9382c89 100644
--- a/reflex/components/core/match.py
+++ b/reflex/components/core/match.py
@@ -5,13 +5,13 @@ from typing import Any, Dict, List, Optional, Tuple, Union
from reflex.components.base import Fragment
from reflex.components.component import BaseComponent, Component, MemoizationLeaf
-from reflex.components.core.colors import Color
from reflex.components.tags import MatchTag, Tag
from reflex.style import Style
from reflex.utils import format, types
from reflex.utils.exceptions import MatchTypeError
from reflex.utils.imports import ImportDict
-from reflex.vars import BaseVar, Var, VarData
+from reflex.vars import VarData
+from reflex.vars.base import LiteralVar, Var
class Match(MemoizationLeaf):
@@ -27,7 +27,7 @@ class Match(MemoizationLeaf):
default: Any
@classmethod
- def create(cls, cond: Any, *cases) -> Union[Component, BaseVar]:
+ def create(cls, cond: Any, *cases) -> Union[Component, Var]:
"""Create a Match Component.
Args:
@@ -46,7 +46,7 @@ class Match(MemoizationLeaf):
cls._validate_return_types(match_cases)
- if default is None and types._issubclass(type(match_cases[0][-1]), BaseVar):
+ if default is None and types._issubclass(type(match_cases[0][-1]), Var):
raise ValueError(
"For cases with return types as Vars, a default case must be provided"
)
@@ -56,7 +56,7 @@ class Match(MemoizationLeaf):
)
@classmethod
- def _create_condition_var(cls, cond: Any) -> BaseVar:
+ def _create_condition_var(cls, cond: Any) -> Var:
"""Convert the condition to a Var.
Args:
@@ -68,16 +68,16 @@ class Match(MemoizationLeaf):
Raises:
ValueError: If the condition is not provided.
"""
- match_cond_var = Var.create(cond, _var_is_string=isinstance(cond, str))
+ match_cond_var = LiteralVar.create(cond)
if match_cond_var is None:
raise ValueError("The condition must be set")
- return match_cond_var # type: ignore
+ return match_cond_var
@classmethod
def _process_cases(
cls, cases: List
- ) -> Tuple[List, Optional[Union[BaseVar, BaseComponent]]]:
+ ) -> Tuple[List, Optional[Union[Var, BaseComponent]]]:
"""Process the list of match cases and the catchall default case.
Args:
@@ -94,6 +94,9 @@ class Match(MemoizationLeaf):
if len([case for case in cases if not isinstance(case, tuple)]) > 1:
raise ValueError("rx.match can only have one default case.")
+ if not cases:
+ raise ValueError("rx.match should have at least one case.")
+
# Get the default case which should be the last non-tuple arg
if not isinstance(cases[-1], tuple):
default = cases.pop()
@@ -103,7 +106,7 @@ class Match(MemoizationLeaf):
else default
)
- return cases, default # type: ignore
+ return cases, default
@classmethod
def _create_case_var_with_var_data(cls, case_element):
@@ -117,17 +120,12 @@ class Match(MemoizationLeaf):
Returns:
The case element Var.
"""
- _var_data = case_element._var_data if isinstance(case_element, Style) else None # type: ignore
- case_element = Var.create(
- case_element,
- _var_is_string=isinstance(case_element, (str, Color)),
- )
- if _var_data is not None:
- case_element._var_data = VarData.merge(case_element._var_data, _var_data) # type: ignore
+ _var_data = case_element._var_data if isinstance(case_element, Style) else None
+ case_element = LiteralVar.create(case_element, _var_data=_var_data)
return case_element
@classmethod
- def _process_match_cases(cls, cases: List) -> List[List[BaseVar]]:
+ def _process_match_cases(cls, cases: List) -> List[List[Var]]:
"""Process the individual match cases.
Args:
@@ -159,7 +157,7 @@ class Match(MemoizationLeaf):
if not isinstance(element, BaseComponent)
else element
)
- if not isinstance(el, (BaseVar, BaseComponent)):
+ if not isinstance(el, (Var, BaseComponent)):
raise ValueError("Case element must be a var or component")
case_list.append(el)
@@ -168,7 +166,7 @@ class Match(MemoizationLeaf):
return match_cases
@classmethod
- def _validate_return_types(cls, match_cases: List[List[BaseVar]]) -> None:
+ def _validate_return_types(cls, match_cases: List[List[Var]]) -> None:
"""Validate that match cases have the same return types.
Args:
@@ -182,14 +180,14 @@ class Match(MemoizationLeaf):
if types._isinstance(first_case_return, BaseComponent):
return_type = BaseComponent
- elif types._isinstance(first_case_return, BaseVar):
- return_type = BaseVar
+ elif types._isinstance(first_case_return, Var):
+ return_type = Var
for index, case in enumerate(match_cases):
if not types._issubclass(type(case[-1]), return_type):
raise MatchTypeError(
f"Match cases should have the same return types. Case {index} with return "
- f"value `{case[-1]._var_name if isinstance(case[-1], BaseVar) else textwrap.shorten(str(case[-1]), width=250)}`"
+ f"value `{case[-1]._js_expr if isinstance(case[-1], Var) else textwrap.shorten(str(case[-1]), width=250)}`"
f" of type {type(case[-1])!r} is not {return_type}"
)
@@ -197,9 +195,9 @@ class Match(MemoizationLeaf):
def _create_match_cond_var_or_component(
cls,
match_cond_var: Var,
- match_cases: List[List[BaseVar]],
- default: Optional[Union[BaseVar, BaseComponent]],
- ) -> Union[Component, BaseVar]:
+ match_cases: List[List[Var]],
+ default: Optional[Union[Var, BaseComponent]],
+ ) -> Union[Component, Var]:
"""Create and return the match condition var or component.
Args:
@@ -230,28 +228,22 @@ class Match(MemoizationLeaf):
# Validate the match cases (as well as the default case) to have Var return types.
if any(
- case for case in match_cases if not types._isinstance(case[-1], BaseVar)
- ) or not types._isinstance(default, BaseVar):
+ case for case in match_cases if not types._isinstance(case[-1], Var)
+ ) or not types._isinstance(default, Var):
raise ValueError("Return types of match cases should be Vars.")
- # match cases and default should all be Vars at this point.
- # Retrieve var data of every var in the match cases and default.
- var_data = [
- *[el._var_data for case in match_cases for el in case],
- default._var_data, # type: ignore
- ]
-
- return match_cond_var._replace(
- _var_name=format.format_match(
- cond=match_cond_var._var_name_unwrapped,
- match_cases=match_cases, # type: ignore
+ return Var(
+ _js_expr=format.format_match(
+ cond=str(match_cond_var),
+ match_cases=match_cases,
default=default, # type: ignore
),
_var_type=default._var_type, # type: ignore
- _var_is_local=False,
- _var_full_name_needs_state_prefix=False,
- _var_is_string=False,
- merge_var_data=VarData.merge(*var_data),
+ _var_data=VarData.merge(
+ match_cond_var._get_all_var_data(),
+ *[el._get_all_var_data() for case in match_cases for el in case],
+ default._get_all_var_data(), # type: ignore
+ ),
)
def _render(self) -> Tag:
@@ -275,7 +267,8 @@ class Match(MemoizationLeaf):
Returns:
The import dict.
"""
- return getattr(self.cond._var_data, "imports", {})
+ var_data = VarData.merge(self.cond._get_all_var_data())
+ return var_data.old_school_imports() if var_data else {}
match = Match.create
diff --git a/reflex/components/core/upload.py b/reflex/components/core/upload.py
index 3c2113253..14205cc6b 100644
--- a/reflex/components/core/upload.py
+++ b/reflex/components/core/upload.py
@@ -2,32 +2,42 @@
from __future__ import annotations
-import os
from pathlib import Path
-from typing import Callable, ClassVar, Dict, List, Optional
+from typing import Any, Callable, ClassVar, Dict, List, Optional, Tuple
-from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
+from reflex.components.base.fragment import Fragment
+from reflex.components.component import (
+ Component,
+ ComponentNamespace,
+ MemoizationLeaf,
+ StatefulComponent,
+)
from reflex.components.el.elements.forms import Input
from reflex.components.radix.themes.layout.box import Box
+from reflex.config import environment
from reflex.constants import Dirs
+from reflex.constants.compiler import Hooks, Imports
from reflex.event import (
CallableEventSpec,
EventChain,
EventHandler,
EventSpec,
call_event_fn,
- call_script,
parse_args_spec,
+ run_script,
)
+from reflex.utils import format
from reflex.utils.imports import ImportVar
-from reflex.vars import BaseVar, CallableVar, Var, VarData
+from reflex.vars import VarData
+from reflex.vars.base import CallableVar, Var, get_unique_variable_name
+from reflex.vars.sequence import LiteralStringVar
DEFAULT_UPLOAD_ID: str = "default"
upload_files_context_var_data: VarData = VarData(
imports={
"react": "useContext",
- f"/{Dirs.CONTEXTS_PATH}": "UploadFilesContext",
+ f"$/{Dirs.CONTEXTS_PATH}": "UploadFilesContext",
},
hooks={
"const [filesById, setFilesById] = useContext(UploadFilesContext);": None,
@@ -36,7 +46,7 @@ upload_files_context_var_data: VarData = VarData(
@CallableVar
-def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar:
+def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var:
"""Get the file upload drop trigger.
This var is passed to the dropzone component to update the file list when a
@@ -48,23 +58,25 @@ def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar:
Returns:
A var referencing the file upload drop trigger.
"""
- id_var = Var.create_safe(id_, _var_is_string=True)
+ id_var = LiteralStringVar.create(id_)
var_name = f"""e => setFilesById(filesById => {{
const updatedFilesById = Object.assign({{}}, filesById);
- updatedFilesById[{id_var._var_name_unwrapped}] = e;
+ updatedFilesById[{id_var!s}] = e;
return updatedFilesById;
}})
"""
- return BaseVar(
- _var_name=var_name,
+ return Var(
+ _js_expr=var_name,
_var_type=EventChain,
- _var_data=VarData.merge(upload_files_context_var_data, id_var._var_data),
+ _var_data=VarData.merge(
+ upload_files_context_var_data, id_var._get_all_var_data()
+ ),
)
@CallableVar
-def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar:
+def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var:
"""Get the list of selected files.
Args:
@@ -73,12 +85,14 @@ def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar:
Returns:
A var referencing the list of selected file paths.
"""
- id_var = Var.create_safe(id_, _var_is_string=True)
- return BaseVar(
- _var_name=f"(filesById[{id_var._var_name_unwrapped}] ? filesById[{id_var._var_name_unwrapped}].map((f) => (f.path || f.name)) : [])",
+ id_var = LiteralStringVar.create(id_)
+ return Var(
+ _js_expr=f"(filesById[{id_var!s}] ? filesById[{id_var!s}].map((f) => (f.path || f.name)) : [])",
_var_type=List[str],
- _var_data=VarData.merge(upload_files_context_var_data, id_var._var_data),
- )
+ _var_data=VarData.merge(
+ upload_files_context_var_data, id_var._get_all_var_data()
+ ),
+ ).guess_type()
@CallableEventSpec
@@ -93,8 +107,9 @@ def clear_selected_files(id_: str = DEFAULT_UPLOAD_ID) -> EventSpec:
"""
# UploadFilesProvider assigns a special function to clear selected files
# into the shared global refs object to make it accessible outside a React
- # component via `call_script` (otherwise backend could never clear files).
- return call_script(f"refs['__clear_selected_files']({id_!r})")
+ # component via `run_script` (otherwise backend could never clear files).
+ func = Var("__clear_selected_files")._as_ref()
+ return run_script(f"{func}({id_!r})")
def cancel_upload(upload_id: str) -> EventSpec:
@@ -106,9 +121,8 @@ def cancel_upload(upload_id: str) -> EventSpec:
Returns:
An event spec that cancels the upload when triggered.
"""
- return call_script(
- f"upload_controllers[{Var.create_safe(upload_id, _var_is_string=True)._var_name_unwrapped}]?.abort()"
- )
+ controller = Var(f"__upload_controllers_{upload_id}")._as_ref()
+ return run_script(f"{controller}?.abort()")
def get_upload_dir() -> Path:
@@ -119,23 +133,20 @@ def get_upload_dir() -> Path:
"""
Upload.is_used = True
- uploaded_files_dir = Path(
- os.environ.get("REFLEX_UPLOADED_FILES_DIR", "./uploaded_files")
- )
+ uploaded_files_dir = environment.REFLEX_UPLOADED_FILES_DIR.get()
uploaded_files_dir.mkdir(parents=True, exist_ok=True)
return uploaded_files_dir
-uploaded_files_url_prefix: Var = Var.create_safe(
- "${getBackendURL(env.UPLOAD)}",
- _var_is_string=False,
+uploaded_files_url_prefix = Var(
+ _js_expr="getBackendURL(env.UPLOAD)",
_var_data=VarData(
imports={
- f"/{Dirs.STATE_PATH}": "getBackendURL",
- "/env.json": ImportVar(tag="env", is_default=True),
+ f"$/{Dirs.STATE_PATH}": "getBackendURL",
+ "$/env.json": ImportVar(tag="env", is_default=True),
}
),
-)
+).to(str)
def get_upload_url(file_path: str) -> Var[str]:
@@ -149,12 +160,10 @@ def get_upload_url(file_path: str) -> Var[str]:
"""
Upload.is_used = True
- return Var.create_safe(
- f"{uploaded_files_url_prefix}/{file_path}", _var_is_string=True
- )
+ return uploaded_files_url_prefix + "/" + file_path
-def _on_drop_spec(files: Var):
+def _on_drop_spec(files: Var) -> Tuple[Var[Any]]:
"""Args spec for the on_drop event trigger.
Args:
@@ -163,24 +172,29 @@ def _on_drop_spec(files: Var):
Returns:
Signature for on_drop handler including the files to upload.
"""
- return [files]
+ return (files,)
class UploadFilesProvider(Component):
"""AppWrap component that provides a dict of selected files by ID via useContext."""
- library = f"/{Dirs.CONTEXTS_PATH}"
+ library = f"$/{Dirs.CONTEXTS_PATH}"
tag = "UploadFilesProvider"
+class GhostUpload(Fragment):
+ """A ghost upload component."""
+
+ # Fired when files are dropped.
+ on_drop: EventHandler[_on_drop_spec]
+
+
class Upload(MemoizationLeaf):
"""A file upload component."""
- library = "react-dropzone@14.2.3"
+ library = "react-dropzone@14.2.10"
- tag = "ReactDropzone"
-
- is_default = True
+ tag = ""
# The list of accepted file types. This should be a dictionary of MIME types as keys and array of file formats as
# values.
@@ -200,7 +214,7 @@ class Upload(MemoizationLeaf):
min_size: Var[int]
# Whether to allow multiple files to be uploaded.
- multiple: Var[bool] = True # type: ignore
+ multiple: Var[bool]
# Whether to disable click to upload.
no_click: Var[bool]
@@ -231,6 +245,8 @@ class Upload(MemoizationLeaf):
# Mark the Upload component as used in the app.
cls.is_used = True
+ props.setdefault("multiple", True)
+
# Apply the default classname
given_class_name = props.pop("class_name", [])
if isinstance(given_class_name, str):
@@ -242,19 +258,6 @@ class Upload(MemoizationLeaf):
upload_props = {
key: value for key, value in props.items() if key in supported_props
}
- # The file input to use.
- upload = Input.create(type="file")
- upload.special_props = {
- BaseVar(_var_name="{...getInputProps()}", _var_type=None)
- }
-
- # The dropzone to use.
- zone = Box.create(
- upload,
- *children,
- **{k: v for k, v in props.items() if k not in supported_props},
- )
- zone.special_props = {BaseVar(_var_name="{...getRootProps()}", _var_type=None)}
# Create the component.
upload_props["id"] = props.get("id", DEFAULT_UPLOAD_ID)
@@ -276,9 +279,75 @@ class Upload(MemoizationLeaf):
),
)
upload_props["on_drop"] = on_drop
+
+ input_props_unique_name = get_unique_variable_name()
+ root_props_unique_name = get_unique_variable_name()
+
+ event_var, callback_str = StatefulComponent._get_memoized_event_triggers(
+ GhostUpload.create(on_drop=upload_props["on_drop"])
+ )["on_drop"]
+
+ upload_props["on_drop"] = event_var
+
+ upload_props = {
+ format.to_camel_case(key): value for key, value in upload_props.items()
+ }
+
+ use_dropzone_arguments = Var.create(
+ {
+ "onDrop": event_var,
+ **upload_props,
+ }
+ )
+
+ left_side = f"const {{getRootProps: {root_props_unique_name}, getInputProps: {input_props_unique_name}}} "
+ right_side = f"useDropzone({use_dropzone_arguments!s})"
+
+ var_data = VarData.merge(
+ VarData(
+ imports=Imports.EVENTS,
+ hooks={Hooks.EVENTS: None},
+ ),
+ event_var._get_all_var_data(),
+ use_dropzone_arguments._get_all_var_data(),
+ VarData(
+ hooks={
+ callback_str: None,
+ f"{left_side} = {right_side};": None,
+ },
+ imports={
+ "react-dropzone": "useDropzone",
+ **Imports.EVENTS,
+ },
+ ),
+ )
+
+ # The file input to use.
+ upload = Input.create(type="file")
+ upload.special_props = [
+ Var(
+ _js_expr=f"{{...{input_props_unique_name}()}}",
+ _var_type=None,
+ _var_data=var_data,
+ )
+ ]
+
+ # The dropzone to use.
+ zone = Box.create(
+ upload,
+ *children,
+ **{k: v for k, v in props.items() if k not in supported_props},
+ )
+ zone.special_props = [
+ Var(
+ _js_expr=f"{{...{root_props_unique_name}()}}",
+ _var_type=None,
+ _var_data=var_data,
+ )
+ ]
+
return super().create(
zone,
- **upload_props,
)
@classmethod
@@ -291,16 +360,11 @@ class Upload(MemoizationLeaf):
Returns:
The updated arg_value tuple when arg is "files", otherwise the original arg_value.
"""
- if arg_value[0]._var_name == "files":
+ if arg_value[0]._js_expr == "files":
placeholder = parse_args_spec(_on_drop_spec)[0]
return (arg_value[0], placeholder)
return arg_value
- def _render(self):
- out = super()._render()
- out.args = ("getRootProps", "getInputProps")
- return out
-
@staticmethod
def _get_app_wrap_components() -> dict[tuple[int, str], Component]:
return {
diff --git a/reflex/components/core/upload.pyi b/reflex/components/core/upload.pyi
index 54bb351de..6238ff9cb 100644
--- a/reflex/components/core/upload.pyi
+++ b/reflex/components/core/upload.pyi
@@ -4,30 +4,38 @@
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
from pathlib import Path
-from typing import Any, Callable, ClassVar, Dict, List, Optional, Union, overload
+from typing import Any, ClassVar, Dict, List, Optional, Union, overload
+from reflex.components.base.fragment import Fragment
from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
-from reflex.event import (
- CallableEventSpec,
- EventHandler,
- EventSpec,
-)
+from reflex.constants import Dirs
+from reflex.event import BASE_STATE, CallableEventSpec, EventSpec, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, CallableVar, Var, VarData
+from reflex.utils.imports import ImportVar
+from reflex.vars import VarData
+from reflex.vars.base import CallableVar, Var
DEFAULT_UPLOAD_ID: str
upload_files_context_var_data: VarData
@CallableVar
-def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar: ...
+def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var: ...
@CallableVar
-def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar: ...
+def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var: ...
@CallableEventSpec
def clear_selected_files(id_: str = DEFAULT_UPLOAD_ID) -> EventSpec: ...
def cancel_upload(upload_id: str) -> EventSpec: ...
def get_upload_dir() -> Path: ...
-uploaded_files_url_prefix: Var
+uploaded_files_url_prefix = Var(
+ _js_expr="getBackendURL(env.UPLOAD)",
+ _var_data=VarData(
+ imports={
+ f"$/{Dirs.STATE_PATH}": "getBackendURL",
+ "$/env.json": ImportVar(tag="env", is_default=True),
+ }
+ ),
+).to(str)
def get_upload_url(file_path: str) -> Var[str]: ...
@@ -42,52 +50,22 @@ class UploadFilesProvider(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "UploadFilesProvider":
"""Create the component.
@@ -107,6 +85,56 @@ class UploadFilesProvider(Component):
"""
...
+class GhostUpload(Fragment):
+ @overload
+ @classmethod
+ def create( # type: ignore
+ cls,
+ *children,
+ style: Optional[Style] = None,
+ key: Optional[Any] = None,
+ id: Optional[Any] = None,
+ class_name: Optional[Any] = None,
+ autofocus: Optional[bool] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_drop: Optional[
+ Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]]
+ ] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
+ **props,
+ ) -> "GhostUpload":
+ """Create the component.
+
+ Args:
+ *children: The children of the component.
+ on_drop: Fired when files are dropped.
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: The props of the component.
+
+ Returns:
+ The component.
+ """
+ ...
+
class Upload(MemoizationLeaf):
is_used: ClassVar[bool] = False
@@ -115,7 +143,7 @@ class Upload(MemoizationLeaf):
def create( # type: ignore
cls,
*children,
- accept: Optional[Union[Var[Optional[Dict[str, List]]], Dict[str, List]]] = None,
+ accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
max_files: Optional[Union[Var[int], int]] = None,
max_size: Optional[Union[Var[int], int]] = None,
@@ -129,55 +157,25 @@ class Upload(MemoizationLeaf):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
on_drop: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]]
] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Upload":
"""Create an upload component.
@@ -193,6 +191,7 @@ class Upload(MemoizationLeaf):
no_click: Whether to disable click to upload.
no_drag: Whether to disable drag and drop.
no_keyboard: Whether to disable using the space/enter keys to upload.
+ on_drop: Fired when files are dropped.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -212,7 +211,7 @@ class StyledUpload(Upload):
def create( # type: ignore
cls,
*children,
- accept: Optional[Union[Var[Optional[Dict[str, List]]], Dict[str, List]]] = None,
+ accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
max_files: Optional[Union[Var[int], int]] = None,
max_size: Optional[Union[Var[int], int]] = None,
@@ -226,55 +225,25 @@ class StyledUpload(Upload):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
on_drop: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]]
] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "StyledUpload":
"""Create the styled upload component.
@@ -290,6 +259,7 @@ class StyledUpload(Upload):
no_click: Whether to disable click to upload.
no_drag: Whether to disable drag and drop.
no_keyboard: Whether to disable using the space/enter keys to upload.
+ on_drop: Fired when files are dropped.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -309,7 +279,7 @@ class UploadNamespace(ComponentNamespace):
@staticmethod
def __call__(
*children,
- accept: Optional[Union[Var[Optional[Dict[str, List]]], Dict[str, List]]] = None,
+ accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
max_files: Optional[Union[Var[int], int]] = None,
max_size: Optional[Union[Var[int], int]] = None,
@@ -323,55 +293,25 @@ class UploadNamespace(ComponentNamespace):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
on_drop: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]]
] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "StyledUpload":
"""Create the styled upload component.
@@ -387,6 +327,7 @@ class UploadNamespace(ComponentNamespace):
no_click: Whether to disable click to upload.
no_drag: Whether to disable drag and drop.
no_keyboard: Whether to disable using the space/enter keys to upload.
+ on_drop: Fired when files are dropped.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/datadisplay/__init__.py b/reflex/components/datadisplay/__init__.py
index fe613ee52..1aff69676 100644
--- a/reflex/components/datadisplay/__init__.py
+++ b/reflex/components/datadisplay/__init__.py
@@ -8,7 +8,6 @@ _SUBMOD_ATTRS: dict[str, list[str]] = {
"code": [
"CodeBlock",
"code_block",
- "LiteralCodeBlockTheme",
"LiteralCodeLanguage",
],
"dataeditor": ["data_editor", "data_editor_theme", "DataEditorTheme"],
diff --git a/reflex/components/datadisplay/__init__.pyi b/reflex/components/datadisplay/__init__.pyi
index 4882c83df..32b29d106 100644
--- a/reflex/components/datadisplay/__init__.pyi
+++ b/reflex/components/datadisplay/__init__.pyi
@@ -4,7 +4,6 @@
# ------------------------------------------------------
from .code import CodeBlock as CodeBlock
-from .code import LiteralCodeBlockTheme as LiteralCodeBlockTheme
from .code import LiteralCodeLanguage as LiteralCodeLanguage
from .code import code_block as code_block
from .dataeditor import DataEditorTheme as DataEditorTheme
diff --git a/reflex/components/datadisplay/code.py b/reflex/components/datadisplay/code.py
index 47cba3736..2d5dfc625 100644
--- a/reflex/components/datadisplay/code.py
+++ b/reflex/components/datadisplay/code.py
@@ -2,69 +2,21 @@
from __future__ import annotations
-import re
-from typing import Dict, Literal, Optional, Union
+import dataclasses
+from typing import ClassVar, Dict, Literal, Optional, Union
-from reflex.components.component import Component
+from reflex.components.component import Component, ComponentNamespace
from reflex.components.core.cond import color_mode_cond
from reflex.components.lucide.icon import Icon
+from reflex.components.markdown.markdown import _LANGUAGE, MarkdownComponentMap
from reflex.components.radix.themes.components.button import Button
from reflex.components.radix.themes.layout.box import Box
from reflex.constants.colors import Color
from reflex.event import set_clipboard
from reflex.style import Style
-from reflex.utils import format
-from reflex.utils.imports import ImportDict, ImportVar
-from reflex.vars import Var
-
-LiteralCodeBlockTheme = Literal[
- "a11y-dark",
- "atom-dark",
- "cb",
- "coldark-cold",
- "coldark-dark",
- "coy",
- "coy-without-shadows",
- "darcula",
- "dark",
- "dracula",
- "duotone-dark",
- "duotone-earth",
- "duotone-forest",
- "duotone-light",
- "duotone-sea",
- "duotone-space",
- "funky",
- "ghcolors",
- "gruvbox-dark",
- "gruvbox-light",
- "holi-theme",
- "hopscotch",
- "light", # not present in react-syntax-highlighter styles
- "lucario",
- "material-dark",
- "material-light",
- "material-oceanic",
- "night-owl",
- "nord",
- "okaidia",
- "one-dark",
- "one-light",
- "pojoaque",
- "prism",
- "shades-of-purple",
- "solarized-dark-atom",
- "solarizedlight",
- "synthwave84",
- "tomorrow",
- "twilight",
- "vs",
- "vs-dark",
- "vsc-dark-plus",
- "xonokai",
- "z-touch",
-]
-
+from reflex.utils import console, format
+from reflex.utils.imports import ImportVar
+from reflex.vars.base import LiteralVar, Var, VarData
LiteralCodeLanguage = Literal[
"abap",
@@ -349,20 +301,98 @@ LiteralCodeLanguage = Literal[
]
-class CodeBlock(Component):
+def construct_theme_var(theme: str) -> Var[Theme]:
+ """Construct a theme var.
+
+ Args:
+ theme: The theme to construct.
+
+ Returns:
+ The constructed theme var.
+ """
+ return Var(
+ theme,
+ _var_data=VarData(
+ imports={
+ f"react-syntax-highlighter/dist/cjs/styles/prism/{format.to_kebab_case(theme)}": [
+ ImportVar(tag=theme, is_default=True, install=False)
+ ]
+ }
+ ),
+ )
+
+
+@dataclasses.dataclass(init=False)
+class Theme:
+ """Themes for the CodeBlock component."""
+
+ a11y_dark: ClassVar[Var[Theme]] = construct_theme_var("a11yDark")
+ atom_dark: ClassVar[Var[Theme]] = construct_theme_var("atomDark")
+ cb: ClassVar[Var[Theme]] = construct_theme_var("cb")
+ coldark_cold: ClassVar[Var[Theme]] = construct_theme_var("coldarkCold")
+ coldark_dark: ClassVar[Var[Theme]] = construct_theme_var("coldarkDark")
+ coy: ClassVar[Var[Theme]] = construct_theme_var("coy")
+ coy_without_shadows: ClassVar[Var[Theme]] = construct_theme_var("coyWithoutShadows")
+ darcula: ClassVar[Var[Theme]] = construct_theme_var("darcula")
+ dark: ClassVar[Var[Theme]] = construct_theme_var("oneDark")
+ dracula: ClassVar[Var[Theme]] = construct_theme_var("dracula")
+ duotone_dark: ClassVar[Var[Theme]] = construct_theme_var("duotoneDark")
+ duotone_earth: ClassVar[Var[Theme]] = construct_theme_var("duotoneEarth")
+ duotone_forest: ClassVar[Var[Theme]] = construct_theme_var("duotoneForest")
+ duotone_light: ClassVar[Var[Theme]] = construct_theme_var("duotoneLight")
+ duotone_sea: ClassVar[Var[Theme]] = construct_theme_var("duotoneSea")
+ duotone_space: ClassVar[Var[Theme]] = construct_theme_var("duotoneSpace")
+ funky: ClassVar[Var[Theme]] = construct_theme_var("funky")
+ ghcolors: ClassVar[Var[Theme]] = construct_theme_var("ghcolors")
+ gruvbox_dark: ClassVar[Var[Theme]] = construct_theme_var("gruvboxDark")
+ gruvbox_light: ClassVar[Var[Theme]] = construct_theme_var("gruvboxLight")
+ holi_theme: ClassVar[Var[Theme]] = construct_theme_var("holiTheme")
+ hopscotch: ClassVar[Var[Theme]] = construct_theme_var("hopscotch")
+ light: ClassVar[Var[Theme]] = construct_theme_var("oneLight")
+ lucario: ClassVar[Var[Theme]] = construct_theme_var("lucario")
+ material_dark: ClassVar[Var[Theme]] = construct_theme_var("materialDark")
+ material_light: ClassVar[Var[Theme]] = construct_theme_var("materialLight")
+ material_oceanic: ClassVar[Var[Theme]] = construct_theme_var("materialOceanic")
+ night_owl: ClassVar[Var[Theme]] = construct_theme_var("nightOwl")
+ nord: ClassVar[Var[Theme]] = construct_theme_var("nord")
+ okaidia: ClassVar[Var[Theme]] = construct_theme_var("okaidia")
+ one_dark: ClassVar[Var[Theme]] = construct_theme_var("oneDark")
+ one_light: ClassVar[Var[Theme]] = construct_theme_var("oneLight")
+ pojoaque: ClassVar[Var[Theme]] = construct_theme_var("pojoaque")
+ prism: ClassVar[Var[Theme]] = construct_theme_var("prism")
+ shades_of_purple: ClassVar[Var[Theme]] = construct_theme_var("shadesOfPurple")
+ solarized_dark_atom: ClassVar[Var[Theme]] = construct_theme_var("solarizedDarkAtom")
+ solarizedlight: ClassVar[Var[Theme]] = construct_theme_var("solarizedlight")
+ synthwave84: ClassVar[Var[Theme]] = construct_theme_var("synthwave84")
+ tomorrow: ClassVar[Var[Theme]] = construct_theme_var("tomorrow")
+ twilight: ClassVar[Var[Theme]] = construct_theme_var("twilight")
+ vs: ClassVar[Var[Theme]] = construct_theme_var("vs")
+ vs_dark: ClassVar[Var[Theme]] = construct_theme_var("vsDark")
+ vsc_dark_plus: ClassVar[Var[Theme]] = construct_theme_var("vscDarkPlus")
+ xonokai: ClassVar[Var[Theme]] = construct_theme_var("xonokai")
+ z_touch: ClassVar[Var[Theme]] = construct_theme_var("zTouch")
+
+
+for theme_name in dir(Theme):
+ if theme_name.startswith("_"):
+ continue
+ setattr(Theme, theme_name, getattr(Theme, theme_name)._replace(_var_type=Theme))
+
+
+class CodeBlock(Component, MarkdownComponentMap):
"""A code block."""
- library = "react-syntax-highlighter@15.5.0"
+ library = "react-syntax-highlighter@15.6.0"
tag = "PrismAsyncLight"
alias = "SyntaxHighlighter"
# The theme to use ("light" or "dark").
- theme: Var[LiteralCodeBlockTheme] = "one-light" # type: ignore
+ theme: Var[Union[Theme, str]] = Theme.one_light
# The language to use.
- language: Var[LiteralCodeLanguage] = "python" # type: ignore
+ language: Var[LiteralCodeLanguage] = Var.create("python")
# The code to display.
code: Var[str]
@@ -382,67 +412,22 @@ class CodeBlock(Component):
# Props passed down to the code tag.
code_tag_props: Var[Dict[str, str]]
- def add_imports(self) -> ImportDict:
- """Add imports for the CodeBlock component.
+ # Whether a copy button should appear.
+ can_copy: Optional[bool] = False
- Returns:
- The import dict.
- """
- imports_: ImportDict = {}
- themes = re.findall(r"`(.*?)`", self.theme._var_name)
- if not themes:
- themes = [self.theme._var_name]
-
- imports_.update(
- {
- f"react-syntax-highlighter/dist/cjs/styles/prism/{self.convert_theme_name(theme)}": [
- ImportVar(
- tag=format.to_camel_case(self.convert_theme_name(theme)),
- is_default=True,
- install=False,
- )
- ]
- for theme in themes
- }
- )
-
- if (
- self.language is not None
- and self.language._var_name in LiteralCodeLanguage.__args__ # type: ignore
- ):
- imports_[
- f"react-syntax-highlighter/dist/cjs/languages/prism/{self.language._var_name}"
- ] = [
- ImportVar(
- tag=format.to_camel_case(self.language._var_name),
- is_default=True,
- install=False,
- )
- ]
-
- return imports_
-
- def _get_custom_code(self) -> Optional[str]:
- if (
- self.language is not None
- and self.language._var_name in LiteralCodeLanguage.__args__ # type: ignore
- ):
- return f"{self.alias}.registerLanguage('{self.language._var_name}', {format.to_camel_case(self.language._var_name)})"
+ # A custom copy button to override the default one.
+ copy_button: Optional[Union[bool, Component]] = None
@classmethod
def create(
cls,
*children,
- can_copy: Optional[bool] = False,
- copy_button: Optional[Union[bool, Component]] = None,
**props,
):
"""Create a text component.
Args:
*children: The children of the component.
- can_copy: Whether a copy button should appears.
- copy_button: A custom copy button to override the default one.
**props: The props to pass to the component.
Returns:
@@ -450,15 +435,26 @@ class CodeBlock(Component):
"""
# This component handles style in a special prop.
custom_style = props.pop("custom_style", {})
+ can_copy = props.pop("can_copy", False)
+ copy_button = props.pop("copy_button", None)
if "theme" not in props:
# Default color scheme responds to global color mode.
- props["theme"] = color_mode_cond(light="one-light", dark="one-dark")
+ props["theme"] = color_mode_cond(
+ light=Theme.one_light,
+ dark=Theme.one_dark,
+ )
- # react-syntax-highlighter doesnt have an explicit "light" or "dark" theme so we use one-light and one-dark
+ # react-syntax-highlighter doesn't have an explicit "light" or "dark" theme so we use one-light and one-dark
# themes respectively to ensure code compatibility.
if "theme" in props and not isinstance(props["theme"], Var):
- props["theme"] = cls.convert_theme_name(props["theme"])
+ props["theme"] = getattr(Theme, format.to_snake_case(props["theme"])) # type: ignore
+ console.deprecate(
+ feature_name="theme prop as string",
+ reason="Use code_block.themes instead.",
+ deprecation_version="0.6.0",
+ removal_version="0.7.0",
+ )
if can_copy:
code = children[0]
@@ -484,7 +480,7 @@ class CodeBlock(Component):
if children:
props["code"] = children[0]
if not isinstance(props["code"], Var):
- props["code"] = Var.create(props["code"], _var_is_string=True)
+ props["code"] = LiteralVar.create(props["code"])
# Create the component.
code_block = super().create(
@@ -503,33 +499,65 @@ class CodeBlock(Component):
def _render(self):
out = super()._render()
- predicate, qmark, value = self.theme._var_name.partition("?")
- out.add_props(
- style=Var.create(
- format.to_camel_case(f"{predicate}{qmark}{value.replace('`', '')}"),
- _var_is_local=False,
- _var_is_string=False,
- )
- ).remove_props("theme", "code")
- if self.code is not None:
- out.special_props.add(
- Var.create_safe(f"children={str(self.code)}", _var_is_string=False)
- )
+
+ theme = self.theme
+
+ out.add_props(style=theme).remove_props("theme", "code", "language").add_props(
+ children=self.code, language=_LANGUAGE
+ )
+
return out
- @staticmethod
- def convert_theme_name(theme) -> str:
- """Convert theme names to appropriate names.
+ def _exclude_props(self) -> list[str]:
+ return ["can_copy", "copy_button"]
- Args:
- theme: The theme name.
+ @classmethod
+ def _get_language_registration_hook(cls) -> str:
+ """Get the hook to register the language.
Returns:
- The right theme name.
+ The hook to register the language.
"""
- if theme in ["light", "dark"]:
- return f"one-{theme}"
- return theme
+ return f"""
+ if ({_LANGUAGE!s}) {{
+ (async () => {{
+ try {{
+ const module = await import(`react-syntax-highlighter/dist/cjs/languages/prism/${{{_LANGUAGE!s}}}`);
+ SyntaxHighlighter.registerLanguage({_LANGUAGE!s}, module.default);
+ }} catch (error) {{
+ console.error(`Error importing language module for ${{{_LANGUAGE!s}}}:`, error);
+ }}
+ }})();
+ }}
+"""
+
+ @classmethod
+ def get_component_map_custom_code(cls) -> str:
+ """Get the custom code for the component.
+
+ Returns:
+ The custom code for the component.
+ """
+ return cls._get_language_registration_hook()
+
+ def add_hooks(self) -> list[str | Var]:
+ """Add hooks for the component.
+
+ Returns:
+ The hooks for the component.
+ """
+ return [
+ f"const {_LANGUAGE!s} = {self.language!s}",
+ self._get_language_registration_hook(),
+ ]
-code_block = CodeBlock.create
+class CodeblockNamespace(ComponentNamespace):
+ """Namespace for the CodeBlock component."""
+
+ themes = Theme
+
+ __call__ = CodeBlock.create
+
+
+code_block = CodeblockNamespace()
diff --git a/reflex/components/datadisplay/code.pyi b/reflex/components/datadisplay/code.pyi
index a60838b8e..da89195ce 100644
--- a/reflex/components/datadisplay/code.pyi
+++ b/reflex/components/datadisplay/code.pyi
@@ -3,62 +3,16 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+import dataclasses
+from typing import Any, ClassVar, Dict, Literal, Optional, Union, overload
-from reflex.components.component import Component
+from reflex.components.component import Component, ComponentNamespace
+from reflex.components.markdown.markdown import MarkdownComponentMap
from reflex.constants.colors import Color
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.utils.imports import ImportDict
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
-LiteralCodeBlockTheme = Literal[
- "a11y-dark",
- "atom-dark",
- "cb",
- "coldark-cold",
- "coldark-dark",
- "coy",
- "coy-without-shadows",
- "darcula",
- "dark",
- "dracula",
- "duotone-dark",
- "duotone-earth",
- "duotone-forest",
- "duotone-light",
- "duotone-sea",
- "duotone-space",
- "funky",
- "ghcolors",
- "gruvbox-dark",
- "gruvbox-light",
- "holi-theme",
- "hopscotch",
- "light",
- "lucario",
- "material-dark",
- "material-light",
- "material-oceanic",
- "night-owl",
- "nord",
- "okaidia",
- "one-dark",
- "one-light",
- "pojoaque",
- "prism",
- "shades-of-purple",
- "solarized-dark-atom",
- "solarizedlight",
- "synthwave84",
- "tomorrow",
- "twilight",
- "vs",
- "vs-dark",
- "vsc-dark-plus",
- "xonokai",
- "z-touch",
-]
LiteralCodeLanguage = Literal[
"abap",
"abnf",
@@ -341,117 +295,350 @@ LiteralCodeLanguage = Literal[
"zig",
]
-class CodeBlock(Component):
- def add_imports(self) -> ImportDict: ...
+def construct_theme_var(theme: str) -> Var[Theme]: ...
+@dataclasses.dataclass(init=False)
+class Theme:
+ a11y_dark: ClassVar[Var[Theme]] = construct_theme_var("a11yDark")
+ atom_dark: ClassVar[Var[Theme]] = construct_theme_var("atomDark")
+ cb: ClassVar[Var[Theme]] = construct_theme_var("cb")
+ coldark_cold: ClassVar[Var[Theme]] = construct_theme_var("coldarkCold")
+ coldark_dark: ClassVar[Var[Theme]] = construct_theme_var("coldarkDark")
+ coy: ClassVar[Var[Theme]] = construct_theme_var("coy")
+ coy_without_shadows: ClassVar[Var[Theme]] = construct_theme_var("coyWithoutShadows")
+ darcula: ClassVar[Var[Theme]] = construct_theme_var("darcula")
+ dark: ClassVar[Var[Theme]] = construct_theme_var("oneDark")
+ dracula: ClassVar[Var[Theme]] = construct_theme_var("dracula")
+ duotone_dark: ClassVar[Var[Theme]] = construct_theme_var("duotoneDark")
+ duotone_earth: ClassVar[Var[Theme]] = construct_theme_var("duotoneEarth")
+ duotone_forest: ClassVar[Var[Theme]] = construct_theme_var("duotoneForest")
+ duotone_light: ClassVar[Var[Theme]] = construct_theme_var("duotoneLight")
+ duotone_sea: ClassVar[Var[Theme]] = construct_theme_var("duotoneSea")
+ duotone_space: ClassVar[Var[Theme]] = construct_theme_var("duotoneSpace")
+ funky: ClassVar[Var[Theme]] = construct_theme_var("funky")
+ ghcolors: ClassVar[Var[Theme]] = construct_theme_var("ghcolors")
+ gruvbox_dark: ClassVar[Var[Theme]] = construct_theme_var("gruvboxDark")
+ gruvbox_light: ClassVar[Var[Theme]] = construct_theme_var("gruvboxLight")
+ holi_theme: ClassVar[Var[Theme]] = construct_theme_var("holiTheme")
+ hopscotch: ClassVar[Var[Theme]] = construct_theme_var("hopscotch")
+ light: ClassVar[Var[Theme]] = construct_theme_var("oneLight")
+ lucario: ClassVar[Var[Theme]] = construct_theme_var("lucario")
+ material_dark: ClassVar[Var[Theme]] = construct_theme_var("materialDark")
+ material_light: ClassVar[Var[Theme]] = construct_theme_var("materialLight")
+ material_oceanic: ClassVar[Var[Theme]] = construct_theme_var("materialOceanic")
+ night_owl: ClassVar[Var[Theme]] = construct_theme_var("nightOwl")
+ nord: ClassVar[Var[Theme]] = construct_theme_var("nord")
+ okaidia: ClassVar[Var[Theme]] = construct_theme_var("okaidia")
+ one_dark: ClassVar[Var[Theme]] = construct_theme_var("oneDark")
+ one_light: ClassVar[Var[Theme]] = construct_theme_var("oneLight")
+ pojoaque: ClassVar[Var[Theme]] = construct_theme_var("pojoaque")
+ prism: ClassVar[Var[Theme]] = construct_theme_var("prism")
+ shades_of_purple: ClassVar[Var[Theme]] = construct_theme_var("shadesOfPurple")
+ solarized_dark_atom: ClassVar[Var[Theme]] = construct_theme_var("solarizedDarkAtom")
+ solarizedlight: ClassVar[Var[Theme]] = construct_theme_var("solarizedlight")
+ synthwave84: ClassVar[Var[Theme]] = construct_theme_var("synthwave84")
+ tomorrow: ClassVar[Var[Theme]] = construct_theme_var("tomorrow")
+ twilight: ClassVar[Var[Theme]] = construct_theme_var("twilight")
+ vs: ClassVar[Var[Theme]] = construct_theme_var("vs")
+ vs_dark: ClassVar[Var[Theme]] = construct_theme_var("vsDark")
+ vsc_dark_plus: ClassVar[Var[Theme]] = construct_theme_var("vscDarkPlus")
+ xonokai: ClassVar[Var[Theme]] = construct_theme_var("xonokai")
+ z_touch: ClassVar[Var[Theme]] = construct_theme_var("zTouch")
+
+for theme_name in dir(Theme):
+ if theme_name.startswith("_"):
+ continue
+ setattr(Theme, theme_name, getattr(Theme, theme_name)._replace(_var_type=Theme))
+
+class CodeBlock(Component, MarkdownComponentMap):
@overload
@classmethod
def create( # type: ignore
cls,
*children,
- can_copy: Optional[bool] = False,
- copy_button: Optional[Union[Component, bool]] = None,
- theme: Optional[
- Union[
- Var[
- Literal[
- "a11y-dark",
- "atom-dark",
- "cb",
- "coldark-cold",
- "coldark-dark",
- "coy",
- "coy-without-shadows",
- "darcula",
- "dark",
- "dracula",
- "duotone-dark",
- "duotone-earth",
- "duotone-forest",
- "duotone-light",
- "duotone-sea",
- "duotone-space",
- "funky",
- "ghcolors",
- "gruvbox-dark",
- "gruvbox-light",
- "holi-theme",
- "hopscotch",
- "light",
- "lucario",
- "material-dark",
- "material-light",
- "material-oceanic",
- "night-owl",
- "nord",
- "okaidia",
- "one-dark",
- "one-light",
- "pojoaque",
- "prism",
- "shades-of-purple",
- "solarized-dark-atom",
- "solarizedlight",
- "synthwave84",
- "tomorrow",
- "twilight",
- "vs",
- "vs-dark",
- "vsc-dark-plus",
- "xonokai",
- "z-touch",
- ]
- ],
- Literal[
- "a11y-dark",
- "atom-dark",
- "cb",
- "coldark-cold",
- "coldark-dark",
- "coy",
- "coy-without-shadows",
- "darcula",
- "dark",
- "dracula",
- "duotone-dark",
- "duotone-earth",
- "duotone-forest",
- "duotone-light",
- "duotone-sea",
- "duotone-space",
- "funky",
- "ghcolors",
- "gruvbox-dark",
- "gruvbox-light",
- "holi-theme",
- "hopscotch",
- "light",
- "lucario",
- "material-dark",
- "material-light",
- "material-oceanic",
- "night-owl",
- "nord",
- "okaidia",
- "one-dark",
- "one-light",
- "pojoaque",
- "prism",
- "shades-of-purple",
- "solarized-dark-atom",
- "solarizedlight",
- "synthwave84",
- "tomorrow",
- "twilight",
- "vs",
- "vs-dark",
- "vsc-dark-plus",
- "xonokai",
- "z-touch",
- ],
- ]
- ] = None,
+ theme: Optional[Union[Theme, Var[Union[Theme, str]], str]] = None,
language: Optional[
Union[
+ Literal[
+ "abap",
+ "abnf",
+ "actionscript",
+ "ada",
+ "agda",
+ "al",
+ "antlr4",
+ "apacheconf",
+ "apex",
+ "apl",
+ "applescript",
+ "aql",
+ "arduino",
+ "arff",
+ "asciidoc",
+ "asm6502",
+ "asmatmel",
+ "aspnet",
+ "autohotkey",
+ "autoit",
+ "avisynth",
+ "avro-idl",
+ "bash",
+ "basic",
+ "batch",
+ "bbcode",
+ "bicep",
+ "birb",
+ "bison",
+ "bnf",
+ "brainfuck",
+ "brightscript",
+ "bro",
+ "bsl",
+ "c",
+ "cfscript",
+ "chaiscript",
+ "cil",
+ "clike",
+ "clojure",
+ "cmake",
+ "cobol",
+ "coffeescript",
+ "concurnas",
+ "coq",
+ "core",
+ "cpp",
+ "crystal",
+ "csharp",
+ "cshtml",
+ "csp",
+ "css",
+ "css-extras",
+ "csv",
+ "cypher",
+ "d",
+ "dart",
+ "dataweave",
+ "dax",
+ "dhall",
+ "diff",
+ "django",
+ "dns-zone-file",
+ "docker",
+ "dot",
+ "ebnf",
+ "editorconfig",
+ "eiffel",
+ "ejs",
+ "elixir",
+ "elm",
+ "erb",
+ "erlang",
+ "etlua",
+ "excel-formula",
+ "factor",
+ "false",
+ "firestore-security-rules",
+ "flow",
+ "fortran",
+ "fsharp",
+ "ftl",
+ "gap",
+ "gcode",
+ "gdscript",
+ "gedcom",
+ "gherkin",
+ "git",
+ "glsl",
+ "gml",
+ "gn",
+ "go",
+ "go-module",
+ "graphql",
+ "groovy",
+ "haml",
+ "handlebars",
+ "haskell",
+ "haxe",
+ "hcl",
+ "hlsl",
+ "hoon",
+ "hpkp",
+ "hsts",
+ "http",
+ "ichigojam",
+ "icon",
+ "icu-message-format",
+ "idris",
+ "iecst",
+ "ignore",
+ "index",
+ "inform7",
+ "ini",
+ "io",
+ "j",
+ "java",
+ "javadoc",
+ "javadoclike",
+ "javascript",
+ "javastacktrace",
+ "jexl",
+ "jolie",
+ "jq",
+ "js-extras",
+ "js-templates",
+ "jsdoc",
+ "json",
+ "json5",
+ "jsonp",
+ "jsstacktrace",
+ "jsx",
+ "julia",
+ "keepalived",
+ "keyman",
+ "kotlin",
+ "kumir",
+ "kusto",
+ "latex",
+ "latte",
+ "less",
+ "lilypond",
+ "liquid",
+ "lisp",
+ "livescript",
+ "llvm",
+ "log",
+ "lolcode",
+ "lua",
+ "magma",
+ "makefile",
+ "markdown",
+ "markup",
+ "markup-templating",
+ "matlab",
+ "maxscript",
+ "mel",
+ "mermaid",
+ "mizar",
+ "mongodb",
+ "monkey",
+ "moonscript",
+ "n1ql",
+ "n4js",
+ "nand2tetris-hdl",
+ "naniscript",
+ "nasm",
+ "neon",
+ "nevod",
+ "nginx",
+ "nim",
+ "nix",
+ "nsis",
+ "objectivec",
+ "ocaml",
+ "opencl",
+ "openqasm",
+ "oz",
+ "parigp",
+ "parser",
+ "pascal",
+ "pascaligo",
+ "pcaxis",
+ "peoplecode",
+ "perl",
+ "php",
+ "php-extras",
+ "phpdoc",
+ "plsql",
+ "powerquery",
+ "powershell",
+ "processing",
+ "prolog",
+ "promql",
+ "properties",
+ "protobuf",
+ "psl",
+ "pug",
+ "puppet",
+ "pure",
+ "purebasic",
+ "purescript",
+ "python",
+ "q",
+ "qml",
+ "qore",
+ "qsharp",
+ "r",
+ "racket",
+ "reason",
+ "regex",
+ "rego",
+ "renpy",
+ "rest",
+ "rip",
+ "roboconf",
+ "robotframework",
+ "ruby",
+ "rust",
+ "sas",
+ "sass",
+ "scala",
+ "scheme",
+ "scss",
+ "shell-session",
+ "smali",
+ "smalltalk",
+ "smarty",
+ "sml",
+ "solidity",
+ "solution-file",
+ "soy",
+ "sparql",
+ "splunk-spl",
+ "sqf",
+ "sql",
+ "squirrel",
+ "stan",
+ "stylus",
+ "swift",
+ "systemd",
+ "t4-cs",
+ "t4-templating",
+ "t4-vb",
+ "tap",
+ "tcl",
+ "textile",
+ "toml",
+ "tremor",
+ "tsx",
+ "tt2",
+ "turtle",
+ "twig",
+ "typescript",
+ "typoscript",
+ "unrealscript",
+ "uorazor",
+ "uri",
+ "v",
+ "vala",
+ "vbnet",
+ "velocity",
+ "verilog",
+ "vhdl",
+ "vim",
+ "visual-basic",
+ "warpscript",
+ "wasm",
+ "web-idl",
+ "wiki",
+ "wolfram",
+ "wren",
+ "xeora",
+ "xml-doc",
+ "xojo",
+ "xquery",
+ "yaml",
+ "yang",
+ "zig",
+ ],
Var[
Literal[
"abap",
@@ -735,6 +922,80 @@ class CodeBlock(Component):
"zig",
]
],
+ ]
+ ] = None,
+ code: Optional[Union[Var[str], str]] = None,
+ show_line_numbers: Optional[Union[Var[bool], bool]] = None,
+ starting_line_number: Optional[Union[Var[int], int]] = None,
+ wrap_long_lines: Optional[Union[Var[bool], bool]] = None,
+ custom_style: Optional[Dict[str, Union[str, Var, Color]]] = None,
+ code_tag_props: Optional[Union[Dict[str, str], Var[Dict[str, str]]]] = None,
+ can_copy: Optional[bool] = None,
+ copy_button: Optional[Union[Component, bool]] = None,
+ style: Optional[Style] = None,
+ key: Optional[Any] = None,
+ id: Optional[Any] = None,
+ class_name: Optional[Any] = None,
+ autofocus: Optional[bool] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
+ **props,
+ ) -> "CodeBlock":
+ """Create a text component.
+
+ Args:
+ *children: The children of the component.
+ theme: The theme to use ("light" or "dark").
+ language: The language to use.
+ code: The code to display.
+ show_line_numbers: If this is enabled line numbers will be shown next to the code block.
+ starting_line_number: The starting line number to use.
+ wrap_long_lines: Whether to wrap long lines.
+ custom_style: A custom style for the code block.
+ code_tag_props: Props passed down to the code tag.
+ can_copy: Whether a copy button should appear.
+ copy_button: A custom copy button to override the default one.
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: The props to pass to the component.
+
+ Returns:
+ The text component.
+ """
+ ...
+
+ def add_style(self): ...
+ @classmethod
+ def get_component_map_custom_code(cls) -> str: ...
+ def add_hooks(self) -> list[str | Var]: ...
+
+class CodeblockNamespace(ComponentNamespace):
+ themes = Theme
+
+ @staticmethod
+ def __call__(
+ *children,
+ theme: Optional[Union[Theme, Var[Union[Theme, str]], str]] = None,
+ language: Optional[
+ Union[
Literal[
"abap",
"abnf",
@@ -1016,6 +1277,289 @@ class CodeBlock(Component):
"yang",
"zig",
],
+ Var[
+ Literal[
+ "abap",
+ "abnf",
+ "actionscript",
+ "ada",
+ "agda",
+ "al",
+ "antlr4",
+ "apacheconf",
+ "apex",
+ "apl",
+ "applescript",
+ "aql",
+ "arduino",
+ "arff",
+ "asciidoc",
+ "asm6502",
+ "asmatmel",
+ "aspnet",
+ "autohotkey",
+ "autoit",
+ "avisynth",
+ "avro-idl",
+ "bash",
+ "basic",
+ "batch",
+ "bbcode",
+ "bicep",
+ "birb",
+ "bison",
+ "bnf",
+ "brainfuck",
+ "brightscript",
+ "bro",
+ "bsl",
+ "c",
+ "cfscript",
+ "chaiscript",
+ "cil",
+ "clike",
+ "clojure",
+ "cmake",
+ "cobol",
+ "coffeescript",
+ "concurnas",
+ "coq",
+ "core",
+ "cpp",
+ "crystal",
+ "csharp",
+ "cshtml",
+ "csp",
+ "css",
+ "css-extras",
+ "csv",
+ "cypher",
+ "d",
+ "dart",
+ "dataweave",
+ "dax",
+ "dhall",
+ "diff",
+ "django",
+ "dns-zone-file",
+ "docker",
+ "dot",
+ "ebnf",
+ "editorconfig",
+ "eiffel",
+ "ejs",
+ "elixir",
+ "elm",
+ "erb",
+ "erlang",
+ "etlua",
+ "excel-formula",
+ "factor",
+ "false",
+ "firestore-security-rules",
+ "flow",
+ "fortran",
+ "fsharp",
+ "ftl",
+ "gap",
+ "gcode",
+ "gdscript",
+ "gedcom",
+ "gherkin",
+ "git",
+ "glsl",
+ "gml",
+ "gn",
+ "go",
+ "go-module",
+ "graphql",
+ "groovy",
+ "haml",
+ "handlebars",
+ "haskell",
+ "haxe",
+ "hcl",
+ "hlsl",
+ "hoon",
+ "hpkp",
+ "hsts",
+ "http",
+ "ichigojam",
+ "icon",
+ "icu-message-format",
+ "idris",
+ "iecst",
+ "ignore",
+ "index",
+ "inform7",
+ "ini",
+ "io",
+ "j",
+ "java",
+ "javadoc",
+ "javadoclike",
+ "javascript",
+ "javastacktrace",
+ "jexl",
+ "jolie",
+ "jq",
+ "js-extras",
+ "js-templates",
+ "jsdoc",
+ "json",
+ "json5",
+ "jsonp",
+ "jsstacktrace",
+ "jsx",
+ "julia",
+ "keepalived",
+ "keyman",
+ "kotlin",
+ "kumir",
+ "kusto",
+ "latex",
+ "latte",
+ "less",
+ "lilypond",
+ "liquid",
+ "lisp",
+ "livescript",
+ "llvm",
+ "log",
+ "lolcode",
+ "lua",
+ "magma",
+ "makefile",
+ "markdown",
+ "markup",
+ "markup-templating",
+ "matlab",
+ "maxscript",
+ "mel",
+ "mermaid",
+ "mizar",
+ "mongodb",
+ "monkey",
+ "moonscript",
+ "n1ql",
+ "n4js",
+ "nand2tetris-hdl",
+ "naniscript",
+ "nasm",
+ "neon",
+ "nevod",
+ "nginx",
+ "nim",
+ "nix",
+ "nsis",
+ "objectivec",
+ "ocaml",
+ "opencl",
+ "openqasm",
+ "oz",
+ "parigp",
+ "parser",
+ "pascal",
+ "pascaligo",
+ "pcaxis",
+ "peoplecode",
+ "perl",
+ "php",
+ "php-extras",
+ "phpdoc",
+ "plsql",
+ "powerquery",
+ "powershell",
+ "processing",
+ "prolog",
+ "promql",
+ "properties",
+ "protobuf",
+ "psl",
+ "pug",
+ "puppet",
+ "pure",
+ "purebasic",
+ "purescript",
+ "python",
+ "q",
+ "qml",
+ "qore",
+ "qsharp",
+ "r",
+ "racket",
+ "reason",
+ "regex",
+ "rego",
+ "renpy",
+ "rest",
+ "rip",
+ "roboconf",
+ "robotframework",
+ "ruby",
+ "rust",
+ "sas",
+ "sass",
+ "scala",
+ "scheme",
+ "scss",
+ "shell-session",
+ "smali",
+ "smalltalk",
+ "smarty",
+ "sml",
+ "solidity",
+ "solution-file",
+ "soy",
+ "sparql",
+ "splunk-spl",
+ "sqf",
+ "sql",
+ "squirrel",
+ "stan",
+ "stylus",
+ "swift",
+ "systemd",
+ "t4-cs",
+ "t4-templating",
+ "t4-vb",
+ "tap",
+ "tcl",
+ "textile",
+ "toml",
+ "tremor",
+ "tsx",
+ "tt2",
+ "turtle",
+ "twig",
+ "typescript",
+ "typoscript",
+ "unrealscript",
+ "uorazor",
+ "uri",
+ "v",
+ "vala",
+ "vbnet",
+ "velocity",
+ "verilog",
+ "vhdl",
+ "vim",
+ "visual-basic",
+ "warpscript",
+ "wasm",
+ "web-idl",
+ "wiki",
+ "wolfram",
+ "wren",
+ "xeora",
+ "xml-doc",
+ "xojo",
+ "xquery",
+ "yaml",
+ "yang",
+ "zig",
+ ]
+ ],
]
] = None,
code: Optional[Union[Var[str], str]] = None,
@@ -1023,66 +1567,36 @@ class CodeBlock(Component):
starting_line_number: Optional[Union[Var[int], int]] = None,
wrap_long_lines: Optional[Union[Var[bool], bool]] = None,
custom_style: Optional[Dict[str, Union[str, Var, Color]]] = None,
- code_tag_props: Optional[Union[Var[Dict[str, str]], Dict[str, str]]] = None,
+ code_tag_props: Optional[Union[Dict[str, str], Var[Dict[str, str]]]] = None,
+ can_copy: Optional[bool] = None,
+ copy_button: Optional[Union[Component, bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "CodeBlock":
"""Create a text component.
Args:
*children: The children of the component.
- can_copy: Whether a copy button should appears.
- copy_button: A custom copy button to override the default one.
theme: The theme to use ("light" or "dark").
language: The language to use.
code: The code to display.
@@ -1091,6 +1605,8 @@ class CodeBlock(Component):
wrap_long_lines: Whether to wrap long lines.
custom_style: A custom style for the code block.
code_tag_props: Props passed down to the code tag.
+ can_copy: Whether a copy button should appear.
+ copy_button: A custom copy button to override the default one.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -1104,8 +1620,4 @@ class CodeBlock(Component):
"""
...
- def add_style(self): ...
- @staticmethod
- def convert_theme_name(theme) -> str: ...
-
-code_block = CodeBlock.create
+code_block = CodeblockNamespace()
diff --git a/reflex/components/datadisplay/dataeditor.py b/reflex/components/datadisplay/dataeditor.py
index c6d9c1981..f71f97713 100644
--- a/reflex/components/datadisplay/dataeditor.py
+++ b/reflex/components/datadisplay/dataeditor.py
@@ -3,16 +3,20 @@
from __future__ import annotations
from enum import Enum
-from typing import Any, Dict, List, Literal, Optional, Union
+from typing import Any, Dict, List, Literal, Optional, Tuple, Union
+
+from typing_extensions import TypedDict
from reflex.base import Base
from reflex.components.component import Component, NoSSRComponent
from reflex.components.literals import LiteralRowMarker
-from reflex.event import EventHandler
+from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec
from reflex.utils import console, format, types
from reflex.utils.imports import ImportDict, ImportVar
from reflex.utils.serializers import serializer
-from reflex.vars import Var, get_unique_variable_name
+from reflex.vars import get_unique_variable_name
+from reflex.vars.base import Var
+from reflex.vars.sequence import ArrayVar
# TODO: Fix the serialization issue for custom types.
@@ -47,27 +51,6 @@ class GridColumnIcons(Enum):
VideoUri = "video_uri"
-# @serializer
-# def serialize_gridcolumn_icon(icon: GridColumnIcons) -> str:
-# """Serialize grid column icon.
-
-# Args:
-# icon: the Icon to serialize.
-
-# Returns:
-# The serialized value.
-# """
-# return "prefix" + str(icon)
-
-
-# class DataEditorColumn(Base):
-# """Column."""
-
-# title: str
-# id: Optional[str] = None
-# type_: str = "str"
-
-
class DataEditorTheme(Base):
"""The theme for the DataEditor component."""
@@ -105,17 +88,76 @@ class DataEditorTheme(Base):
text_medium: Optional[str] = None
-def on_edit_spec(pos, data: dict[str, Any]):
- """The on edit spec function.
+class Bounds(TypedDict):
+ """The bounds of the group header."""
- Args:
- pos: The position of the edit event.
- data: The data of the edit event.
+ x: int
+ y: int
+ width: int
+ height: int
- Returns:
- The position and data.
- """
- return [pos, data]
+
+class CompatSelection(TypedDict):
+ """The selection."""
+
+ items: list
+
+
+class Rectangle(TypedDict):
+ """The bounds of the group header."""
+
+ x: int
+ y: int
+ width: int
+ height: int
+
+
+class GridSelectionCurrent(TypedDict):
+ """The current selection."""
+
+ cell: tuple[int, int]
+ range: Rectangle
+ rangeStack: list[Rectangle]
+
+
+class GridSelection(TypedDict):
+ """The grid selection."""
+
+ current: Optional[GridSelectionCurrent]
+ columns: CompatSelection
+ rows: CompatSelection
+
+
+class GroupHeaderClickedEventArgs(TypedDict):
+ """The arguments for the group header clicked event."""
+
+ kind: str
+ group: str
+ location: tuple[int, int]
+ bounds: Bounds
+ isEdge: bool
+ shiftKey: bool
+ ctrlKey: bool
+ metaKey: bool
+ isTouch: bool
+ localEventX: int
+ localEventY: int
+ button: int
+ buttons: int
+ scrollEdge: tuple[int, int]
+
+
+class GridCell(TypedDict):
+ """The grid cell."""
+
+ span: Optional[List[int]]
+
+
+class GridColumn(TypedDict):
+ """The grid column."""
+
+ title: str
+ group: Optional[str]
class DataEditor(NoSSRComponent):
@@ -123,10 +165,9 @@ class DataEditor(NoSSRComponent):
tag = "DataEditor"
is_default = True
- library: str = "@glideapps/glide-data-grid@^5.3.0"
+ library: str = "@glideapps/glide-data-grid@^6.0.3"
lib_dependencies: List[str] = [
"lodash@^4.17.21",
- "marked@^4.0.10",
"react-responsive-carousel@^3.2.7",
]
@@ -143,7 +184,7 @@ class DataEditor(NoSSRComponent):
get_cell_content: Var[str]
# Allow selection for copying.
- get_cell_for_selection: Var[bool]
+ get_cells_for_selection: Var[bool]
# Allow paste.
on_paste: Var[bool]
@@ -167,7 +208,7 @@ class DataEditor(NoSSRComponent):
header_height: Var[int]
# Additional header icons:
- # header_icons: Var[Any] # (TODO: must be a map of name: svg)
+ # header_icons: Var[Any] # (TODO: must be a map of name: svg) #noqa: ERA001
# The maximum width a column can be automatically sized to.
max_column_auto_width: Var[int]
@@ -178,7 +219,7 @@ class DataEditor(NoSSRComponent):
# The minimum width a column can be resized to.
min_column_width: Var[int]
- # Determins the height of each row.
+ # Determines the height of each row.
row_height: Var[int]
# Kind of row markers.
@@ -221,52 +262,58 @@ class DataEditor(NoSSRComponent):
theme: Var[Union[DataEditorTheme, Dict]]
# Fired when a cell is activated.
- on_cell_activated: EventHandler[lambda pos: [pos]]
+ on_cell_activated: EventHandler[passthrough_event_spec(Tuple[int, int])]
# Fired when a cell is clicked.
- on_cell_clicked: EventHandler[lambda pos: [pos]]
+ on_cell_clicked: EventHandler[passthrough_event_spec(Tuple[int, int])]
# Fired when a cell is right-clicked.
- on_cell_context_menu: EventHandler[lambda pos: [pos]]
+ on_cell_context_menu: EventHandler[passthrough_event_spec(Tuple[int, int])]
# Fired when a cell is edited.
- on_cell_edited: EventHandler[on_edit_spec]
+ on_cell_edited: EventHandler[passthrough_event_spec(Tuple[int, int], GridCell)]
# Fired when a group header is clicked.
- on_group_header_clicked: EventHandler[on_edit_spec]
+ on_group_header_clicked: EventHandler[
+ passthrough_event_spec(Tuple[int, int], GridCell)
+ ]
# Fired when a group header is right-clicked.
- on_group_header_context_menu: EventHandler[lambda grp_idx, data: [grp_idx, data]]
+ on_group_header_context_menu: EventHandler[
+ passthrough_event_spec(int, GroupHeaderClickedEventArgs)
+ ]
# Fired when a group header is renamed.
- on_group_header_renamed: EventHandler[lambda idx, val: [idx, val]]
+ on_group_header_renamed: EventHandler[passthrough_event_spec(str, str)]
# Fired when a header is clicked.
- on_header_clicked: EventHandler[lambda pos: [pos]]
+ on_header_clicked: EventHandler[passthrough_event_spec(Tuple[int, int])]
# Fired when a header is right-clicked.
- on_header_context_menu: EventHandler[lambda pos: [pos]]
+ on_header_context_menu: EventHandler[passthrough_event_spec(Tuple[int, int])]
# Fired when a header menu item is clicked.
- on_header_menu_click: EventHandler[lambda col, pos: [col, pos]]
+ on_header_menu_click: EventHandler[passthrough_event_spec(int, Rectangle)]
# Fired when an item is hovered.
- on_item_hovered: EventHandler[lambda pos: [pos]]
+ on_item_hovered: EventHandler[passthrough_event_spec(Tuple[int, int])]
# Fired when a selection is deleted.
- on_delete: EventHandler[lambda selection: [selection]]
+ on_delete: EventHandler[passthrough_event_spec(GridSelection)]
# Fired when editing is finished.
- on_finished_editing: EventHandler[lambda new_value, movement: [new_value, movement]]
+ on_finished_editing: EventHandler[
+ passthrough_event_spec(Union[GridCell, None], tuple[int, int])
+ ]
# Fired when a row is appended.
- on_row_appended: EventHandler[lambda: []]
+ on_row_appended: EventHandler[no_args_event_spec]
# Fired when the selection is cleared.
- on_selection_cleared: EventHandler[lambda: []]
+ on_selection_cleared: EventHandler[no_args_event_spec]
# Fired when a column is resized.
- on_column_resize: EventHandler[lambda col, width: [col, width]]
+ on_column_resize: EventHandler[passthrough_event_spec(GridColumn, int)]
def add_imports(self) -> ImportDict:
"""Add imports for the component.
@@ -277,7 +324,7 @@ class DataEditor(NoSSRComponent):
return {
"": f"{format.format_library_name(self.library)}/dist/index.css",
self.library: "GridCellKind",
- "/utils/helpers/dataeditor.js": ImportVar(
+ "$/utils/helpers/dataeditor.js": ImportVar(
tag="formatDataEditorCells", is_default=False, install=False
),
}
@@ -292,15 +339,16 @@ class DataEditor(NoSSRComponent):
editor_id = get_unique_variable_name()
# Define the name of the getData callback associated with this component and assign to get_cell_content.
- data_callback = f"getData_{editor_id}"
- self.get_cell_content = Var.create(
- data_callback, _var_is_local=False, _var_is_string=False
- ) # type: ignore
+ if self.get_cell_content is not None:
+ data_callback = self.get_cell_content._js_expr
+ else:
+ data_callback = f"getData_{editor_id}"
+ self.get_cell_content = Var(_js_expr=data_callback) # type: ignore
code = [f"function {data_callback}([col, row])" "{"]
- columns_path = f"{self.columns._var_full_name}"
- data_path = f"{self.data._var_full_name}"
+ columns_path = str(self.columns)
+ data_path = str(self.data)
code.extend(
[
@@ -329,17 +377,19 @@ class DataEditor(NoSSRComponent):
columns = props.get("columns", [])
data = props.get("data", [])
- rows = props.get("rows", None)
+ rows = props.get("rows")
# If rows is not provided, determine from data.
if rows is None:
+ if isinstance(data, Var) and not isinstance(data, ArrayVar):
+ raise ValueError(
+ "DataEditor data must be an ArrayVar if rows is not provided."
+ )
props["rows"] = data.length() if isinstance(data, Var) else len(data)
if not isinstance(columns, Var) and len(columns):
- if (
- types.is_dataframe(type(data))
- or isinstance(data, Var)
- and types.is_dataframe(data._var_type)
+ if types.is_dataframe(type(data)) or (
+ isinstance(data, Var) and types.is_dataframe(data._var_type)
):
raise ValueError(
"Cannot pass in both a pandas dataframe and columns to the data_editor component."
@@ -355,7 +405,7 @@ class DataEditor(NoSSRComponent):
props["theme"] = DataEditorTheme(**theme)
# Allow by default to select a region of cells in the grid.
- props.setdefault("get_cell_for_selection", True)
+ props.setdefault("get_cells_for_selection", True)
# Disable on_paste by default if not provided.
props.setdefault("on_paste", False)
@@ -403,9 +453,9 @@ def serialize_dataeditortheme(theme: DataEditorTheme):
Returns:
The serialized theme.
"""
- return format.json_dumps(
- {format.to_camel_case(k): v for k, v in theme.__dict__.items() if v is not None}
- )
+ return {
+ format.to_camel_case(k): v for k, v in theme.__dict__.items() if v is not None
+ }
data_editor = DataEditor.create
diff --git a/reflex/components/datadisplay/dataeditor.pyi b/reflex/components/datadisplay/dataeditor.pyi
index 21ee461c3..d930fe256 100644
--- a/reflex/components/datadisplay/dataeditor.pyi
+++ b/reflex/components/datadisplay/dataeditor.pyi
@@ -4,15 +4,17 @@
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
from enum import Enum
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Union, overload
+
+from typing_extensions import TypedDict
from reflex.base import Base
from reflex.components.component import NoSSRComponent
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
from reflex.utils.imports import ImportDict
from reflex.utils.serializers import serializer
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class GridColumnIcons(Enum):
Array = "array"
@@ -76,7 +78,53 @@ class DataEditorTheme(Base):
text_light: Optional[str]
text_medium: Optional[str]
-def on_edit_spec(pos, data: dict[str, Any]): ...
+class Bounds(TypedDict):
+ x: int
+ y: int
+ width: int
+ height: int
+
+class CompatSelection(TypedDict):
+ items: list
+
+class Rectangle(TypedDict):
+ x: int
+ y: int
+ width: int
+ height: int
+
+class GridSelectionCurrent(TypedDict):
+ cell: tuple[int, int]
+ range: Rectangle
+ rangeStack: list[Rectangle]
+
+class GridSelection(TypedDict):
+ current: Optional[GridSelectionCurrent]
+ columns: CompatSelection
+ rows: CompatSelection
+
+class GroupHeaderClickedEventArgs(TypedDict):
+ kind: str
+ group: str
+ location: tuple[int, int]
+ bounds: Bounds
+ isEdge: bool
+ shiftKey: bool
+ ctrlKey: bool
+ metaKey: bool
+ isTouch: bool
+ localEventX: int
+ localEventY: int
+ button: int
+ buttons: int
+ scrollEdge: tuple[int, int]
+
+class GridCell(TypedDict):
+ span: Optional[List[int]]
+
+class GridColumn(TypedDict):
+ title: str
+ group: Optional[str]
class DataEditor(NoSSRComponent):
def add_imports(self) -> ImportDict: ...
@@ -88,11 +136,11 @@ class DataEditor(NoSSRComponent):
*children,
rows: Optional[Union[Var[int], int]] = None,
columns: Optional[
- Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]
+ Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]
] = None,
- data: Optional[Union[Var[List[List[Any]]], List[List[Any]]]] = None,
+ data: Optional[Union[List[List[Any]], Var[List[List[Any]]]]] = None,
get_cell_content: Optional[Union[Var[str], str]] = None,
- get_cell_for_selection: Optional[Union[Var[bool], bool]] = None,
+ get_cells_for_selection: Optional[Union[Var[bool], bool]] = None,
on_paste: Optional[Union[Var[bool], bool]] = None,
draw_focus_ring: Optional[Union[Var[bool], bool]] = None,
fixed_shadow_x: Optional[Union[Var[bool], bool]] = None,
@@ -106,8 +154,8 @@ class DataEditor(NoSSRComponent):
row_height: Optional[Union[Var[int], int]] = None,
row_markers: Optional[
Union[
- Var[Literal["none", "number", "checkbox", "both", "clickable-number"]],
- Literal["none", "number", "checkbox", "both", "clickable-number"],
+ Literal["both", "checkbox", "clickable-number", "none", "number"],
+ Var[Literal["both", "checkbox", "clickable-number", "none", "number"]],
]
] = None,
row_marker_start_index: Optional[Union[Var[int], int]] = None,
@@ -117,8 +165,8 @@ class DataEditor(NoSSRComponent):
vertical_border: Optional[Union[Var[bool], bool]] = None,
column_select: Optional[
Union[
- Var[Literal["none", "single", "multi"]],
- Literal["none", "single", "multi"],
+ Literal["multi", "none", "single"],
+ Var[Literal["multi", "none", "single"]],
]
] = None,
prevent_diagonal_scrolling: Optional[Union[Var[bool], bool]] = None,
@@ -127,107 +175,101 @@ class DataEditor(NoSSRComponent):
scroll_offset_x: Optional[Union[Var[int], int]] = None,
scroll_offset_y: Optional[Union[Var[int], int]] = None,
theme: Optional[
- Union[Var[Union[DataEditorTheme, Dict]], DataEditorTheme, Dict]
+ Union[DataEditorTheme, Dict, Var[Union[DataEditorTheme, Dict]]]
] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_cell_activated: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[tuple[int, int]], BASE_STATE]]
] = None,
on_cell_clicked: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[tuple[int, int]], BASE_STATE]]
] = None,
on_cell_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[tuple[int, int]], BASE_STATE]]
] = None,
on_cell_edited: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[tuple[int, int]], BASE_STATE],
+ EventType[[tuple[int, int], GridCell], BASE_STATE],
+ ]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
on_column_resize: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[GridColumn], BASE_STATE],
+ EventType[[GridColumn, int], BASE_STATE],
+ ]
] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
on_delete: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[GridSelection], BASE_STATE]]
] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
on_finished_editing: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[Union[GridCell, None]], BASE_STATE],
+ EventType[[Union[GridCell, None], tuple[int, int]], BASE_STATE],
+ ]
] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
on_group_header_clicked: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[tuple[int, int]], BASE_STATE],
+ EventType[[tuple[int, int], GridCell], BASE_STATE],
+ ]
] = None,
on_group_header_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[int], BASE_STATE],
+ EventType[[int, GroupHeaderClickedEventArgs], BASE_STATE],
+ ]
] = None,
on_group_header_renamed: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[str], BASE_STATE],
+ EventType[[str, str], BASE_STATE],
+ ]
] = None,
on_header_clicked: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[tuple[int, int]], BASE_STATE]]
] = None,
on_header_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[tuple[int, int]], BASE_STATE]]
] = None,
on_header_menu_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[int], BASE_STATE],
+ EventType[[int, Rectangle], BASE_STATE],
+ ]
] = None,
on_item_hovered: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_row_appended: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_selection_cleared: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[tuple[int, int]], BASE_STATE]]
] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_row_appended: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_selection_cleared: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DataEditor":
"""Create the DataEditor component.
@@ -238,7 +280,7 @@ class DataEditor(NoSSRComponent):
columns: Headers of the columns for the data grid.
data: The data.
get_cell_content: The name of the callback used to find the data to display.
- get_cell_for_selection: Allow selection for copying.
+ get_cells_for_selection: Allow selection for copying.
on_paste: Allow paste.
draw_focus_ring: Controls the drawing of the focus ring.
fixed_shadow_x: Enables or disables the overlay shadow when scrolling horizontally.
@@ -246,10 +288,10 @@ class DataEditor(NoSSRComponent):
freeze_columns: The number of columns which should remain in place when scrolling horizontally. Doesn't include rowMarkers.
group_header_height: Controls the header of the group header row.
header_height: Controls the height of the header row.
- max_column_auto_width: Additional header icons: header_icons: Var[Any] # (TODO: must be a map of name: svg) The maximum width a column can be automatically sized to.
+ max_column_auto_width: The maximum width a column can be automatically sized to.
max_column_width: The maximum width a column can be resized to.
min_column_width: The minimum width a column can be resized to.
- row_height: Determins the height of each row.
+ row_height: Determines the height of each row.
row_markers: Kind of row markers.
row_marker_start_index: Changes the starting index for row markers.
row_marker_width: Sets the width of row markers in pixels, if unset row markers will automatically size.
@@ -263,6 +305,22 @@ class DataEditor(NoSSRComponent):
scroll_offset_x: Initial scroll offset on the horizontal axis.
scroll_offset_y: Initial scroll offset on the vertical axis.
theme: global theme
+ on_cell_activated: Fired when a cell is activated.
+ on_cell_clicked: Fired when a cell is clicked.
+ on_cell_context_menu: Fired when a cell is right-clicked.
+ on_cell_edited: Fired when a cell is edited.
+ on_group_header_clicked: Fired when a group header is clicked.
+ on_group_header_context_menu: Fired when a group header is right-clicked.
+ on_group_header_renamed: Fired when a group header is renamed.
+ on_header_clicked: Fired when a header is clicked.
+ on_header_context_menu: Fired when a header is right-clicked.
+ on_header_menu_click: Fired when a header menu item is clicked.
+ on_item_hovered: Fired when an item is hovered.
+ on_delete: Fired when a selection is deleted.
+ on_finished_editing: Fired when editing is finished.
+ on_row_appended: Fired when a row is appended.
+ on_selection_cleared: Fired when the selection is cleared.
+ on_column_resize: Fired when a column is resized.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/datadisplay/logo.py b/reflex/components/datadisplay/logo.py
index c00c8ebae..d960b8cee 100644
--- a/reflex/components/datadisplay/logo.py
+++ b/reflex/components/datadisplay/logo.py
@@ -1,8 +1,44 @@
"""A Reflex logo component."""
+from typing import Union
+
import reflex as rx
+def svg_logo(color: Union[str, rx.Var[str]] = rx.color_mode_cond("#110F1F", "white")):
+ """A Reflex logo SVG.
+
+ Args:
+ color: The color of the logo.
+
+ Returns:
+ The Reflex logo SVG.
+ """
+
+ def logo_path(d):
+ return rx.el.svg.path(
+ d=d,
+ )
+
+ paths = [
+ "M0 11.5999V0.399902H8.96V4.8799H6.72V2.6399H2.24V4.8799H6.72V7.1199H2.24V11.5999H0ZM6.72 11.5999V7.1199H8.96V11.5999H6.72Z",
+ "M11.2 11.5999V0.399902H17.92V2.6399H13.44V4.8799H17.92V7.1199H13.44V9.3599H17.92V11.5999H11.2Z",
+ "M20.16 11.5999V0.399902H26.88V2.6399H22.4V4.8799H26.88V7.1199H22.4V11.5999H20.16Z",
+ "M29.12 11.5999V0.399902H31.36V9.3599H35.84V11.5999H29.12Z",
+ "M38.08 11.5999V0.399902H44.8V2.6399H40.32V4.8799H44.8V7.1199H40.32V9.3599H44.8V11.5999H38.08Z",
+ "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",
+ ]
+
+ return rx.el.svg(
+ *[logo_path(d) for d in paths],
+ width="56",
+ height="12",
+ viewBox="0 0 56 12",
+ fill=color,
+ xmlns="http://www.w3.org/2000/svg",
+ )
+
+
def logo(**props):
"""A Reflex logo.
@@ -12,32 +48,11 @@ def logo(**props):
Returns:
The logo component.
"""
- light_mode_logo = """
-
-
-
-
-
-
- """
-
- dark_mode_logo = """
-
-
-
-
-
-
- """
-
return rx.center(
rx.link(
rx.hstack(
"Built with ",
- rx.color_mode_cond(
- rx.html(light_mode_logo),
- rx.html(dark_mode_logo),
- ),
+ svg_logo(),
text_align="center",
align="center",
padding="1em",
diff --git a/reflex/components/datadisplay/shiki_code_block.py b/reflex/components/datadisplay/shiki_code_block.py
new file mode 100644
index 000000000..3b6bce8a1
--- /dev/null
+++ b/reflex/components/datadisplay/shiki_code_block.py
@@ -0,0 +1,846 @@
+"""Shiki syntax hghlighter component."""
+
+from __future__ import annotations
+
+import re
+from collections import defaultdict
+from typing import Any, Literal, Optional, Union
+
+from reflex.base import Base
+from reflex.components.component import Component, ComponentNamespace
+from reflex.components.core.colors import color
+from reflex.components.core.cond import color_mode_cond
+from reflex.components.el.elements.forms import Button
+from reflex.components.lucide.icon import Icon
+from reflex.components.markdown.markdown import MarkdownComponentMap
+from reflex.components.props import NoExtrasAllowedProps
+from reflex.components.radix.themes.layout.box import Box
+from reflex.event import run_script, set_clipboard
+from reflex.style import Style
+from reflex.utils.exceptions import VarTypeError
+from reflex.utils.imports import ImportVar
+from reflex.vars.base import LiteralVar, Var
+from reflex.vars.function import FunctionStringVar
+from reflex.vars.sequence import StringVar, string_replace_operation
+
+
+def copy_script() -> Any:
+ """Copy script for the code block and modify the child SVG element.
+
+ Returns:
+ Any: The result of calling the script.
+ """
+ return run_script(
+ """
+// Event listener for the parent click
+document.addEventListener('click', function(event) {
+ // Find the closest button (parent element)
+ const parent = event.target.closest('button');
+ // If the parent is found
+ if (parent) {
+ // Find the SVG element within the parent
+ const svgIcon = parent.querySelector('svg');
+ // If the SVG exists, proceed with the script
+ if (svgIcon) {
+ const originalPath = svgIcon.innerHTML;
+ const checkmarkPath = ' '; // Checkmark SVG path
+ function transition(element, scale, opacity) {
+ element.style.transform = `scale(${scale})`;
+ element.style.opacity = opacity;
+ }
+ // Animate the SVG
+ transition(svgIcon, 0, '0');
+ setTimeout(() => {
+ svgIcon.innerHTML = checkmarkPath; // Replace content with checkmark
+ svgIcon.setAttribute('viewBox', '0 0 24 24'); // Adjust viewBox if necessary
+ transition(svgIcon, 1, '1');
+ setTimeout(() => {
+ transition(svgIcon, 0, '0');
+ setTimeout(() => {
+ svgIcon.innerHTML = originalPath; // Restore original SVG content
+ transition(svgIcon, 1, '1');
+ }, 125);
+ }, 600);
+ }, 125);
+ } else {
+ // console.error('SVG element not found within the parent.');
+ }
+ } else {
+ // console.error('Parent element not found.');
+ }
+})
+"""
+ )
+
+
+SHIKIJS_TRANSFORMER_FNS = {
+ "transformerNotationDiff",
+ "transformerNotationHighlight",
+ "transformerNotationWordHighlight",
+ "transformerNotationFocus",
+ "transformerNotationErrorLevel",
+ "transformerRenderWhitespace",
+ "transformerMetaHighlight",
+ "transformerMetaWordHighlight",
+ "transformerCompactLineOptions",
+ # TODO: this transformer when included adds a weird behavior which removes other code lines. Need to figure out why.
+ # "transformerRemoveLineBreak",
+ "transformerRemoveNotationEscape",
+}
+LINE_NUMBER_STYLING = {
+ "code": {
+ "counter-reset": "step",
+ "counter-increment": "step 0",
+ "display": "grid",
+ "line-height": "1.7",
+ "font-size": "0.875em",
+ },
+ "code .line::before": {
+ "content": "counter(step)",
+ "counter-increment": "step",
+ "width": "1rem",
+ "margin-right": "1.5rem",
+ "display": "inline-block",
+ "text-align": "right",
+ "color": "rgba(115,138,148,.4)",
+ },
+}
+BOX_PARENT_STYLING = {
+ "pre": {
+ "margin": "0",
+ "padding": "24px",
+ "background": "transparent",
+ "overflow-x": "auto",
+ "border-radius": "6px",
+ },
+}
+
+THEME_MAPPING = {
+ "light": "one-light",
+ "dark": "one-dark-pro",
+ "a11y-dark": "github-dark",
+}
+LANGUAGE_MAPPING = {"bash": "shellscript"}
+LiteralCodeLanguage = Literal[
+ "abap",
+ "actionscript-3",
+ "ada",
+ "angular-html",
+ "angular-ts",
+ "apache",
+ "apex",
+ "apl",
+ "applescript",
+ "ara",
+ "asciidoc",
+ "asm",
+ "astro",
+ "awk",
+ "ballerina",
+ "bat",
+ "beancount",
+ "berry",
+ "bibtex",
+ "bicep",
+ "blade",
+ "c",
+ "cadence",
+ "clarity",
+ "clojure",
+ "cmake",
+ "cobol",
+ "codeowners",
+ "codeql",
+ "coffee",
+ "common-lisp",
+ "coq",
+ "cpp",
+ "crystal",
+ "csharp",
+ "css",
+ "csv",
+ "cue",
+ "cypher",
+ "d",
+ "dart",
+ "dax",
+ "desktop",
+ "diff",
+ "docker",
+ "dotenv",
+ "dream-maker",
+ "edge",
+ "elixir",
+ "elm",
+ "emacs-lisp",
+ "erb",
+ "erlang",
+ "fennel",
+ "fish",
+ "fluent",
+ "fortran-fixed-form",
+ "fortran-free-form",
+ "fsharp",
+ "gdresource",
+ "gdscript",
+ "gdshader",
+ "genie",
+ "gherkin",
+ "git-commit",
+ "git-rebase",
+ "gleam",
+ "glimmer-js",
+ "glimmer-ts",
+ "glsl",
+ "gnuplot",
+ "go",
+ "graphql",
+ "groovy",
+ "hack",
+ "haml",
+ "handlebars",
+ "haskell",
+ "haxe",
+ "hcl",
+ "hjson",
+ "hlsl",
+ "html",
+ "html-derivative",
+ "http",
+ "hxml",
+ "hy",
+ "imba",
+ "ini",
+ "java",
+ "javascript",
+ "jinja",
+ "jison",
+ "json",
+ "json5",
+ "jsonc",
+ "jsonl",
+ "jsonnet",
+ "jssm",
+ "jsx",
+ "julia",
+ "kotlin",
+ "kusto",
+ "latex",
+ "lean",
+ "less",
+ "liquid",
+ "log",
+ "logo",
+ "lua",
+ "luau",
+ "make",
+ "markdown",
+ "marko",
+ "matlab",
+ "mdc",
+ "mdx",
+ "mermaid",
+ "mojo",
+ "move",
+ "narrat",
+ "nextflow",
+ "nginx",
+ "nim",
+ "nix",
+ "nushell",
+ "objective-c",
+ "objective-cpp",
+ "ocaml",
+ "pascal",
+ "perl",
+ "php",
+ "plain",
+ "plsql",
+ "po",
+ "postcss",
+ "powerquery",
+ "powershell",
+ "prisma",
+ "prolog",
+ "proto",
+ "pug",
+ "puppet",
+ "purescript",
+ "python",
+ "qml",
+ "qmldir",
+ "qss",
+ "r",
+ "racket",
+ "raku",
+ "razor",
+ "reg",
+ "regexp",
+ "rel",
+ "riscv",
+ "rst",
+ "ruby",
+ "rust",
+ "sas",
+ "sass",
+ "scala",
+ "scheme",
+ "scss",
+ "shaderlab",
+ "shellscript",
+ "shellsession",
+ "smalltalk",
+ "solidity",
+ "soy",
+ "sparql",
+ "splunk",
+ "sql",
+ "ssh-config",
+ "stata",
+ "stylus",
+ "svelte",
+ "swift",
+ "system-verilog",
+ "systemd",
+ "tasl",
+ "tcl",
+ "templ",
+ "terraform",
+ "tex",
+ "toml",
+ "ts-tags",
+ "tsv",
+ "tsx",
+ "turtle",
+ "twig",
+ "typescript",
+ "typespec",
+ "typst",
+ "v",
+ "vala",
+ "vb",
+ "verilog",
+ "vhdl",
+ "viml",
+ "vue",
+ "vue-html",
+ "vyper",
+ "wasm",
+ "wenyan",
+ "wgsl",
+ "wikitext",
+ "wolfram",
+ "xml",
+ "xsl",
+ "yaml",
+ "zenscript",
+ "zig",
+]
+LiteralCodeTheme = Literal[
+ "andromeeda",
+ "aurora-x",
+ "ayu-dark",
+ "catppuccin-frappe",
+ "catppuccin-latte",
+ "catppuccin-macchiato",
+ "catppuccin-mocha",
+ "dark-plus",
+ "dracula",
+ "dracula-soft",
+ "everforest-dark",
+ "everforest-light",
+ "github-dark",
+ "github-dark-default",
+ "github-dark-dimmed",
+ "github-dark-high-contrast",
+ "github-light",
+ "github-light-default",
+ "github-light-high-contrast",
+ "houston",
+ "laserwave",
+ "light-plus",
+ "material-theme",
+ "material-theme-darker",
+ "material-theme-lighter",
+ "material-theme-ocean",
+ "material-theme-palenight",
+ "min-dark",
+ "min-light",
+ "monokai",
+ "night-owl",
+ "nord",
+ "one-dark-pro",
+ "one-light",
+ "plastic",
+ "poimandres",
+ "red",
+ # rose-pine themes dont work with the current version of shikijs transformers
+ # https://github.com/shikijs/shiki/issues/730
+ "rose-pine",
+ "rose-pine-dawn",
+ "rose-pine-moon",
+ "slack-dark",
+ "slack-ochin",
+ "snazzy-light",
+ "solarized-dark",
+ "solarized-light",
+ "synthwave-84",
+ "tokyo-night",
+ "vesper",
+ "vitesse-black",
+ "vitesse-dark",
+ "vitesse-light",
+]
+
+
+class Position(NoExtrasAllowedProps):
+ """Position of the decoration."""
+
+ line: int
+ character: int
+
+
+class ShikiDecorations(NoExtrasAllowedProps):
+ """Decorations for the code block."""
+
+ start: Union[int, Position]
+ end: Union[int, Position]
+ tag_name: str = "span"
+ properties: dict[str, Any] = {}
+ always_wrap: bool = False
+
+
+class ShikiBaseTransformers(Base):
+ """Base for creating transformers."""
+
+ library: str
+ fns: list[FunctionStringVar]
+ style: Optional[Style]
+
+
+class ShikiJsTransformer(ShikiBaseTransformers):
+ """A Wrapped shikijs transformer."""
+
+ library: str = "@shikijs/transformers"
+ fns: list[FunctionStringVar] = [
+ FunctionStringVar.create(fn) for fn in SHIKIJS_TRANSFORMER_FNS
+ ]
+ style: Optional[Style] = Style(
+ {
+ "code": {"line-height": "1.7", "font-size": "0.875em", "display": "grid"},
+ # Diffs
+ ".diff": {
+ "margin": "0 -24px",
+ "padding": "0 24px",
+ "width": "calc(100% + 48px)",
+ "display": "inline-block",
+ },
+ ".diff.add": {
+ "background-color": "rgba(16, 185, 129, .14)",
+ "position": "relative",
+ },
+ ".diff.remove": {
+ "background-color": "rgba(244, 63, 94, .14)",
+ "opacity": "0.7",
+ "position": "relative",
+ },
+ ".diff.remove:after": {
+ "position": "absolute",
+ "left": "10px",
+ "content": "'-'",
+ "color": "#b34e52",
+ },
+ ".diff.add:after": {
+ "position": "absolute",
+ "left": "10px",
+ "content": "'+'",
+ "color": "#18794e",
+ },
+ # Highlight
+ ".highlighted": {
+ "background-color": "rgba(142, 150, 170, .14)",
+ "margin": "0 -24px",
+ "padding": "0 24px",
+ "width": "calc(100% + 48px)",
+ "display": "inline-block",
+ },
+ ".highlighted.error": {
+ "background-color": "rgba(244, 63, 94, .14)",
+ },
+ ".highlighted.warning": {
+ "background-color": "rgba(234, 179, 8, .14)",
+ },
+ # Highlighted Word
+ ".highlighted-word": {
+ "background-color": color("gray", 2),
+ "border": f"1px solid {color('gray', 5)}",
+ "padding": "1px 3px",
+ "margin": "-1px -3px",
+ "border-radius": "4px",
+ },
+ # Focused Lines
+ ".has-focused .line:not(.focused)": {
+ "opacity": "0.7",
+ "filter": "blur(0.095rem)",
+ "transition": "filter .35s, opacity .35s",
+ },
+ ".has-focused:hover .line:not(.focused)": {
+ "opacity": "1",
+ "filter": "none",
+ },
+ # White Space
+ # ".tab, .space": {
+ # "position": "relative", # noqa: ERA001
+ # },
+ # ".tab::before": {
+ # "content": "'⇥'", # noqa: ERA001
+ # "position": "absolute", # noqa: ERA001
+ # "opacity": "0.3",# noqa: ERA001
+ # },
+ # ".space::before": {
+ # "content": "'·'", # noqa: ERA001
+ # "position": "absolute", # noqa: ERA001
+ # "opacity": "0.3", # noqa: ERA001
+ # },
+ }
+ )
+
+ def __init__(self, **kwargs):
+ """Initialize the transformer.
+
+ Args:
+ kwargs: Kwargs to initialize the props.
+
+ """
+ fns = kwargs.pop("fns", None)
+ style = kwargs.pop("style", None)
+ if fns:
+ kwargs["fns"] = [
+ (
+ FunctionStringVar.create(x)
+ if not isinstance(x, FunctionStringVar)
+ else x
+ )
+ for x in fns
+ ]
+
+ if style:
+ kwargs["style"] = Style(style)
+ super().__init__(**kwargs)
+
+
+class ShikiCodeBlock(Component, MarkdownComponentMap):
+ """A Code block."""
+
+ library = "/components/shiki/code"
+
+ tag = "Code"
+
+ alias = "ShikiCode"
+
+ lib_dependencies: list[str] = ["shiki"]
+
+ # The language to use.
+ language: Var[LiteralCodeLanguage] = Var.create("python")
+
+ # The theme to use ("light" or "dark").
+ theme: Var[LiteralCodeTheme] = Var.create("one-light")
+
+ # The set of themes to use for different modes.
+ themes: Var[Union[list[dict[str, Any]], dict[str, str]]]
+
+ # The code to display.
+ code: Var[str]
+
+ # The transformers to use for the syntax highlighter.
+ transformers: Var[list[Union[ShikiBaseTransformers, dict[str, Any]]]] = Var.create(
+ []
+ )
+
+ # The decorations to use for the syntax highlighter.
+ decorations: Var[list[ShikiDecorations]] = Var.create([])
+
+ @classmethod
+ def create(
+ cls,
+ *children,
+ **props,
+ ) -> Component:
+ """Create a code block component using [shiki syntax highlighter](https://shiki.matsu.io/).
+
+ Args:
+ *children: The children of the component.
+ **props: The props to pass to the component.
+
+ Returns:
+ The code block component.
+ """
+ # Separate props for the code block and the wrapper
+ code_block_props = {}
+ code_wrapper_props = {}
+ decorations = props.pop("decorations", [])
+
+ class_props = cls.get_props()
+
+ # Distribute props between the code block and wrapper
+ for key, value in props.items():
+ (code_block_props if key in class_props else code_wrapper_props)[key] = (
+ value
+ )
+
+ # cast decorations into ShikiDecorations.
+ decorations = [
+ ShikiDecorations(**decoration)
+ if not isinstance(decoration, ShikiDecorations)
+ else decoration
+ for decoration in decorations
+ ]
+ code_block_props["decorations"] = decorations
+
+ code_block_props["code"] = children[0]
+ code_block = super().create(**code_block_props)
+
+ transformer_styles = {}
+ # Collect styles from transformers and wrapper
+ for transformer in code_block.transformers._var_value: # type: ignore
+ if isinstance(transformer, ShikiBaseTransformers) and transformer.style:
+ transformer_styles.update(transformer.style)
+ transformer_styles.update(code_wrapper_props.pop("style", {}))
+
+ return Box.create(
+ code_block,
+ *children[1:],
+ style=Style({**transformer_styles, **BOX_PARENT_STYLING}),
+ **code_wrapper_props,
+ )
+
+ def add_imports(self) -> dict[str, list[str]]:
+ """Add the necessary imports.
+ We add all referenced transformer functions as imports from their corresponding
+ libraries.
+
+ Returns:
+ Imports for the component.
+ """
+ imports = defaultdict(list)
+ for transformer in self.transformers._var_value:
+ if isinstance(transformer, ShikiBaseTransformers):
+ imports[transformer.library].extend(
+ [ImportVar(tag=str(fn)) for fn in transformer.fns]
+ )
+ (
+ self.lib_dependencies.append(transformer.library)
+ if transformer.library not in self.lib_dependencies
+ else None
+ )
+ return imports
+
+ @classmethod
+ def create_transformer(cls, library: str, fns: list[str]) -> ShikiBaseTransformers:
+ """Create a transformer from a third party library.
+
+ Args:
+ library: The name of the library.
+ fns: The str names of the functions/callables to invoke from the library.
+
+ Returns:
+ A transformer for the specified library.
+
+ Raises:
+ ValueError: If a supplied function name is not valid str.
+ """
+ if any(not isinstance(fn_name, str) for fn_name in fns):
+ raise ValueError(
+ f"the function names should be str names of functions in the specified transformer: {library!r}"
+ )
+ return ShikiBaseTransformers( # type: ignore
+ library=library, fns=[FunctionStringVar.create(fn) for fn in fns]
+ )
+
+ def _render(self, props: dict[str, Any] | None = None):
+ """Renders the component with the given properties, processing transformers if present.
+
+ Args:
+ props: Optional properties to pass to the render function.
+
+ Returns:
+ Rendered component output.
+ """
+ # Ensure props is initialized from class attributes if not provided
+ props = props or {
+ attr.rstrip("_"): getattr(self, attr) for attr in self.get_props()
+ }
+
+ # Extract transformers and apply transformations
+ transformers = props.get("transformers")
+ if transformers is not None:
+ transformed_values = self._process_transformers(transformers._var_value)
+ props["transformers"] = LiteralVar.create(transformed_values)
+
+ return super()._render(props)
+
+ def _process_transformers(self, transformer_list: list) -> list:
+ """Processes a list of transformers, applying transformations where necessary.
+
+ Args:
+ transformer_list: List of transformer objects or values.
+
+ Returns:
+ list: A list of transformed values.
+ """
+ processed = []
+
+ for transformer in transformer_list:
+ if isinstance(transformer, ShikiBaseTransformers):
+ processed.extend(fn.call() for fn in transformer.fns)
+ else:
+ processed.append(transformer)
+
+ return processed
+
+
+class ShikiHighLevelCodeBlock(ShikiCodeBlock):
+ """High level component for the shiki syntax highlighter."""
+
+ # If this is enabled, the default transformers(shikijs transformer) will be used.
+ use_transformers: Var[bool]
+
+ # If this is enabled line numbers will be shown next to the code block.
+ show_line_numbers: Var[bool]
+
+ # Whether a copy button should appear.
+ can_copy: bool = False
+
+ # copy_button: A custom copy button to override the default one.
+ copy_button: Optional[Union[Component, bool]] = None
+
+ @classmethod
+ def create(
+ cls,
+ *children,
+ **props,
+ ) -> Component:
+ """Create a code block component using [shiki syntax highlighter](https://shiki.matsu.io/).
+
+ Args:
+ *children: The children of the component.
+ **props: The props to pass to the component.
+
+ Returns:
+ The code block component.
+ """
+ use_transformers = props.pop("use_transformers", False)
+ show_line_numbers = props.pop("show_line_numbers", False)
+ language = props.pop("language", None)
+ can_copy = props.pop("can_copy", False)
+ copy_button = props.pop("copy_button", None)
+
+ if use_transformers:
+ props["transformers"] = [ShikiJsTransformer()]
+
+ if language is not None:
+ props["language"] = cls._map_languages(language)
+
+ # line numbers are generated via css
+ if show_line_numbers:
+ props["style"] = {**LINE_NUMBER_STYLING, **props.get("style", {})}
+
+ theme = props.pop("theme", None)
+ props["theme"] = props["theme"] = (
+ cls._map_themes(theme)
+ if theme is not None
+ else color_mode_cond( # Default color scheme responds to global color mode.
+ light="one-light",
+ dark="one-dark-pro",
+ )
+ )
+
+ if can_copy:
+ code = children[0]
+ copy_button = ( # type: ignore
+ copy_button
+ if copy_button is not None
+ else Button.create(
+ Icon.create(tag="copy", size=16, color=color("gray", 11)),
+ on_click=[
+ set_clipboard(cls._strip_transformer_triggers(code)), # type: ignore
+ copy_script(),
+ ],
+ style=Style(
+ {
+ "position": "absolute",
+ "top": "4px",
+ "right": "4px",
+ "background": color("gray", 3),
+ "border": "1px solid",
+ "border-color": color("gray", 5),
+ "border-radius": "6px",
+ "padding": "5px",
+ "opacity": "1",
+ "cursor": "pointer",
+ "_hover": {
+ "background": color("gray", 4),
+ },
+ "transition": "background 0.250s ease-out",
+ "&>svg": {
+ "transition": "transform 0.250s ease-out, opacity 0.250s ease-out",
+ },
+ "_active": {
+ "background": color("gray", 5),
+ },
+ }
+ ),
+ )
+ )
+
+ if copy_button:
+ return ShikiCodeBlock.create(
+ children[0], copy_button, position="relative", **props
+ )
+ else:
+ return ShikiCodeBlock.create(children[0], **props)
+
+ @staticmethod
+ def _map_themes(theme: str) -> str:
+ if isinstance(theme, str) and theme in THEME_MAPPING:
+ return THEME_MAPPING[theme]
+ return theme
+
+ @staticmethod
+ def _map_languages(language: str) -> str:
+ if isinstance(language, str) and language in LANGUAGE_MAPPING:
+ return LANGUAGE_MAPPING[language]
+ return language
+
+ @staticmethod
+ def _strip_transformer_triggers(code: str | StringVar) -> StringVar | str:
+ if not isinstance(code, (StringVar, str)):
+ raise VarTypeError(
+ f"code should be string literal or a StringVar type. Got {type(code)} instead."
+ )
+ regex_pattern = r"[\/#]+ *\[!code.*?\]"
+
+ if isinstance(code, Var):
+ return string_replace_operation(
+ code, StringVar(_js_expr=f"/{regex_pattern}/g", _var_type=str), ""
+ )
+ if isinstance(code, str):
+ return re.sub(regex_pattern, "", code)
+
+
+class TransformerNamespace(ComponentNamespace):
+ """Namespace for the Transformers."""
+
+ shikijs = ShikiJsTransformer
+
+
+class CodeblockNamespace(ComponentNamespace):
+ """Namespace for the CodeBlock component."""
+
+ root = staticmethod(ShikiCodeBlock.create)
+ create_transformer = staticmethod(ShikiCodeBlock.create_transformer)
+ transformers = TransformerNamespace()
+ __call__ = staticmethod(ShikiHighLevelCodeBlock.create)
+
+
+code_block = CodeblockNamespace()
diff --git a/reflex/components/datadisplay/shiki_code_block.pyi b/reflex/components/datadisplay/shiki_code_block.pyi
new file mode 100644
index 000000000..92546ee4f
--- /dev/null
+++ b/reflex/components/datadisplay/shiki_code_block.pyi
@@ -0,0 +1,2232 @@
+"""Stub file for reflex/components/datadisplay/shiki_code_block.py"""
+
+# ------------------- DO NOT EDIT ----------------------
+# This file was generated by `reflex/utils/pyi_generator.py`!
+# ------------------------------------------------------
+from typing import Any, Dict, Literal, Optional, Union, overload
+
+from reflex.base import Base
+from reflex.components.component import Component, ComponentNamespace
+from reflex.components.markdown.markdown import MarkdownComponentMap
+from reflex.components.props import NoExtrasAllowedProps
+from reflex.event import BASE_STATE, EventType
+from reflex.style import Style
+from reflex.vars.base import Var
+from reflex.vars.function import FunctionStringVar
+
+def copy_script() -> Any: ...
+
+SHIKIJS_TRANSFORMER_FNS = {
+ "transformerNotationDiff",
+ "transformerNotationHighlight",
+ "transformerNotationWordHighlight",
+ "transformerNotationFocus",
+ "transformerNotationErrorLevel",
+ "transformerRenderWhitespace",
+ "transformerMetaHighlight",
+ "transformerMetaWordHighlight",
+ "transformerCompactLineOptions",
+ "transformerRemoveNotationEscape",
+}
+LINE_NUMBER_STYLING = {
+ "code": {
+ "counter-reset": "step",
+ "counter-increment": "step 0",
+ "display": "grid",
+ "line-height": "1.7",
+ "font-size": "0.875em",
+ },
+ "code .line::before": {
+ "content": "counter(step)",
+ "counter-increment": "step",
+ "width": "1rem",
+ "margin-right": "1.5rem",
+ "display": "inline-block",
+ "text-align": "right",
+ "color": "rgba(115,138,148,.4)",
+ },
+}
+BOX_PARENT_STYLING = {
+ "pre": {
+ "margin": "0",
+ "padding": "24px",
+ "background": "transparent",
+ "overflow-x": "auto",
+ "border-radius": "6px",
+ }
+}
+THEME_MAPPING = {
+ "light": "one-light",
+ "dark": "one-dark-pro",
+ "a11y-dark": "github-dark",
+}
+LANGUAGE_MAPPING = {"bash": "shellscript"}
+LiteralCodeLanguage = Literal[
+ "abap",
+ "actionscript-3",
+ "ada",
+ "angular-html",
+ "angular-ts",
+ "apache",
+ "apex",
+ "apl",
+ "applescript",
+ "ara",
+ "asciidoc",
+ "asm",
+ "astro",
+ "awk",
+ "ballerina",
+ "bat",
+ "beancount",
+ "berry",
+ "bibtex",
+ "bicep",
+ "blade",
+ "c",
+ "cadence",
+ "clarity",
+ "clojure",
+ "cmake",
+ "cobol",
+ "codeowners",
+ "codeql",
+ "coffee",
+ "common-lisp",
+ "coq",
+ "cpp",
+ "crystal",
+ "csharp",
+ "css",
+ "csv",
+ "cue",
+ "cypher",
+ "d",
+ "dart",
+ "dax",
+ "desktop",
+ "diff",
+ "docker",
+ "dotenv",
+ "dream-maker",
+ "edge",
+ "elixir",
+ "elm",
+ "emacs-lisp",
+ "erb",
+ "erlang",
+ "fennel",
+ "fish",
+ "fluent",
+ "fortran-fixed-form",
+ "fortran-free-form",
+ "fsharp",
+ "gdresource",
+ "gdscript",
+ "gdshader",
+ "genie",
+ "gherkin",
+ "git-commit",
+ "git-rebase",
+ "gleam",
+ "glimmer-js",
+ "glimmer-ts",
+ "glsl",
+ "gnuplot",
+ "go",
+ "graphql",
+ "groovy",
+ "hack",
+ "haml",
+ "handlebars",
+ "haskell",
+ "haxe",
+ "hcl",
+ "hjson",
+ "hlsl",
+ "html",
+ "html-derivative",
+ "http",
+ "hxml",
+ "hy",
+ "imba",
+ "ini",
+ "java",
+ "javascript",
+ "jinja",
+ "jison",
+ "json",
+ "json5",
+ "jsonc",
+ "jsonl",
+ "jsonnet",
+ "jssm",
+ "jsx",
+ "julia",
+ "kotlin",
+ "kusto",
+ "latex",
+ "lean",
+ "less",
+ "liquid",
+ "log",
+ "logo",
+ "lua",
+ "luau",
+ "make",
+ "markdown",
+ "marko",
+ "matlab",
+ "mdc",
+ "mdx",
+ "mermaid",
+ "mojo",
+ "move",
+ "narrat",
+ "nextflow",
+ "nginx",
+ "nim",
+ "nix",
+ "nushell",
+ "objective-c",
+ "objective-cpp",
+ "ocaml",
+ "pascal",
+ "perl",
+ "php",
+ "plain",
+ "plsql",
+ "po",
+ "postcss",
+ "powerquery",
+ "powershell",
+ "prisma",
+ "prolog",
+ "proto",
+ "pug",
+ "puppet",
+ "purescript",
+ "python",
+ "qml",
+ "qmldir",
+ "qss",
+ "r",
+ "racket",
+ "raku",
+ "razor",
+ "reg",
+ "regexp",
+ "rel",
+ "riscv",
+ "rst",
+ "ruby",
+ "rust",
+ "sas",
+ "sass",
+ "scala",
+ "scheme",
+ "scss",
+ "shaderlab",
+ "shellscript",
+ "shellsession",
+ "smalltalk",
+ "solidity",
+ "soy",
+ "sparql",
+ "splunk",
+ "sql",
+ "ssh-config",
+ "stata",
+ "stylus",
+ "svelte",
+ "swift",
+ "system-verilog",
+ "systemd",
+ "tasl",
+ "tcl",
+ "templ",
+ "terraform",
+ "tex",
+ "toml",
+ "ts-tags",
+ "tsv",
+ "tsx",
+ "turtle",
+ "twig",
+ "typescript",
+ "typespec",
+ "typst",
+ "v",
+ "vala",
+ "vb",
+ "verilog",
+ "vhdl",
+ "viml",
+ "vue",
+ "vue-html",
+ "vyper",
+ "wasm",
+ "wenyan",
+ "wgsl",
+ "wikitext",
+ "wolfram",
+ "xml",
+ "xsl",
+ "yaml",
+ "zenscript",
+ "zig",
+]
+LiteralCodeTheme = Literal[
+ "andromeeda",
+ "aurora-x",
+ "ayu-dark",
+ "catppuccin-frappe",
+ "catppuccin-latte",
+ "catppuccin-macchiato",
+ "catppuccin-mocha",
+ "dark-plus",
+ "dracula",
+ "dracula-soft",
+ "everforest-dark",
+ "everforest-light",
+ "github-dark",
+ "github-dark-default",
+ "github-dark-dimmed",
+ "github-dark-high-contrast",
+ "github-light",
+ "github-light-default",
+ "github-light-high-contrast",
+ "houston",
+ "laserwave",
+ "light-plus",
+ "material-theme",
+ "material-theme-darker",
+ "material-theme-lighter",
+ "material-theme-ocean",
+ "material-theme-palenight",
+ "min-dark",
+ "min-light",
+ "monokai",
+ "night-owl",
+ "nord",
+ "one-dark-pro",
+ "one-light",
+ "plastic",
+ "poimandres",
+ "red",
+ "rose-pine",
+ "rose-pine-dawn",
+ "rose-pine-moon",
+ "slack-dark",
+ "slack-ochin",
+ "snazzy-light",
+ "solarized-dark",
+ "solarized-light",
+ "synthwave-84",
+ "tokyo-night",
+ "vesper",
+ "vitesse-black",
+ "vitesse-dark",
+ "vitesse-light",
+]
+
+class Position(NoExtrasAllowedProps):
+ line: int
+ character: int
+
+class ShikiDecorations(NoExtrasAllowedProps):
+ start: Union[int, Position]
+ end: Union[int, Position]
+ tag_name: str
+ properties: dict[str, Any]
+ always_wrap: bool
+
+class ShikiBaseTransformers(Base):
+ library: str
+ fns: list[FunctionStringVar]
+ style: Optional[Style]
+
+class ShikiJsTransformer(ShikiBaseTransformers):
+ library: str
+ fns: list[FunctionStringVar]
+ style: Optional[Style]
+
+class ShikiCodeBlock(Component, MarkdownComponentMap):
+ @overload
+ @classmethod
+ def create( # type: ignore
+ cls,
+ *children,
+ language: Optional[
+ Union[
+ Literal[
+ "abap",
+ "actionscript-3",
+ "ada",
+ "angular-html",
+ "angular-ts",
+ "apache",
+ "apex",
+ "apl",
+ "applescript",
+ "ara",
+ "asciidoc",
+ "asm",
+ "astro",
+ "awk",
+ "ballerina",
+ "bat",
+ "beancount",
+ "berry",
+ "bibtex",
+ "bicep",
+ "blade",
+ "c",
+ "cadence",
+ "clarity",
+ "clojure",
+ "cmake",
+ "cobol",
+ "codeowners",
+ "codeql",
+ "coffee",
+ "common-lisp",
+ "coq",
+ "cpp",
+ "crystal",
+ "csharp",
+ "css",
+ "csv",
+ "cue",
+ "cypher",
+ "d",
+ "dart",
+ "dax",
+ "desktop",
+ "diff",
+ "docker",
+ "dotenv",
+ "dream-maker",
+ "edge",
+ "elixir",
+ "elm",
+ "emacs-lisp",
+ "erb",
+ "erlang",
+ "fennel",
+ "fish",
+ "fluent",
+ "fortran-fixed-form",
+ "fortran-free-form",
+ "fsharp",
+ "gdresource",
+ "gdscript",
+ "gdshader",
+ "genie",
+ "gherkin",
+ "git-commit",
+ "git-rebase",
+ "gleam",
+ "glimmer-js",
+ "glimmer-ts",
+ "glsl",
+ "gnuplot",
+ "go",
+ "graphql",
+ "groovy",
+ "hack",
+ "haml",
+ "handlebars",
+ "haskell",
+ "haxe",
+ "hcl",
+ "hjson",
+ "hlsl",
+ "html",
+ "html-derivative",
+ "http",
+ "hxml",
+ "hy",
+ "imba",
+ "ini",
+ "java",
+ "javascript",
+ "jinja",
+ "jison",
+ "json",
+ "json5",
+ "jsonc",
+ "jsonl",
+ "jsonnet",
+ "jssm",
+ "jsx",
+ "julia",
+ "kotlin",
+ "kusto",
+ "latex",
+ "lean",
+ "less",
+ "liquid",
+ "log",
+ "logo",
+ "lua",
+ "luau",
+ "make",
+ "markdown",
+ "marko",
+ "matlab",
+ "mdc",
+ "mdx",
+ "mermaid",
+ "mojo",
+ "move",
+ "narrat",
+ "nextflow",
+ "nginx",
+ "nim",
+ "nix",
+ "nushell",
+ "objective-c",
+ "objective-cpp",
+ "ocaml",
+ "pascal",
+ "perl",
+ "php",
+ "plain",
+ "plsql",
+ "po",
+ "postcss",
+ "powerquery",
+ "powershell",
+ "prisma",
+ "prolog",
+ "proto",
+ "pug",
+ "puppet",
+ "purescript",
+ "python",
+ "qml",
+ "qmldir",
+ "qss",
+ "r",
+ "racket",
+ "raku",
+ "razor",
+ "reg",
+ "regexp",
+ "rel",
+ "riscv",
+ "rst",
+ "ruby",
+ "rust",
+ "sas",
+ "sass",
+ "scala",
+ "scheme",
+ "scss",
+ "shaderlab",
+ "shellscript",
+ "shellsession",
+ "smalltalk",
+ "solidity",
+ "soy",
+ "sparql",
+ "splunk",
+ "sql",
+ "ssh-config",
+ "stata",
+ "stylus",
+ "svelte",
+ "swift",
+ "system-verilog",
+ "systemd",
+ "tasl",
+ "tcl",
+ "templ",
+ "terraform",
+ "tex",
+ "toml",
+ "ts-tags",
+ "tsv",
+ "tsx",
+ "turtle",
+ "twig",
+ "typescript",
+ "typespec",
+ "typst",
+ "v",
+ "vala",
+ "vb",
+ "verilog",
+ "vhdl",
+ "viml",
+ "vue",
+ "vue-html",
+ "vyper",
+ "wasm",
+ "wenyan",
+ "wgsl",
+ "wikitext",
+ "wolfram",
+ "xml",
+ "xsl",
+ "yaml",
+ "zenscript",
+ "zig",
+ ],
+ Var[
+ Literal[
+ "abap",
+ "actionscript-3",
+ "ada",
+ "angular-html",
+ "angular-ts",
+ "apache",
+ "apex",
+ "apl",
+ "applescript",
+ "ara",
+ "asciidoc",
+ "asm",
+ "astro",
+ "awk",
+ "ballerina",
+ "bat",
+ "beancount",
+ "berry",
+ "bibtex",
+ "bicep",
+ "blade",
+ "c",
+ "cadence",
+ "clarity",
+ "clojure",
+ "cmake",
+ "cobol",
+ "codeowners",
+ "codeql",
+ "coffee",
+ "common-lisp",
+ "coq",
+ "cpp",
+ "crystal",
+ "csharp",
+ "css",
+ "csv",
+ "cue",
+ "cypher",
+ "d",
+ "dart",
+ "dax",
+ "desktop",
+ "diff",
+ "docker",
+ "dotenv",
+ "dream-maker",
+ "edge",
+ "elixir",
+ "elm",
+ "emacs-lisp",
+ "erb",
+ "erlang",
+ "fennel",
+ "fish",
+ "fluent",
+ "fortran-fixed-form",
+ "fortran-free-form",
+ "fsharp",
+ "gdresource",
+ "gdscript",
+ "gdshader",
+ "genie",
+ "gherkin",
+ "git-commit",
+ "git-rebase",
+ "gleam",
+ "glimmer-js",
+ "glimmer-ts",
+ "glsl",
+ "gnuplot",
+ "go",
+ "graphql",
+ "groovy",
+ "hack",
+ "haml",
+ "handlebars",
+ "haskell",
+ "haxe",
+ "hcl",
+ "hjson",
+ "hlsl",
+ "html",
+ "html-derivative",
+ "http",
+ "hxml",
+ "hy",
+ "imba",
+ "ini",
+ "java",
+ "javascript",
+ "jinja",
+ "jison",
+ "json",
+ "json5",
+ "jsonc",
+ "jsonl",
+ "jsonnet",
+ "jssm",
+ "jsx",
+ "julia",
+ "kotlin",
+ "kusto",
+ "latex",
+ "lean",
+ "less",
+ "liquid",
+ "log",
+ "logo",
+ "lua",
+ "luau",
+ "make",
+ "markdown",
+ "marko",
+ "matlab",
+ "mdc",
+ "mdx",
+ "mermaid",
+ "mojo",
+ "move",
+ "narrat",
+ "nextflow",
+ "nginx",
+ "nim",
+ "nix",
+ "nushell",
+ "objective-c",
+ "objective-cpp",
+ "ocaml",
+ "pascal",
+ "perl",
+ "php",
+ "plain",
+ "plsql",
+ "po",
+ "postcss",
+ "powerquery",
+ "powershell",
+ "prisma",
+ "prolog",
+ "proto",
+ "pug",
+ "puppet",
+ "purescript",
+ "python",
+ "qml",
+ "qmldir",
+ "qss",
+ "r",
+ "racket",
+ "raku",
+ "razor",
+ "reg",
+ "regexp",
+ "rel",
+ "riscv",
+ "rst",
+ "ruby",
+ "rust",
+ "sas",
+ "sass",
+ "scala",
+ "scheme",
+ "scss",
+ "shaderlab",
+ "shellscript",
+ "shellsession",
+ "smalltalk",
+ "solidity",
+ "soy",
+ "sparql",
+ "splunk",
+ "sql",
+ "ssh-config",
+ "stata",
+ "stylus",
+ "svelte",
+ "swift",
+ "system-verilog",
+ "systemd",
+ "tasl",
+ "tcl",
+ "templ",
+ "terraform",
+ "tex",
+ "toml",
+ "ts-tags",
+ "tsv",
+ "tsx",
+ "turtle",
+ "twig",
+ "typescript",
+ "typespec",
+ "typst",
+ "v",
+ "vala",
+ "vb",
+ "verilog",
+ "vhdl",
+ "viml",
+ "vue",
+ "vue-html",
+ "vyper",
+ "wasm",
+ "wenyan",
+ "wgsl",
+ "wikitext",
+ "wolfram",
+ "xml",
+ "xsl",
+ "yaml",
+ "zenscript",
+ "zig",
+ ]
+ ],
+ ]
+ ] = None,
+ theme: Optional[
+ Union[
+ Literal[
+ "andromeeda",
+ "aurora-x",
+ "ayu-dark",
+ "catppuccin-frappe",
+ "catppuccin-latte",
+ "catppuccin-macchiato",
+ "catppuccin-mocha",
+ "dark-plus",
+ "dracula",
+ "dracula-soft",
+ "everforest-dark",
+ "everforest-light",
+ "github-dark",
+ "github-dark-default",
+ "github-dark-dimmed",
+ "github-dark-high-contrast",
+ "github-light",
+ "github-light-default",
+ "github-light-high-contrast",
+ "houston",
+ "laserwave",
+ "light-plus",
+ "material-theme",
+ "material-theme-darker",
+ "material-theme-lighter",
+ "material-theme-ocean",
+ "material-theme-palenight",
+ "min-dark",
+ "min-light",
+ "monokai",
+ "night-owl",
+ "nord",
+ "one-dark-pro",
+ "one-light",
+ "plastic",
+ "poimandres",
+ "red",
+ "rose-pine",
+ "rose-pine-dawn",
+ "rose-pine-moon",
+ "slack-dark",
+ "slack-ochin",
+ "snazzy-light",
+ "solarized-dark",
+ "solarized-light",
+ "synthwave-84",
+ "tokyo-night",
+ "vesper",
+ "vitesse-black",
+ "vitesse-dark",
+ "vitesse-light",
+ ],
+ Var[
+ Literal[
+ "andromeeda",
+ "aurora-x",
+ "ayu-dark",
+ "catppuccin-frappe",
+ "catppuccin-latte",
+ "catppuccin-macchiato",
+ "catppuccin-mocha",
+ "dark-plus",
+ "dracula",
+ "dracula-soft",
+ "everforest-dark",
+ "everforest-light",
+ "github-dark",
+ "github-dark-default",
+ "github-dark-dimmed",
+ "github-dark-high-contrast",
+ "github-light",
+ "github-light-default",
+ "github-light-high-contrast",
+ "houston",
+ "laserwave",
+ "light-plus",
+ "material-theme",
+ "material-theme-darker",
+ "material-theme-lighter",
+ "material-theme-ocean",
+ "material-theme-palenight",
+ "min-dark",
+ "min-light",
+ "monokai",
+ "night-owl",
+ "nord",
+ "one-dark-pro",
+ "one-light",
+ "plastic",
+ "poimandres",
+ "red",
+ "rose-pine",
+ "rose-pine-dawn",
+ "rose-pine-moon",
+ "slack-dark",
+ "slack-ochin",
+ "snazzy-light",
+ "solarized-dark",
+ "solarized-light",
+ "synthwave-84",
+ "tokyo-night",
+ "vesper",
+ "vitesse-black",
+ "vitesse-dark",
+ "vitesse-light",
+ ]
+ ],
+ ]
+ ] = None,
+ themes: Optional[
+ Union[
+ Var[Union[dict[str, str], list[dict[str, Any]]]],
+ dict[str, str],
+ list[dict[str, Any]],
+ ]
+ ] = None,
+ code: Optional[Union[Var[str], str]] = None,
+ transformers: Optional[
+ Union[
+ Var[list[Union[ShikiBaseTransformers, dict[str, Any]]]],
+ list[Union[ShikiBaseTransformers, dict[str, Any]]],
+ ]
+ ] = None,
+ decorations: Optional[
+ Union[Var[list[ShikiDecorations]], list[ShikiDecorations]]
+ ] = None,
+ style: Optional[Style] = None,
+ key: Optional[Any] = None,
+ id: Optional[Any] = None,
+ class_name: Optional[Any] = None,
+ autofocus: Optional[bool] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
+ **props,
+ ) -> "ShikiCodeBlock":
+ """Create a code block component using [shiki syntax highlighter](https://shiki.matsu.io/).
+
+ Args:
+ *children: The children of the component.
+ language: The language to use.
+ theme: The theme to use ("light" or "dark").
+ themes: The set of themes to use for different modes.
+ code: The code to display.
+ transformers: The transformers to use for the syntax highlighter.
+ decorations: The decorations to use for the syntax highlighter.
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: The props to pass to the component.
+
+ Returns:
+ The code block component.
+ """
+ ...
+
+ def add_imports(self) -> dict[str, list[str]]: ...
+ @classmethod
+ def create_transformer(
+ cls, library: str, fns: list[str]
+ ) -> ShikiBaseTransformers: ...
+
+class ShikiHighLevelCodeBlock(ShikiCodeBlock):
+ @overload
+ @classmethod
+ def create( # type: ignore
+ cls,
+ *children,
+ use_transformers: Optional[Union[Var[bool], bool]] = None,
+ show_line_numbers: Optional[Union[Var[bool], bool]] = None,
+ can_copy: Optional[bool] = None,
+ copy_button: Optional[Union[Component, bool]] = None,
+ language: Optional[
+ Union[
+ Literal[
+ "abap",
+ "actionscript-3",
+ "ada",
+ "angular-html",
+ "angular-ts",
+ "apache",
+ "apex",
+ "apl",
+ "applescript",
+ "ara",
+ "asciidoc",
+ "asm",
+ "astro",
+ "awk",
+ "ballerina",
+ "bat",
+ "beancount",
+ "berry",
+ "bibtex",
+ "bicep",
+ "blade",
+ "c",
+ "cadence",
+ "clarity",
+ "clojure",
+ "cmake",
+ "cobol",
+ "codeowners",
+ "codeql",
+ "coffee",
+ "common-lisp",
+ "coq",
+ "cpp",
+ "crystal",
+ "csharp",
+ "css",
+ "csv",
+ "cue",
+ "cypher",
+ "d",
+ "dart",
+ "dax",
+ "desktop",
+ "diff",
+ "docker",
+ "dotenv",
+ "dream-maker",
+ "edge",
+ "elixir",
+ "elm",
+ "emacs-lisp",
+ "erb",
+ "erlang",
+ "fennel",
+ "fish",
+ "fluent",
+ "fortran-fixed-form",
+ "fortran-free-form",
+ "fsharp",
+ "gdresource",
+ "gdscript",
+ "gdshader",
+ "genie",
+ "gherkin",
+ "git-commit",
+ "git-rebase",
+ "gleam",
+ "glimmer-js",
+ "glimmer-ts",
+ "glsl",
+ "gnuplot",
+ "go",
+ "graphql",
+ "groovy",
+ "hack",
+ "haml",
+ "handlebars",
+ "haskell",
+ "haxe",
+ "hcl",
+ "hjson",
+ "hlsl",
+ "html",
+ "html-derivative",
+ "http",
+ "hxml",
+ "hy",
+ "imba",
+ "ini",
+ "java",
+ "javascript",
+ "jinja",
+ "jison",
+ "json",
+ "json5",
+ "jsonc",
+ "jsonl",
+ "jsonnet",
+ "jssm",
+ "jsx",
+ "julia",
+ "kotlin",
+ "kusto",
+ "latex",
+ "lean",
+ "less",
+ "liquid",
+ "log",
+ "logo",
+ "lua",
+ "luau",
+ "make",
+ "markdown",
+ "marko",
+ "matlab",
+ "mdc",
+ "mdx",
+ "mermaid",
+ "mojo",
+ "move",
+ "narrat",
+ "nextflow",
+ "nginx",
+ "nim",
+ "nix",
+ "nushell",
+ "objective-c",
+ "objective-cpp",
+ "ocaml",
+ "pascal",
+ "perl",
+ "php",
+ "plain",
+ "plsql",
+ "po",
+ "postcss",
+ "powerquery",
+ "powershell",
+ "prisma",
+ "prolog",
+ "proto",
+ "pug",
+ "puppet",
+ "purescript",
+ "python",
+ "qml",
+ "qmldir",
+ "qss",
+ "r",
+ "racket",
+ "raku",
+ "razor",
+ "reg",
+ "regexp",
+ "rel",
+ "riscv",
+ "rst",
+ "ruby",
+ "rust",
+ "sas",
+ "sass",
+ "scala",
+ "scheme",
+ "scss",
+ "shaderlab",
+ "shellscript",
+ "shellsession",
+ "smalltalk",
+ "solidity",
+ "soy",
+ "sparql",
+ "splunk",
+ "sql",
+ "ssh-config",
+ "stata",
+ "stylus",
+ "svelte",
+ "swift",
+ "system-verilog",
+ "systemd",
+ "tasl",
+ "tcl",
+ "templ",
+ "terraform",
+ "tex",
+ "toml",
+ "ts-tags",
+ "tsv",
+ "tsx",
+ "turtle",
+ "twig",
+ "typescript",
+ "typespec",
+ "typst",
+ "v",
+ "vala",
+ "vb",
+ "verilog",
+ "vhdl",
+ "viml",
+ "vue",
+ "vue-html",
+ "vyper",
+ "wasm",
+ "wenyan",
+ "wgsl",
+ "wikitext",
+ "wolfram",
+ "xml",
+ "xsl",
+ "yaml",
+ "zenscript",
+ "zig",
+ ],
+ Var[
+ Literal[
+ "abap",
+ "actionscript-3",
+ "ada",
+ "angular-html",
+ "angular-ts",
+ "apache",
+ "apex",
+ "apl",
+ "applescript",
+ "ara",
+ "asciidoc",
+ "asm",
+ "astro",
+ "awk",
+ "ballerina",
+ "bat",
+ "beancount",
+ "berry",
+ "bibtex",
+ "bicep",
+ "blade",
+ "c",
+ "cadence",
+ "clarity",
+ "clojure",
+ "cmake",
+ "cobol",
+ "codeowners",
+ "codeql",
+ "coffee",
+ "common-lisp",
+ "coq",
+ "cpp",
+ "crystal",
+ "csharp",
+ "css",
+ "csv",
+ "cue",
+ "cypher",
+ "d",
+ "dart",
+ "dax",
+ "desktop",
+ "diff",
+ "docker",
+ "dotenv",
+ "dream-maker",
+ "edge",
+ "elixir",
+ "elm",
+ "emacs-lisp",
+ "erb",
+ "erlang",
+ "fennel",
+ "fish",
+ "fluent",
+ "fortran-fixed-form",
+ "fortran-free-form",
+ "fsharp",
+ "gdresource",
+ "gdscript",
+ "gdshader",
+ "genie",
+ "gherkin",
+ "git-commit",
+ "git-rebase",
+ "gleam",
+ "glimmer-js",
+ "glimmer-ts",
+ "glsl",
+ "gnuplot",
+ "go",
+ "graphql",
+ "groovy",
+ "hack",
+ "haml",
+ "handlebars",
+ "haskell",
+ "haxe",
+ "hcl",
+ "hjson",
+ "hlsl",
+ "html",
+ "html-derivative",
+ "http",
+ "hxml",
+ "hy",
+ "imba",
+ "ini",
+ "java",
+ "javascript",
+ "jinja",
+ "jison",
+ "json",
+ "json5",
+ "jsonc",
+ "jsonl",
+ "jsonnet",
+ "jssm",
+ "jsx",
+ "julia",
+ "kotlin",
+ "kusto",
+ "latex",
+ "lean",
+ "less",
+ "liquid",
+ "log",
+ "logo",
+ "lua",
+ "luau",
+ "make",
+ "markdown",
+ "marko",
+ "matlab",
+ "mdc",
+ "mdx",
+ "mermaid",
+ "mojo",
+ "move",
+ "narrat",
+ "nextflow",
+ "nginx",
+ "nim",
+ "nix",
+ "nushell",
+ "objective-c",
+ "objective-cpp",
+ "ocaml",
+ "pascal",
+ "perl",
+ "php",
+ "plain",
+ "plsql",
+ "po",
+ "postcss",
+ "powerquery",
+ "powershell",
+ "prisma",
+ "prolog",
+ "proto",
+ "pug",
+ "puppet",
+ "purescript",
+ "python",
+ "qml",
+ "qmldir",
+ "qss",
+ "r",
+ "racket",
+ "raku",
+ "razor",
+ "reg",
+ "regexp",
+ "rel",
+ "riscv",
+ "rst",
+ "ruby",
+ "rust",
+ "sas",
+ "sass",
+ "scala",
+ "scheme",
+ "scss",
+ "shaderlab",
+ "shellscript",
+ "shellsession",
+ "smalltalk",
+ "solidity",
+ "soy",
+ "sparql",
+ "splunk",
+ "sql",
+ "ssh-config",
+ "stata",
+ "stylus",
+ "svelte",
+ "swift",
+ "system-verilog",
+ "systemd",
+ "tasl",
+ "tcl",
+ "templ",
+ "terraform",
+ "tex",
+ "toml",
+ "ts-tags",
+ "tsv",
+ "tsx",
+ "turtle",
+ "twig",
+ "typescript",
+ "typespec",
+ "typst",
+ "v",
+ "vala",
+ "vb",
+ "verilog",
+ "vhdl",
+ "viml",
+ "vue",
+ "vue-html",
+ "vyper",
+ "wasm",
+ "wenyan",
+ "wgsl",
+ "wikitext",
+ "wolfram",
+ "xml",
+ "xsl",
+ "yaml",
+ "zenscript",
+ "zig",
+ ]
+ ],
+ ]
+ ] = None,
+ theme: Optional[
+ Union[
+ Literal[
+ "andromeeda",
+ "aurora-x",
+ "ayu-dark",
+ "catppuccin-frappe",
+ "catppuccin-latte",
+ "catppuccin-macchiato",
+ "catppuccin-mocha",
+ "dark-plus",
+ "dracula",
+ "dracula-soft",
+ "everforest-dark",
+ "everforest-light",
+ "github-dark",
+ "github-dark-default",
+ "github-dark-dimmed",
+ "github-dark-high-contrast",
+ "github-light",
+ "github-light-default",
+ "github-light-high-contrast",
+ "houston",
+ "laserwave",
+ "light-plus",
+ "material-theme",
+ "material-theme-darker",
+ "material-theme-lighter",
+ "material-theme-ocean",
+ "material-theme-palenight",
+ "min-dark",
+ "min-light",
+ "monokai",
+ "night-owl",
+ "nord",
+ "one-dark-pro",
+ "one-light",
+ "plastic",
+ "poimandres",
+ "red",
+ "rose-pine",
+ "rose-pine-dawn",
+ "rose-pine-moon",
+ "slack-dark",
+ "slack-ochin",
+ "snazzy-light",
+ "solarized-dark",
+ "solarized-light",
+ "synthwave-84",
+ "tokyo-night",
+ "vesper",
+ "vitesse-black",
+ "vitesse-dark",
+ "vitesse-light",
+ ],
+ Var[
+ Literal[
+ "andromeeda",
+ "aurora-x",
+ "ayu-dark",
+ "catppuccin-frappe",
+ "catppuccin-latte",
+ "catppuccin-macchiato",
+ "catppuccin-mocha",
+ "dark-plus",
+ "dracula",
+ "dracula-soft",
+ "everforest-dark",
+ "everforest-light",
+ "github-dark",
+ "github-dark-default",
+ "github-dark-dimmed",
+ "github-dark-high-contrast",
+ "github-light",
+ "github-light-default",
+ "github-light-high-contrast",
+ "houston",
+ "laserwave",
+ "light-plus",
+ "material-theme",
+ "material-theme-darker",
+ "material-theme-lighter",
+ "material-theme-ocean",
+ "material-theme-palenight",
+ "min-dark",
+ "min-light",
+ "monokai",
+ "night-owl",
+ "nord",
+ "one-dark-pro",
+ "one-light",
+ "plastic",
+ "poimandres",
+ "red",
+ "rose-pine",
+ "rose-pine-dawn",
+ "rose-pine-moon",
+ "slack-dark",
+ "slack-ochin",
+ "snazzy-light",
+ "solarized-dark",
+ "solarized-light",
+ "synthwave-84",
+ "tokyo-night",
+ "vesper",
+ "vitesse-black",
+ "vitesse-dark",
+ "vitesse-light",
+ ]
+ ],
+ ]
+ ] = None,
+ themes: Optional[
+ Union[
+ Var[Union[dict[str, str], list[dict[str, Any]]]],
+ dict[str, str],
+ list[dict[str, Any]],
+ ]
+ ] = None,
+ code: Optional[Union[Var[str], str]] = None,
+ transformers: Optional[
+ Union[
+ Var[list[Union[ShikiBaseTransformers, dict[str, Any]]]],
+ list[Union[ShikiBaseTransformers, dict[str, Any]]],
+ ]
+ ] = None,
+ decorations: Optional[
+ Union[Var[list[ShikiDecorations]], list[ShikiDecorations]]
+ ] = None,
+ style: Optional[Style] = None,
+ key: Optional[Any] = None,
+ id: Optional[Any] = None,
+ class_name: Optional[Any] = None,
+ autofocus: Optional[bool] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
+ **props,
+ ) -> "ShikiHighLevelCodeBlock":
+ """Create a code block component using [shiki syntax highlighter](https://shiki.matsu.io/).
+
+ Args:
+ *children: The children of the component.
+ use_transformers: If this is enabled, the default transformers(shikijs transformer) will be used.
+ show_line_numbers: If this is enabled line numbers will be shown next to the code block.
+ can_copy: Whether a copy button should appear.
+ copy_button: copy_button: A custom copy button to override the default one.
+ language: The language to use.
+ theme: The theme to use ("light" or "dark").
+ themes: The set of themes to use for different modes.
+ code: The code to display.
+ transformers: The transformers to use for the syntax highlighter.
+ decorations: The decorations to use for the syntax highlighter.
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: The props to pass to the component.
+
+ Returns:
+ The code block component.
+ """
+ ...
+
+class TransformerNamespace(ComponentNamespace):
+ shikijs = ShikiJsTransformer
+
+class CodeblockNamespace(ComponentNamespace):
+ root = staticmethod(ShikiCodeBlock.create)
+ create_transformer = staticmethod(ShikiCodeBlock.create_transformer)
+ transformers = TransformerNamespace()
+
+ @staticmethod
+ def __call__(
+ *children,
+ use_transformers: Optional[Union[Var[bool], bool]] = None,
+ show_line_numbers: Optional[Union[Var[bool], bool]] = None,
+ can_copy: Optional[bool] = None,
+ copy_button: Optional[Union[Component, bool]] = None,
+ language: Optional[
+ Union[
+ Literal[
+ "abap",
+ "actionscript-3",
+ "ada",
+ "angular-html",
+ "angular-ts",
+ "apache",
+ "apex",
+ "apl",
+ "applescript",
+ "ara",
+ "asciidoc",
+ "asm",
+ "astro",
+ "awk",
+ "ballerina",
+ "bat",
+ "beancount",
+ "berry",
+ "bibtex",
+ "bicep",
+ "blade",
+ "c",
+ "cadence",
+ "clarity",
+ "clojure",
+ "cmake",
+ "cobol",
+ "codeowners",
+ "codeql",
+ "coffee",
+ "common-lisp",
+ "coq",
+ "cpp",
+ "crystal",
+ "csharp",
+ "css",
+ "csv",
+ "cue",
+ "cypher",
+ "d",
+ "dart",
+ "dax",
+ "desktop",
+ "diff",
+ "docker",
+ "dotenv",
+ "dream-maker",
+ "edge",
+ "elixir",
+ "elm",
+ "emacs-lisp",
+ "erb",
+ "erlang",
+ "fennel",
+ "fish",
+ "fluent",
+ "fortran-fixed-form",
+ "fortran-free-form",
+ "fsharp",
+ "gdresource",
+ "gdscript",
+ "gdshader",
+ "genie",
+ "gherkin",
+ "git-commit",
+ "git-rebase",
+ "gleam",
+ "glimmer-js",
+ "glimmer-ts",
+ "glsl",
+ "gnuplot",
+ "go",
+ "graphql",
+ "groovy",
+ "hack",
+ "haml",
+ "handlebars",
+ "haskell",
+ "haxe",
+ "hcl",
+ "hjson",
+ "hlsl",
+ "html",
+ "html-derivative",
+ "http",
+ "hxml",
+ "hy",
+ "imba",
+ "ini",
+ "java",
+ "javascript",
+ "jinja",
+ "jison",
+ "json",
+ "json5",
+ "jsonc",
+ "jsonl",
+ "jsonnet",
+ "jssm",
+ "jsx",
+ "julia",
+ "kotlin",
+ "kusto",
+ "latex",
+ "lean",
+ "less",
+ "liquid",
+ "log",
+ "logo",
+ "lua",
+ "luau",
+ "make",
+ "markdown",
+ "marko",
+ "matlab",
+ "mdc",
+ "mdx",
+ "mermaid",
+ "mojo",
+ "move",
+ "narrat",
+ "nextflow",
+ "nginx",
+ "nim",
+ "nix",
+ "nushell",
+ "objective-c",
+ "objective-cpp",
+ "ocaml",
+ "pascal",
+ "perl",
+ "php",
+ "plain",
+ "plsql",
+ "po",
+ "postcss",
+ "powerquery",
+ "powershell",
+ "prisma",
+ "prolog",
+ "proto",
+ "pug",
+ "puppet",
+ "purescript",
+ "python",
+ "qml",
+ "qmldir",
+ "qss",
+ "r",
+ "racket",
+ "raku",
+ "razor",
+ "reg",
+ "regexp",
+ "rel",
+ "riscv",
+ "rst",
+ "ruby",
+ "rust",
+ "sas",
+ "sass",
+ "scala",
+ "scheme",
+ "scss",
+ "shaderlab",
+ "shellscript",
+ "shellsession",
+ "smalltalk",
+ "solidity",
+ "soy",
+ "sparql",
+ "splunk",
+ "sql",
+ "ssh-config",
+ "stata",
+ "stylus",
+ "svelte",
+ "swift",
+ "system-verilog",
+ "systemd",
+ "tasl",
+ "tcl",
+ "templ",
+ "terraform",
+ "tex",
+ "toml",
+ "ts-tags",
+ "tsv",
+ "tsx",
+ "turtle",
+ "twig",
+ "typescript",
+ "typespec",
+ "typst",
+ "v",
+ "vala",
+ "vb",
+ "verilog",
+ "vhdl",
+ "viml",
+ "vue",
+ "vue-html",
+ "vyper",
+ "wasm",
+ "wenyan",
+ "wgsl",
+ "wikitext",
+ "wolfram",
+ "xml",
+ "xsl",
+ "yaml",
+ "zenscript",
+ "zig",
+ ],
+ Var[
+ Literal[
+ "abap",
+ "actionscript-3",
+ "ada",
+ "angular-html",
+ "angular-ts",
+ "apache",
+ "apex",
+ "apl",
+ "applescript",
+ "ara",
+ "asciidoc",
+ "asm",
+ "astro",
+ "awk",
+ "ballerina",
+ "bat",
+ "beancount",
+ "berry",
+ "bibtex",
+ "bicep",
+ "blade",
+ "c",
+ "cadence",
+ "clarity",
+ "clojure",
+ "cmake",
+ "cobol",
+ "codeowners",
+ "codeql",
+ "coffee",
+ "common-lisp",
+ "coq",
+ "cpp",
+ "crystal",
+ "csharp",
+ "css",
+ "csv",
+ "cue",
+ "cypher",
+ "d",
+ "dart",
+ "dax",
+ "desktop",
+ "diff",
+ "docker",
+ "dotenv",
+ "dream-maker",
+ "edge",
+ "elixir",
+ "elm",
+ "emacs-lisp",
+ "erb",
+ "erlang",
+ "fennel",
+ "fish",
+ "fluent",
+ "fortran-fixed-form",
+ "fortran-free-form",
+ "fsharp",
+ "gdresource",
+ "gdscript",
+ "gdshader",
+ "genie",
+ "gherkin",
+ "git-commit",
+ "git-rebase",
+ "gleam",
+ "glimmer-js",
+ "glimmer-ts",
+ "glsl",
+ "gnuplot",
+ "go",
+ "graphql",
+ "groovy",
+ "hack",
+ "haml",
+ "handlebars",
+ "haskell",
+ "haxe",
+ "hcl",
+ "hjson",
+ "hlsl",
+ "html",
+ "html-derivative",
+ "http",
+ "hxml",
+ "hy",
+ "imba",
+ "ini",
+ "java",
+ "javascript",
+ "jinja",
+ "jison",
+ "json",
+ "json5",
+ "jsonc",
+ "jsonl",
+ "jsonnet",
+ "jssm",
+ "jsx",
+ "julia",
+ "kotlin",
+ "kusto",
+ "latex",
+ "lean",
+ "less",
+ "liquid",
+ "log",
+ "logo",
+ "lua",
+ "luau",
+ "make",
+ "markdown",
+ "marko",
+ "matlab",
+ "mdc",
+ "mdx",
+ "mermaid",
+ "mojo",
+ "move",
+ "narrat",
+ "nextflow",
+ "nginx",
+ "nim",
+ "nix",
+ "nushell",
+ "objective-c",
+ "objective-cpp",
+ "ocaml",
+ "pascal",
+ "perl",
+ "php",
+ "plain",
+ "plsql",
+ "po",
+ "postcss",
+ "powerquery",
+ "powershell",
+ "prisma",
+ "prolog",
+ "proto",
+ "pug",
+ "puppet",
+ "purescript",
+ "python",
+ "qml",
+ "qmldir",
+ "qss",
+ "r",
+ "racket",
+ "raku",
+ "razor",
+ "reg",
+ "regexp",
+ "rel",
+ "riscv",
+ "rst",
+ "ruby",
+ "rust",
+ "sas",
+ "sass",
+ "scala",
+ "scheme",
+ "scss",
+ "shaderlab",
+ "shellscript",
+ "shellsession",
+ "smalltalk",
+ "solidity",
+ "soy",
+ "sparql",
+ "splunk",
+ "sql",
+ "ssh-config",
+ "stata",
+ "stylus",
+ "svelte",
+ "swift",
+ "system-verilog",
+ "systemd",
+ "tasl",
+ "tcl",
+ "templ",
+ "terraform",
+ "tex",
+ "toml",
+ "ts-tags",
+ "tsv",
+ "tsx",
+ "turtle",
+ "twig",
+ "typescript",
+ "typespec",
+ "typst",
+ "v",
+ "vala",
+ "vb",
+ "verilog",
+ "vhdl",
+ "viml",
+ "vue",
+ "vue-html",
+ "vyper",
+ "wasm",
+ "wenyan",
+ "wgsl",
+ "wikitext",
+ "wolfram",
+ "xml",
+ "xsl",
+ "yaml",
+ "zenscript",
+ "zig",
+ ]
+ ],
+ ]
+ ] = None,
+ theme: Optional[
+ Union[
+ Literal[
+ "andromeeda",
+ "aurora-x",
+ "ayu-dark",
+ "catppuccin-frappe",
+ "catppuccin-latte",
+ "catppuccin-macchiato",
+ "catppuccin-mocha",
+ "dark-plus",
+ "dracula",
+ "dracula-soft",
+ "everforest-dark",
+ "everforest-light",
+ "github-dark",
+ "github-dark-default",
+ "github-dark-dimmed",
+ "github-dark-high-contrast",
+ "github-light",
+ "github-light-default",
+ "github-light-high-contrast",
+ "houston",
+ "laserwave",
+ "light-plus",
+ "material-theme",
+ "material-theme-darker",
+ "material-theme-lighter",
+ "material-theme-ocean",
+ "material-theme-palenight",
+ "min-dark",
+ "min-light",
+ "monokai",
+ "night-owl",
+ "nord",
+ "one-dark-pro",
+ "one-light",
+ "plastic",
+ "poimandres",
+ "red",
+ "rose-pine",
+ "rose-pine-dawn",
+ "rose-pine-moon",
+ "slack-dark",
+ "slack-ochin",
+ "snazzy-light",
+ "solarized-dark",
+ "solarized-light",
+ "synthwave-84",
+ "tokyo-night",
+ "vesper",
+ "vitesse-black",
+ "vitesse-dark",
+ "vitesse-light",
+ ],
+ Var[
+ Literal[
+ "andromeeda",
+ "aurora-x",
+ "ayu-dark",
+ "catppuccin-frappe",
+ "catppuccin-latte",
+ "catppuccin-macchiato",
+ "catppuccin-mocha",
+ "dark-plus",
+ "dracula",
+ "dracula-soft",
+ "everforest-dark",
+ "everforest-light",
+ "github-dark",
+ "github-dark-default",
+ "github-dark-dimmed",
+ "github-dark-high-contrast",
+ "github-light",
+ "github-light-default",
+ "github-light-high-contrast",
+ "houston",
+ "laserwave",
+ "light-plus",
+ "material-theme",
+ "material-theme-darker",
+ "material-theme-lighter",
+ "material-theme-ocean",
+ "material-theme-palenight",
+ "min-dark",
+ "min-light",
+ "monokai",
+ "night-owl",
+ "nord",
+ "one-dark-pro",
+ "one-light",
+ "plastic",
+ "poimandres",
+ "red",
+ "rose-pine",
+ "rose-pine-dawn",
+ "rose-pine-moon",
+ "slack-dark",
+ "slack-ochin",
+ "snazzy-light",
+ "solarized-dark",
+ "solarized-light",
+ "synthwave-84",
+ "tokyo-night",
+ "vesper",
+ "vitesse-black",
+ "vitesse-dark",
+ "vitesse-light",
+ ]
+ ],
+ ]
+ ] = None,
+ themes: Optional[
+ Union[
+ Var[Union[dict[str, str], list[dict[str, Any]]]],
+ dict[str, str],
+ list[dict[str, Any]],
+ ]
+ ] = None,
+ code: Optional[Union[Var[str], str]] = None,
+ transformers: Optional[
+ Union[
+ Var[list[Union[ShikiBaseTransformers, dict[str, Any]]]],
+ list[Union[ShikiBaseTransformers, dict[str, Any]]],
+ ]
+ ] = None,
+ decorations: Optional[
+ Union[Var[list[ShikiDecorations]], list[ShikiDecorations]]
+ ] = None,
+ style: Optional[Style] = None,
+ key: Optional[Any] = None,
+ id: Optional[Any] = None,
+ class_name: Optional[Any] = None,
+ autofocus: Optional[bool] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
+ **props,
+ ) -> "ShikiHighLevelCodeBlock":
+ """Create a code block component using [shiki syntax highlighter](https://shiki.matsu.io/).
+
+ Args:
+ *children: The children of the component.
+ use_transformers: If this is enabled, the default transformers(shikijs transformer) will be used.
+ show_line_numbers: If this is enabled line numbers will be shown next to the code block.
+ can_copy: Whether a copy button should appear.
+ copy_button: copy_button: A custom copy button to override the default one.
+ language: The language to use.
+ theme: The theme to use ("light" or "dark").
+ themes: The set of themes to use for different modes.
+ code: The code to display.
+ transformers: The transformers to use for the syntax highlighter.
+ decorations: The decorations to use for the syntax highlighter.
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: The props to pass to the component.
+
+ Returns:
+ The code block component.
+ """
+ ...
+
+code_block = CodeblockNamespace()
diff --git a/reflex/components/dynamic.py b/reflex/components/dynamic.py
new file mode 100644
index 000000000..fbfc55f97
--- /dev/null
+++ b/reflex/components/dynamic.py
@@ -0,0 +1,190 @@
+"""Components that are dynamically generated on the backend."""
+
+from typing import TYPE_CHECKING, Union
+
+from reflex import constants
+from reflex.utils import imports
+from reflex.utils.exceptions import DynamicComponentMissingLibrary
+from reflex.utils.format import format_library_name
+from reflex.utils.serializers import serializer
+from reflex.vars import Var, get_unique_variable_name
+from reflex.vars.base import VarData, transform
+
+if TYPE_CHECKING:
+ from reflex.components.component import Component
+
+
+def get_cdn_url(lib: str) -> str:
+ """Get the CDN URL for a library.
+
+ Args:
+ lib: The library to get the CDN URL for.
+
+ Returns:
+ The CDN URL for the library.
+ """
+ return f"https://cdn.jsdelivr.net/npm/{lib}" + "/+esm"
+
+
+bundled_libraries = {"react", "@radix-ui/themes", "@emotion/react", "next/link"}
+
+
+def bundle_library(component: Union["Component", str]):
+ """Bundle a library with the component.
+
+ Args:
+ component: The component to bundle the library with.
+
+ Raises:
+ DynamicComponentMissingLibrary: Raised when a dynamic component is missing a library.
+ """
+ if isinstance(component, str):
+ bundled_libraries.add(component)
+ return
+ if component.library is None:
+ raise DynamicComponentMissingLibrary("Component must have a library to bundle.")
+ bundled_libraries.add(format_library_name(component.library))
+
+
+def load_dynamic_serializer():
+ """Load the serializer for dynamic components."""
+ # Causes a circular import, so we import here.
+ from reflex.components.component import Component
+
+ @serializer
+ def make_component(component: Component) -> str:
+ """Generate the code for a dynamic component.
+
+ Args:
+ component: The component to generate code for.
+
+ Returns:
+ The generated code
+ """
+ # Causes a circular import, so we import here.
+ from reflex.compiler import templates, utils
+ from reflex.components.base.bare import Bare
+
+ component = Bare.create(Var.create(component))
+
+ rendered_components = {}
+ # Include dynamic imports in the shared component.
+ if dynamic_imports := component._get_all_dynamic_imports():
+ rendered_components.update(
+ {dynamic_import: None for dynamic_import in dynamic_imports}
+ )
+
+ # Include custom code in the shared component.
+ rendered_components.update(
+ {code: None for code in component._get_all_custom_code()},
+ )
+
+ rendered_components[
+ templates.STATEFUL_COMPONENT.render(
+ tag_name="MySSRComponent",
+ memo_trigger_hooks=[],
+ component=component,
+ )
+ ] = None
+
+ libs_in_window = bundled_libraries
+
+ imports = {}
+ for lib, names in component._get_all_imports().items():
+ formatted_lib_name = format_library_name(lib)
+ if (
+ not lib.startswith((".", "/", "$/"))
+ and not lib.startswith("http")
+ and formatted_lib_name not in libs_in_window
+ ):
+ imports[get_cdn_url(lib)] = names
+ else:
+ imports[lib] = names
+
+ module_code_lines = templates.STATEFUL_COMPONENTS.render(
+ imports=utils.compile_imports(imports),
+ memoized_code="\n".join(rendered_components),
+ ).splitlines()[1:]
+
+ # Rewrite imports from `/` to destructure from window
+ for ix, line in enumerate(module_code_lines[:]):
+ if line.startswith("import "):
+ if 'from "$/' in line or 'from "/' in line:
+ module_code_lines[ix] = (
+ line.replace("import ", "const ", 1)
+ .replace(" as ", ": ")
+ .replace(" from ", " = window['__reflex'][", 1)
+ + "]"
+ )
+ else:
+ for lib in libs_in_window:
+ if f'from "{lib}"' in line:
+ module_code_lines[ix] = (
+ line.replace("import ", "const ", 1)
+ .replace(
+ f' from "{lib}"', f" = window.__reflex['{lib}']", 1
+ )
+ .replace(" as ", ": ")
+ )
+ if line.startswith("export function"):
+ module_code_lines[ix] = line.replace(
+ "export function", "export default function", 1
+ )
+ line_stripped = line.strip()
+ if line_stripped.startswith("{") and line_stripped.endswith("}"):
+ module_code_lines[ix] = line_stripped[1:-1]
+
+ module_code_lines.insert(0, "const React = window.__reflex.react;")
+
+ return "\n".join(
+ [
+ "//__reflex_evaluate",
+ *module_code_lines,
+ ]
+ )
+
+ @transform
+ def evaluate_component(js_string: Var[str]) -> Var[Component]:
+ """Evaluate a component.
+
+ Args:
+ js_string: The JavaScript string to evaluate.
+
+ Returns:
+ The evaluated JavaScript string.
+ """
+ unique_var_name = get_unique_variable_name()
+
+ return js_string._replace(
+ _js_expr=unique_var_name,
+ _var_type=Component,
+ merge_var_data=VarData.merge(
+ VarData(
+ imports={
+ f"$/{constants.Dirs.STATE_PATH}": [
+ imports.ImportVar(tag="evalReactComponent"),
+ ],
+ "react": [
+ imports.ImportVar(tag="useState"),
+ imports.ImportVar(tag="useEffect"),
+ ],
+ },
+ hooks={
+ f"const [{unique_var_name}, set_{unique_var_name}] = useState(null);": None,
+ "useEffect(() => {"
+ "let isMounted = true;"
+ f"evalReactComponent({js_string!s})"
+ ".then((component) => {"
+ "if (isMounted) {"
+ f"set_{unique_var_name}(component);"
+ "}"
+ "});"
+ "return () => {"
+ "isMounted = false;"
+ "};"
+ "}"
+ f", [{js_string!s}]);": None,
+ },
+ ),
+ ),
+ )
diff --git a/reflex/components/el/__init__.py b/reflex/components/el/__init__.py
index 9fe1d89cd..750e65dba 100644
--- a/reflex/components/el/__init__.py
+++ b/reflex/components/el/__init__.py
@@ -10,7 +10,6 @@ _SUBMODULES: set[str] = {"elements"}
_SUBMOD_ATTRS: dict[str, list[str]] = {
f"elements.{k}": v for k, v in elements._MAPPING.items()
}
-_PYRIGHT_IGNORE_IMPORTS = elements._PYRIGHT_IGNORE_IMPORTS
__getattr__, __dir__, __all__ = lazy_loader.attach(
__name__,
diff --git a/reflex/components/el/__init__.pyi b/reflex/components/el/__init__.pyi
index d312db84e..cbfb65f58 100644
--- a/reflex/components/el/__init__.pyi
+++ b/reflex/components/el/__init__.pyi
@@ -3,8 +3,9 @@
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from . import elements
+from . import elements as elements
from .elements.forms import Button as Button
+from .elements.forms import Datalist as Datalist
from .elements.forms import Fieldset as Fieldset
from .elements.forms import Form as Form
from .elements.forms import Input as Input
@@ -18,6 +19,7 @@ from .elements.forms import Progress as Progress
from .elements.forms import Select as Select
from .elements.forms import Textarea as Textarea
from .elements.forms import button as button
+from .elements.forms import datalist as datalist
from .elements.forms import fieldset as fieldset
from .elements.forms import form as form
from .elements.forms import input as input
@@ -88,36 +90,28 @@ from .elements.inline import u as u
from .elements.inline import wbr as wbr
from .elements.media import Area as Area
from .elements.media import Audio as Audio
-from .elements.media import Defs as Defs
from .elements.media import Embed as Embed
from .elements.media import Iframe as Iframe
from .elements.media import Img as Img
-from .elements.media import LinearGradient as LinearGradient
from .elements.media import Map as Map
from .elements.media import Object as Object
-from .elements.media import Path as Path
from .elements.media import Picture as Picture
from .elements.media import Portal as Portal
from .elements.media import Source as Source
-from .elements.media import Stop as Stop
from .elements.media import Svg as Svg
from .elements.media import Track as Track
from .elements.media import Video as Video
from .elements.media import area as area
from .elements.media import audio as audio
-from .elements.media import defs as defs # type: ignore
from .elements.media import embed as embed
from .elements.media import iframe as iframe
from .elements.media import image as image
from .elements.media import img as img
-from .elements.media import lineargradient as lineargradient # type: ignore
from .elements.media import map as map
from .elements.media import object as object
-from .elements.media import path as path # type: ignore
from .elements.media import picture as picture
from .elements.media import portal as portal
from .elements.media import source as source
-from .elements.media import stop as stop # type: ignore
from .elements.media import svg as svg
from .elements.media import track as track
from .elements.media import video as video
@@ -231,5 +225,3 @@ from .elements.typography import ol as ol
from .elements.typography import p as p
from .elements.typography import pre as pre
from .elements.typography import ul as ul
-
-_PYRIGHT_IGNORE_IMPORTS = elements._PYRIGHT_IGNORE_IMPORTS
diff --git a/reflex/components/el/element.pyi b/reflex/components/el/element.pyi
index ce87335c3..de5dee956 100644
--- a/reflex/components/el/element.pyi
+++ b/reflex/components/el/element.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class Element(Component):
@overload
@@ -21,52 +21,22 @@ class Element(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Element":
"""Create the component.
diff --git a/reflex/components/el/elements/__init__.py b/reflex/components/el/elements/__init__.py
index 024ae8c3d..f0d4fd200 100644
--- a/reflex/components/el/elements/__init__.py
+++ b/reflex/components/el/elements/__init__.py
@@ -7,6 +7,7 @@ from reflex.utils import lazy_loader
_MAPPING = {
"forms": [
"button",
+ "datalist",
"fieldset",
"form",
"input",
@@ -65,11 +66,6 @@ _MAPPING = {
"portal",
"source",
"svg",
- "defs",
- "lineargradient",
- "LinearGradient",
- "stop",
- "path",
],
"metadata": [
"base",
@@ -130,13 +126,12 @@ _MAPPING = {
}
-EXCLUDE = ["del_", "Del", "image", "lineargradient", "LinearGradient"]
-for _, v in _MAPPING.items():
+EXCLUDE = ["del_", "Del", "image"]
+for v in _MAPPING.values():
v.extend([mod.capitalize() for mod in v if mod not in EXCLUDE])
_SUBMOD_ATTRS: dict[str, list[str]] = _MAPPING
-_PYRIGHT_IGNORE_IMPORTS = ["stop", "lineargradient", "path", "defs"]
__getattr__, __dir__, __all__ = lazy_loader.attach(
__name__,
submod_attrs=_SUBMOD_ATTRS,
diff --git a/reflex/components/el/elements/__init__.pyi b/reflex/components/el/elements/__init__.pyi
index 4f218f361..defaa5848 100644
--- a/reflex/components/el/elements/__init__.pyi
+++ b/reflex/components/el/elements/__init__.pyi
@@ -4,6 +4,7 @@
# ------------------------------------------------------
from .forms import Button as Button
+from .forms import Datalist as Datalist
from .forms import Fieldset as Fieldset
from .forms import Form as Form
from .forms import Input as Input
@@ -17,6 +18,7 @@ from .forms import Progress as Progress
from .forms import Select as Select
from .forms import Textarea as Textarea
from .forms import button as button
+from .forms import datalist as datalist
from .forms import fieldset as fieldset
from .forms import form as form
from .forms import input as input
@@ -87,36 +89,28 @@ from .inline import u as u
from .inline import wbr as wbr
from .media import Area as Area
from .media import Audio as Audio
-from .media import Defs as Defs
from .media import Embed as Embed
from .media import Iframe as Iframe
from .media import Img as Img
-from .media import LinearGradient as LinearGradient
from .media import Map as Map
from .media import Object as Object
-from .media import Path as Path
from .media import Picture as Picture
from .media import Portal as Portal
from .media import Source as Source
-from .media import Stop as Stop
from .media import Svg as Svg
from .media import Track as Track
from .media import Video as Video
from .media import area as area
from .media import audio as audio
-from .media import defs as defs # type: ignore
from .media import embed as embed
from .media import iframe as iframe
from .media import image as image
from .media import img as img
-from .media import lineargradient as lineargradient # type: ignore
from .media import map as map
from .media import object as object
-from .media import path as path # type: ignore
from .media import picture as picture
from .media import portal as portal
from .media import source as source
-from .media import stop as stop # type: ignore
from .media import svg as svg
from .media import track as track
from .media import video as video
@@ -234,6 +228,7 @@ from .typography import ul as ul
_MAPPING = {
"forms": [
"button",
+ "datalist",
"fieldset",
"form",
"input",
@@ -292,11 +287,6 @@ _MAPPING = {
"portal",
"source",
"svg",
- "defs",
- "lineargradient",
- "LinearGradient",
- "stop",
- "path",
],
"metadata": ["base", "head", "link", "meta", "title", "style"],
"other": ["details", "dialog", "summary", "slot", "template", "math", "html"],
@@ -348,7 +338,6 @@ _MAPPING = {
"Del",
],
}
-EXCLUDE = ["del_", "Del", "image", "lineargradient", "LinearGradient"]
-for _, v in _MAPPING.items():
+EXCLUDE = ["del_", "Del", "image"]
+for v in _MAPPING.values():
v.extend([mod.capitalize() for mod in v if mod not in EXCLUDE])
-_PYRIGHT_IGNORE_IMPORTS = ["stop", "lineargradient", "path", "defs"]
diff --git a/reflex/components/el/elements/base.py b/reflex/components/el/elements/base.py
index 5eb8aa70c..f6e191f68 100644
--- a/reflex/components/el/elements/base.py
+++ b/reflex/components/el/elements/base.py
@@ -1,15 +1,15 @@
-"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
+"""Base classes."""
from typing import Union
from reflex.components.el.element import Element
-from reflex.vars import Var as Var
+from reflex.vars.base import Var
class BaseHTML(Element):
"""Base class for common attributes."""
- # Provides a hint for generating a keyboard shortcut for the current element.
+ # Provides a hint for generating a keyboard shortcut for the current element.
access_key: Var[Union[str, int, bool]]
# Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
diff --git a/reflex/components/el/elements/base.pyi b/reflex/components/el/elements/base.pyi
index 14ee5b62c..b60dabe87 100644
--- a/reflex/components/el/elements/base.pyi
+++ b/reflex/components/el/elements/base.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
from reflex.components.el.element import Element
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class BaseHTML(Element):
@overload
@@ -16,88 +16,58 @@ class BaseHTML(Element):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "BaseHTML":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/el/elements/forms.py b/reflex/components/el/elements/forms.py
index cdad212aa..61ded4fd3 100644
--- a/reflex/components/el/elements/forms.py
+++ b/reflex/components/el/elements/forms.py
@@ -1,31 +1,38 @@
-"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
+"""Forms classes."""
from __future__ import annotations
from hashlib import md5
-from typing import Any, Dict, Iterator, Set, Union
+from typing import Any, Dict, Iterator, Set, Tuple, Union
from jinja2 import Environment
from reflex.components.el.element import Element
from reflex.components.tags.tag import Tag
from reflex.constants import Dirs, EventTriggers
-from reflex.event import EventChain, EventHandler
-from reflex.utils.format import format_event_chain
+from reflex.event import (
+ EventChain,
+ EventHandler,
+ input_event,
+ key_event,
+ prevent_default,
+)
from reflex.utils.imports import ImportDict
-from reflex.vars import BaseVar, Var
+from reflex.utils.types import is_optional
+from reflex.vars import VarData
+from reflex.vars.base import LiteralVar, Var
from .base import BaseHTML
-FORM_DATA = Var.create("form_data", _var_is_string=False)
+FORM_DATA = Var(_js_expr="form_data")
HANDLE_SUBMIT_JS_JINJA2 = Environment().from_string(
"""
const handleSubmit_{{ handle_submit_unique_name }} = useCallback((ev) => {
const $form = ev.target
ev.preventDefault()
- const {{ form_data }} = {...Object.fromEntries(new FormData($form).entries()), ...{{ field_ref_mapping }}}
+ const {{ form_data }} = {...Object.fromEntries(new FormData($form).entries()), ...{{ field_ref_mapping }}};
- {{ on_submit_event_chain }}
+ ({{ on_submit_event_chain }}());
if ({{ reset_on_submit }}) {
$form.reset()
@@ -78,7 +85,6 @@ class Datalist(BaseHTML):
"""Display the datalist element."""
tag = "datalist"
- # No unique attributes, only common ones are inherited
class Fieldset(Element):
@@ -96,6 +102,24 @@ class Fieldset(Element):
name: Var[Union[str, int, bool]]
+def on_submit_event_spec() -> Tuple[Var[Dict[str, Any]]]:
+ """Event handler spec for the on_submit event.
+
+ Returns:
+ The event handler spec.
+ """
+ return (FORM_DATA,)
+
+
+def on_submit_string_event_spec() -> Tuple[Var[Dict[str, str]]]:
+ """Event handler spec for the on_submit event.
+
+ Returns:
+ The event handler spec.
+ """
+ return (FORM_DATA,)
+
+
class Form(BaseHTML):
"""Display the form element."""
@@ -135,7 +159,7 @@ class Form(BaseHTML):
handle_submit_unique_name: Var[str]
# Fired when the form is submitted
- on_submit: EventHandler[lambda e0: [FORM_DATA]]
+ on_submit: EventHandler[on_submit_event_spec, on_submit_string_event_spec]
@classmethod
def create(cls, *children, **props):
@@ -148,6 +172,9 @@ class Form(BaseHTML):
Returns:
The form component.
"""
+ if "on_submit" not in props:
+ props["on_submit"] = prevent_default
+
if "handle_submit_unique_name" in props:
return super().create(*children, **props)
@@ -169,7 +196,7 @@ class Form(BaseHTML):
"""
return {
"react": "useCallback",
- f"/{Dirs.STATE_PATH}": ["getRefValue", "getRefValues"],
+ f"$/{Dirs.STATE_PATH}": ["getRefValue", "getRefValues"],
}
def add_hooks(self) -> list[str]:
@@ -184,9 +211,9 @@ class Form(BaseHTML):
HANDLE_SUBMIT_JS_JINJA2.render(
handle_submit_unique_name=self.handle_submit_unique_name,
form_data=FORM_DATA,
- field_ref_mapping=str(Var.create_safe(self._get_form_refs())),
- on_submit_event_chain=format_event_chain(
- self.event_triggers[EventTriggers.ON_SUBMIT]
+ field_ref_mapping=str(LiteralVar.create(self._get_form_refs())),
+ on_submit_event_chain=str(
+ LiteralVar.create(self.event_triggers[EventTriggers.ON_SUBMIT])
),
reset_on_submit=self.reset_on_submit,
)
@@ -197,8 +224,8 @@ class Form(BaseHTML):
if EventTriggers.ON_SUBMIT in self.event_triggers:
render_tag.add_props(
**{
- EventTriggers.ON_SUBMIT: BaseVar(
- _var_name=f"handleSubmit_{self.handle_submit_unique_name}",
+ EventTriggers.ON_SUBMIT: Var(
+ _js_expr=f"handleSubmit_{self.handle_submit_unique_name}",
_var_type=EventChain,
)
}
@@ -212,20 +239,16 @@ class Form(BaseHTML):
# when ref start with refs_ it's an array of refs, so we need different method
# to collect data
if ref.startswith("refs_"):
- ref_var = Var.create_safe(ref[:-3], _var_is_string=False).as_ref()
- form_refs[ref[5:-3]] = Var.create_safe(
- f"getRefValues({str(ref_var)})",
- _var_is_local=False,
- _var_is_string=False,
- _var_data=ref_var._var_data,
+ ref_var = Var(_js_expr=ref[:-3])._as_ref()
+ form_refs[ref[len("refs_") : -3]] = Var(
+ _js_expr=f"getRefValues({ref_var!s})",
+ _var_data=VarData.merge(ref_var._get_all_var_data()),
)
else:
- ref_var = Var.create_safe(ref, _var_is_string=False).as_ref()
- form_refs[ref[4:]] = Var.create_safe(
- f"getRefValue({str(ref_var)})",
- _var_is_local=False,
- _var_is_string=False,
- _var_data=ref_var._var_data,
+ ref_var = Var(_js_expr=ref)._as_ref()
+ form_refs[ref[4:]] = Var(
+ _js_expr=f"getRefValue({ref_var!s})",
+ _var_data=VarData.merge(ref_var._get_all_var_data()),
)
return form_refs
@@ -234,7 +257,8 @@ class Form(BaseHTML):
yield from self._get_form_refs().values()
def _exclude_props(self) -> list[str]:
- return super()._exclude_props() + [
+ return [
+ *super()._exclude_props(),
"reset_on_submit",
"handle_submit_unique_name",
]
@@ -345,19 +369,46 @@ class Input(BaseHTML):
value: Var[Union[str, int, float]]
# Fired when the input value changes
- on_change: EventHandler[lambda e0: [e0.target.value]]
+ on_change: EventHandler[input_event]
# Fired when the input gains focus
- on_focus: EventHandler[lambda e0: [e0.target.value]]
+ on_focus: EventHandler[input_event]
# Fired when the input loses focus
- on_blur: EventHandler[lambda e0: [e0.target.value]]
+ on_blur: EventHandler[input_event]
# Fired when a key is pressed down
- on_key_down: EventHandler[lambda e0: [e0.key]]
+ on_key_down: EventHandler[key_event]
# Fired when a key is released
- on_key_up: EventHandler[lambda e0: [e0.key]]
+ on_key_up: EventHandler[key_event]
+
+ @classmethod
+ def create(cls, *children, **props):
+ """Create an Input component.
+
+ Args:
+ *children: The children of the component.
+ **props: The properties of the component.
+
+ Returns:
+ The component.
+ """
+ from reflex.vars.number import ternary_operation
+
+ value = props.get("value")
+
+ # React expects an empty string(instead of null) for controlled inputs.
+ if value is not None and is_optional(
+ (value_var := Var.create(value))._var_type
+ ):
+ props["value"] = ternary_operation(
+ (value_var != Var.create(None)) # pyright: ignore [reportGeneralTypeIssues]
+ & (value_var != Var(_js_expr="undefined")),
+ value,
+ Var.create(""),
+ )
+ return super().create(*children, **props)
class Label(BaseHTML):
@@ -376,7 +427,6 @@ class Legend(BaseHTML):
"""Display the legend element."""
tag = "legend"
- # No unique attributes, only common ones are inherited
class Meter(BaseHTML):
@@ -496,14 +546,14 @@ class Select(BaseHTML):
size: Var[Union[str, int, bool]]
# Fired when the select value changes
- on_change: EventHandler[lambda e0: [e0.target.value]]
+ on_change: EventHandler[input_event]
AUTO_HEIGHT_JS = """
const autoHeightOnInput = (e, is_enabled) => {
if (is_enabled) {
const el = e.target;
- el.style.overflowY = "hidden";
+ el.style.overflowY = "scroll";
el.style.height = "auto";
el.style.height = (e.target.scrollHeight) + "px";
if (el.form && !el.form.data_resize_on_reset) {
@@ -546,6 +596,9 @@ class Textarea(BaseHTML):
# Visible width of the text control, in average character widths
cols: Var[Union[str, int, bool]]
+ # The default value of the textarea when initially rendered
+ default_value: Var[str]
+
# Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
dirname: Var[Union[str, int, bool]]
@@ -586,22 +639,59 @@ class Textarea(BaseHTML):
wrap: Var[Union[str, int, bool]]
# Fired when the input value changes
- on_change: EventHandler[lambda e0: [e0.target.value]]
+ on_change: EventHandler[input_event]
# Fired when the input gains focus
- on_focus: EventHandler[lambda e0: [e0.target.value]]
+ on_focus: EventHandler[input_event]
# Fired when the input loses focus
- on_blur: EventHandler[lambda e0: [e0.target.value]]
+ on_blur: EventHandler[input_event]
# Fired when a key is pressed down
- on_key_down: EventHandler[lambda e0: [e0.key]]
+ on_key_down: EventHandler[key_event]
# Fired when a key is released
- on_key_up: EventHandler[lambda e0: [e0.key]]
+ on_key_up: EventHandler[key_event]
+
+ @classmethod
+ def create(cls, *children, **props):
+ """Create a textarea component.
+
+ Args:
+ *children: The children of the textarea.
+ **props: The properties of the textarea.
+
+ Returns:
+ The textarea component.
+
+ Raises:
+ ValueError: when `enter_key_submit` is combined with `on_key_down`.
+ """
+ enter_key_submit = props.get("enter_key_submit")
+ auto_height = props.get("auto_height")
+ custom_attrs = props.setdefault("custom_attrs", {})
+
+ if enter_key_submit is not None:
+ enter_key_submit = Var.create(enter_key_submit)
+ if "on_key_down" in props:
+ raise ValueError(
+ "Cannot combine `enter_key_submit` with `on_key_down`.",
+ )
+ custom_attrs["on_key_down"] = Var(
+ _js_expr=f"(e) => enterKeySubmitOnKeyDown(e, {enter_key_submit!s})",
+ _var_data=VarData.merge(enter_key_submit._get_all_var_data()),
+ )
+ if auto_height is not None:
+ auto_height = Var.create(auto_height)
+ custom_attrs["on_input"] = Var(
+ _js_expr=f"(e) => autoHeightOnInput(e, {auto_height!s})",
+ _var_data=VarData.merge(auto_height._get_all_var_data()),
+ )
+ return super().create(*children, **props)
def _exclude_props(self) -> list[str]:
- return super()._exclude_props() + [
+ return [
+ *super()._exclude_props(),
"auto_height",
"enter_key_submit",
]
@@ -619,34 +709,9 @@ class Textarea(BaseHTML):
custom_code.add(ENTER_KEY_SUBMIT_JS)
return custom_code
- def _render(self) -> Tag:
- tag = super()._render()
- if self.enter_key_submit is not None:
- if "on_key_down" in self.event_triggers:
- raise ValueError(
- "Cannot combine `enter_key_submit` with `on_key_down`.",
- )
- tag.add_props(
- on_key_down=Var.create_safe(
- f"(e) => enterKeySubmitOnKeyDown(e, {self.enter_key_submit._var_name_unwrapped})",
- _var_is_local=False,
- _var_is_string=False,
- _var_data=self.enter_key_submit._var_data,
- )
- )
- if self.auto_height is not None:
- tag.add_props(
- on_input=Var.create_safe(
- f"(e) => autoHeightOnInput(e, {self.auto_height._var_name_unwrapped})",
- _var_is_local=False,
- _var_is_string=False,
- _var_data=self.auto_height._var_data,
- )
- )
- return tag
-
button = Button.create
+datalist = Datalist.create
fieldset = Fieldset.create
form = Form.create
input = Input.create
diff --git a/reflex/components/el/elements/forms.pyi b/reflex/components/el/elements/forms.pyi
index 31a56e9be..dfab40b21 100644
--- a/reflex/components/el/elements/forms.pyi
+++ b/reflex/components/el/elements/forms.pyi
@@ -3,21 +3,21 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Tuple, Union, overload
from jinja2 import Environment
from reflex.components.el.element import Element
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType, KeyInputInfo
from reflex.style import Style
from reflex.utils.imports import ImportDict
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .base import BaseHTML
-FORM_DATA = Var.create("form_data", _var_is_string=False)
+FORM_DATA = Var(_js_expr="form_data")
HANDLE_SUBMIT_JS_JINJA2 = Environment().from_string(
- "\n const handleSubmit_{{ handle_submit_unique_name }} = useCallback((ev) => {\n const $form = ev.target\n ev.preventDefault()\n const {{ form_data }} = {...Object.fromEntries(new FormData($form).entries()), ...{{ field_ref_mapping }}}\n\n {{ on_submit_event_chain }}\n\n if ({{ reset_on_submit }}) {\n $form.reset()\n }\n })\n "
+ "\n const handleSubmit_{{ handle_submit_unique_name }} = useCallback((ev) => {\n const $form = ev.target\n ev.preventDefault()\n const {{ form_data }} = {...Object.fromEntries(new FormData($form).entries()), ...{{ field_ref_mapping }}};\n\n ({{ on_submit_event_chain }}());\n\n if ({{ reset_on_submit }}) {\n $form.reset()\n }\n })\n "
)
class Button(BaseHTML):
@@ -26,96 +26,66 @@ class Button(BaseHTML):
def create( # type: ignore
cls,
*children,
- auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
form_enc_type: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
form_no_validate: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Button":
"""Create the component.
@@ -133,7 +103,7 @@ class Button(BaseHTML):
name: Name of the button, used when sending form data
type: Type of the button (submit, reset, or button)
value: Value of the button, used when sending form data
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -168,88 +138,58 @@ class Datalist(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Datalist":
"""Create the component.
Args:
*children: The children of the component.
- access_key: No unique attributes, only common ones are inherited Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -284,60 +224,30 @@ class Fieldset(Element):
def create( # type: ignore
cls,
*children,
- disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Fieldset":
"""Create the component.
@@ -360,105 +270,85 @@ class Fieldset(Element):
"""
...
+def on_submit_event_spec() -> Tuple[Var[Dict[str, Any]]]: ...
+def on_submit_string_event_spec() -> Tuple[Var[Dict[str, str]]]: ...
+
class Form(BaseHTML):
@overload
@classmethod
def create( # type: ignore
cls,
*children,
- accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
accept_charset: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_complete: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- enc_type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- no_validate: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ enc_type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ no_validate: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
reset_on_submit: Optional[Union[Var[bool], bool]] = None,
handle_submit_unique_name: Optional[Union[Var[str], str]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
on_submit: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ Union[
+ EventType[[], BASE_STATE], EventType[[Dict[str, Any]], BASE_STATE]
+ ],
+ Union[
+ EventType[[], BASE_STATE], EventType[[Dict[str, str]], BASE_STATE]
+ ],
+ ]
] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Form":
"""Create a form component.
@@ -476,7 +366,8 @@ class Form(BaseHTML):
target: Where to display the response after submitting the form
reset_on_submit: If true, the form will be cleared after submit.
handle_submit_unique_name: The name used to make this form's submit handler function unique.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ on_submit: Fired when the form is submitted
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -514,132 +405,114 @@ class Input(BaseHTML):
def create( # type: ignore
cls,
*children,
- accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- alt: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_complete: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- capture: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- checked: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ capture: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ checked: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
default_checked: Optional[Union[Var[bool], bool]] = None,
default_value: Optional[Union[Var[str], str]] = None,
- dirname: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
form_enc_type: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
form_no_validate: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- list: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- max: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- max_length: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- min_length: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- min: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- multiple: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- pattern: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- placeholder: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- read_only: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- required: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- size: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- step: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- use_map: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- value: Optional[Union[Var[Union[float, int, str]], str, int, float]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ list: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ max: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ max_length: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ min_length: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ min: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ pattern: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ placeholder: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ read_only: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ required: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ size: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ step: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
on_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[str], BASE_STATE],
+ EventType[[str, KeyInputInfo], BASE_STATE],
+ ]
] = None,
on_key_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[str], BASE_STATE],
+ EventType[[str, KeyInputInfo], BASE_STATE],
+ ]
] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Input":
- """Create the component.
+ """Create an Input component.
Args:
*children: The children of the component.
@@ -676,7 +549,12 @@ class Input(BaseHTML):
type: Specifies the type of input
use_map: Name of the image map used with the input
value: Value of the input
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ on_change: Fired when the input value changes
+ on_focus: Fired when the input gains focus
+ on_blur: Fired when the input loses focus
+ on_key_down: Fired when a key is pressed down
+ on_key_up: Fired when a key is released
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -698,7 +576,7 @@ class Input(BaseHTML):
class_name: The class name for the component.
autofocus: Whether the component should take the focus once the page is loaded
custom_attrs: custom attribute
- **props: The props of the component.
+ **props: The properties of the component.
Returns:
The component.
@@ -711,83 +589,53 @@ class Label(BaseHTML):
def create( # type: ignore
cls,
*children,
- html_for: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ html_for: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Label":
"""Create the component.
@@ -796,7 +644,7 @@ class Label(BaseHTML):
*children: The children of the component.
html_for: ID of a form control with which the label is associated
form: Associates the label with a form (by id)
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -831,88 +679,58 @@ class Legend(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Legend":
"""Create the component.
Args:
*children: The children of the component.
- access_key: No unique attributes, only common ones are inherited Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -947,88 +765,58 @@ class Meter(BaseHTML):
def create( # type: ignore
cls,
*children,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- high: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- low: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- max: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- min: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- optimum: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ high: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ low: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ max: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ min: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ optimum: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Meter":
"""Create the component.
@@ -1042,7 +830,7 @@ class Meter(BaseHTML):
min: Minimum value of the range
optimum: Optimum value in the range
value: Current value of the meter
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1077,83 +865,53 @@ class Optgroup(BaseHTML):
def create( # type: ignore
cls,
*children,
- disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- label: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ label: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Optgroup":
"""Create the component.
@@ -1162,7 +920,7 @@ class Optgroup(BaseHTML):
*children: The children of the component.
disabled: Disables the optgroup
label: Label for the optgroup
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1197,85 +955,55 @@ class Option(BaseHTML):
def create( # type: ignore
cls,
*children,
- disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- label: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- selected: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ label: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ selected: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Option":
"""Create the component.
@@ -1286,7 +1014,7 @@ class Option(BaseHTML):
label: Label for the option, if the text is not the label
selected: Indicates that the option is initially selected
value: Value to be sent as form data
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1321,84 +1049,54 @@ class Output(BaseHTML):
def create( # type: ignore
cls,
*children,
- html_for: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ html_for: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Output":
"""Create the component.
@@ -1408,7 +1106,7 @@ class Output(BaseHTML):
html_for: Associates the output with one or more elements (by their IDs)
form: Associates the output with a form (by id)
name: Name of the output element for form submission
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1443,84 +1141,54 @@ class Progress(BaseHTML):
def create( # type: ignore
cls,
*children,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- max: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ max: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Progress":
"""Create the component.
@@ -1530,7 +1198,7 @@ class Progress(BaseHTML):
form: Associates the progress element with a form (by id)
max: Maximum value of the progress indicator
value: Current value of the progress indicator
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1566,93 +1234,63 @@ class Select(BaseHTML):
cls,
*children,
auto_complete: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- multiple: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- required: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- size: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ required: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ size: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Select":
"""Create the component.
@@ -1667,7 +1305,8 @@ class Select(BaseHTML):
name: Name of the select, used when submitting the form
required: Indicates that the select control must have a selected option
size: Number of visible options in a drop-down list
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ on_change: Fired when the select value changes
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1696,7 +1335,7 @@ class Select(BaseHTML):
"""
...
-AUTO_HEIGHT_JS = '\nconst autoHeightOnInput = (e, is_enabled) => {\n if (is_enabled) {\n const el = e.target;\n el.style.overflowY = "hidden";\n el.style.height = "auto";\n el.style.height = (e.target.scrollHeight) + "px";\n if (el.form && !el.form.data_resize_on_reset) {\n el.form.addEventListener("reset", () => window.setTimeout(() => autoHeightOnInput(e, is_enabled), 0))\n el.form.data_resize_on_reset = true;\n }\n }\n}\n'
+AUTO_HEIGHT_JS = '\nconst autoHeightOnInput = (e, is_enabled) => {\n if (is_enabled) {\n const el = e.target;\n el.style.overflowY = "scroll";\n el.style.height = "auto";\n el.style.height = (e.target.scrollHeight) + "px";\n if (el.form && !el.form.data_resize_on_reset) {\n el.form.addEventListener("reset", () => window.setTimeout(() => autoHeightOnInput(e, is_enabled), 0))\n el.form.data_resize_on_reset = true;\n }\n }\n}\n'
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"
class Textarea(BaseHTML):
@@ -1706,118 +1345,102 @@ class Textarea(BaseHTML):
cls,
*children,
auto_complete: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_height: Optional[Union[Var[bool], bool]] = None,
- cols: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- dirname: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ cols: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ default_value: Optional[Union[Var[str], str]] = None,
+ dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_submit: Optional[Union[Var[bool], bool]] = None,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- max_length: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- min_length: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- placeholder: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- read_only: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- required: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- rows: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- wrap: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ max_length: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ min_length: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ placeholder: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ read_only: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ required: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ rows: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ wrap: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
on_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[str], BASE_STATE],
+ EventType[[str, KeyInputInfo], BASE_STATE],
+ ]
] = None,
on_key_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[str], BASE_STATE],
+ EventType[[str, KeyInputInfo], BASE_STATE],
+ ]
] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Textarea":
- """Create the component.
+ """Create a textarea component.
Args:
- *children: The children of the component.
+ *children: The children of the textarea.
auto_complete: Whether the form control should have autocomplete enabled
auto_focus: Automatically focuses the textarea when the page loads
auto_height: Automatically fit the content height to the text (use min-height with this prop)
cols: Visible width of the text control, in average character widths
+ default_value: The default value of the textarea when initially rendered
dirname: Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
disabled: Disables the textarea
enter_key_submit: Enter key submits form (shift-enter adds new line)
@@ -1831,7 +1454,12 @@ class Textarea(BaseHTML):
rows: Visible number of lines in the text control
value: The controlled value of the textarea, read only unless used with on_change
wrap: How the text in the textarea is to be wrapped when submitting the form
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ on_change: Fired when the input value changes
+ on_focus: Fired when the input gains focus
+ on_blur: Fired when the input loses focus
+ on_key_down: Fired when a key is pressed down
+ on_key_up: Fired when a key is released
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1853,14 +1481,18 @@ class Textarea(BaseHTML):
class_name: The class name for the component.
autofocus: Whether the component should take the focus once the page is loaded
custom_attrs: custom attribute
- **props: The props of the component.
+ **props: The properties of the textarea.
Returns:
- The component.
+ The textarea component.
+
+ Raises:
+ ValueError: when `enter_key_submit` is combined with `on_key_down`.
"""
...
button = Button.create
+datalist = Datalist.create
fieldset = Fieldset.create
form = Form.create
input = Input.create
diff --git a/reflex/components/el/elements/inline.py b/reflex/components/el/elements/inline.py
index 4364c1ead..270eca28e 100644
--- a/reflex/components/el/elements/inline.py
+++ b/reflex/components/el/elements/inline.py
@@ -1,8 +1,8 @@
-"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
+"""Inline classes."""
from typing import Union
-from reflex.vars import Var
+from reflex.vars.base import Var
from .base import BaseHTML
diff --git a/reflex/components/el/elements/inline.pyi b/reflex/components/el/elements/inline.pyi
index c4cd4286f..06aeeca76 100644
--- a/reflex/components/el/elements/inline.pyi
+++ b/reflex/components/el/elements/inline.pyi
@@ -3,11 +3,11 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .base import BaseHTML
@@ -17,92 +17,62 @@ class A(BaseHTML):
def create( # type: ignore
cls,
*children,
- download: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- href_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- ping: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ download: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ ping: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
referrer_policy: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- rel: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- shape: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ shape: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "A":
"""Create the component.
@@ -118,7 +88,7 @@ class A(BaseHTML):
rel: Specifies the relationship between the linked document and the current document
shape: Specifies the shape of the area
target: Specifies where to open the linked document
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -153,88 +123,58 @@ class Abbr(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Abbr":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -269,88 +209,58 @@ class B(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "B":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -385,88 +295,58 @@ class Bdi(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Bdi":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -501,88 +381,58 @@ class Bdo(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Bdo":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -617,88 +467,58 @@ class Br(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Br":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -733,88 +553,58 @@ class Cite(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Cite":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -849,88 +639,58 @@ class Code(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Code":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -965,82 +725,52 @@ class Data(BaseHTML):
def create( # type: ignore
cls,
*children,
- value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Data":
"""Create the component.
@@ -1048,7 +778,7 @@ class Data(BaseHTML):
Args:
*children: The children of the component.
value: Specifies the machine-readable translation of the data element.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1083,88 +813,58 @@ class Dfn(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Dfn":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1199,88 +899,58 @@ class Em(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Em":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1315,88 +985,58 @@ class I(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "I":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1431,88 +1071,58 @@ class Kbd(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Kbd":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1547,88 +1157,58 @@ class Mark(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Mark":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1663,82 +1243,52 @@ class Q(BaseHTML):
def create( # type: ignore
cls,
*children,
- cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Q":
"""Create the component.
@@ -1746,7 +1296,7 @@ class Q(BaseHTML):
Args:
*children: The children of the component.
cite: Specifies the source URL of the quote.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1781,88 +1331,58 @@ class Rp(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Rp":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1897,88 +1417,58 @@ class Rt(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Rt":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2013,88 +1503,58 @@ class Ruby(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Ruby":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2129,88 +1589,58 @@ class S(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "S":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2245,88 +1675,58 @@ class Samp(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Samp":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2361,88 +1761,58 @@ class Small(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Small":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2477,88 +1847,58 @@ class Span(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Span":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2593,88 +1933,58 @@ class Strong(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Strong":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2709,88 +2019,58 @@ class Sub(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Sub":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2825,88 +2105,58 @@ class Sup(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Sup":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2941,82 +2191,52 @@ class Time(BaseHTML):
def create( # type: ignore
cls,
*children,
- date_time: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ date_time: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Time":
"""Create the component.
@@ -3024,7 +2244,7 @@ class Time(BaseHTML):
Args:
*children: The children of the component.
date_time: Specifies the date and/or time of the element.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -3059,88 +2279,58 @@ class U(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "U":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -3175,88 +2365,58 @@ class Wbr(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Wbr":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/el/elements/media.py b/reflex/components/el/elements/media.py
index b2bdc9e6f..7d2f0e3e9 100644
--- a/reflex/components/el/elements/media.py
+++ b/reflex/components/el/elements/media.py
@@ -1,11 +1,10 @@
-"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
+"""Media classes."""
from typing import Any, Union
from reflex import Component, ComponentNamespace
from reflex.constants.colors import Color
-from reflex.utils import console
-from reflex.vars import Var as Var
+from reflex.vars.base import Var
from .base import BaseHTML
@@ -130,7 +129,6 @@ class Img(BaseHTML):
Returns:
The component.
-
"""
return (
super().create(src=children[0], **props)
@@ -275,14 +273,12 @@ class Picture(BaseHTML):
"""Display the picture element."""
tag = "picture"
- # No unique attributes, only common ones are inherited
class Portal(BaseHTML):
"""Display the portal element."""
tag = "portal"
- # No unique attributes, only common ones are inherited
class Source(BaseHTML):
@@ -318,6 +314,42 @@ class Svg(BaseHTML):
xmlns: Var[str]
+class Text(BaseHTML):
+ """The SVG text component."""
+
+ tag = "text"
+ # The x coordinate of the starting point of the text baseline.
+ x: Var[Union[str, int]]
+ # The y coordinate of the starting point of the text baseline.
+ y: Var[Union[str, int]]
+ # Shifts the text position horizontally from a previous text element.
+ dx: Var[Union[str, int]]
+ # Shifts the text position vertically from a previous text element.
+ dy: Var[Union[str, int]]
+ # Rotates orientation of each individual glyph.
+ rotate: Var[Union[str, int]]
+ # How the text is stretched or compressed to fit the width defined by the text_length attribute.
+ length_adjust: Var[str]
+ # A width that the text should be scaled to fit.
+ text_length: Var[Union[str, int]]
+
+
+class Line(BaseHTML):
+ """The SVG line component."""
+
+ tag = "line"
+ # The x-axis coordinate of the line starting point.
+ x1: Var[Union[str, int]]
+ # The x-axis coordinate of the the line ending point.
+ x2: Var[Union[str, int]]
+ # The y-axis coordinate of the line starting point.
+ y1: Var[Union[str, int]]
+ # The y-axis coordinate of the the line ending point.
+ y2: Var[Union[str, int]]
+ # The total path length, in user units.
+ path_length: Var[int]
+
+
class Circle(BaseHTML):
"""The SVG circle component."""
@@ -332,6 +364,22 @@ class Circle(BaseHTML):
path_length: Var[int]
+class Ellipse(BaseHTML):
+ """The SVG ellipse component."""
+
+ tag = "ellipse"
+ # The x position of the center of the ellipse.
+ cx: Var[Union[str, int]]
+ # The y position of the center of the ellipse.
+ cy: Var[Union[str, int]]
+ # The radius of the ellipse on the x axis.
+ rx: Var[Union[str, int]]
+ # The radius of the ellipse on the y axis.
+ ry: Var[Union[str, int]]
+ # The total length for the ellipse's circumference, in user units.
+ path_length: Var[int]
+
+
class Rect(BaseHTML):
"""The SVG rect component."""
@@ -395,6 +443,39 @@ class LinearGradient(BaseHTML):
y2: Var[Union[str, int, bool]]
+class RadialGradient(BaseHTML):
+ """Display the radialGradient element."""
+
+ tag = "radialGradient"
+
+ # The x coordinate of the end circle of the radial gradient.
+ cx: Var[Union[str, int, bool]]
+
+ # The y coordinate of the end circle of the radial gradient.
+ cy: Var[Union[str, int, bool]]
+
+ # The radius of the start circle of the radial gradient.
+ fr: Var[Union[str, int, bool]]
+
+ # The x coordinate of the start circle of the radial gradient.
+ fx: Var[Union[str, int, bool]]
+
+ # The y coordinate of the start circle of the radial gradient.
+ fy: Var[Union[str, int, bool]]
+
+ # Units for the gradient.
+ gradient_units: Var[Union[str, bool]]
+
+ # Transform applied to the gradient.
+ gradient_transform: Var[Union[str, bool]]
+
+ # The radius of the end circle of the radial gradient.
+ r: Var[Union[str, int, bool]]
+
+ # Method used to spread the gradient.
+ spread_method: Var[Union[str, bool]]
+
+
class Stop(BaseHTML):
"""Display the stop element."""
@@ -422,12 +503,16 @@ class Path(BaseHTML):
class SVG(ComponentNamespace):
"""SVG component namespace."""
+ text = staticmethod(Text.create)
+ line = staticmethod(Line.create)
circle = staticmethod(Circle.create)
+ ellipse = staticmethod(Ellipse.create)
rect = staticmethod(Rect.create)
polygon = staticmethod(Polygon.create)
path = staticmethod(Path.create)
stop = staticmethod(Stop.create)
linear_gradient = staticmethod(LinearGradient.create)
+ radial_gradient = staticmethod(RadialGradient.create)
defs = staticmethod(Defs.create)
__call__ = staticmethod(Svg.create)
@@ -445,23 +530,3 @@ picture = Picture.create
portal = Portal.create
source = Source.create
svg = SVG()
-
-
-def __getattr__(name: str):
- if name in ("defs", "lineargradient", "stop", "path"):
- console.deprecate(
- f"`rx.el.{name}`",
- reason=f"use `rx.el.svg.{'linear_gradient' if name =='lineargradient' else name}`",
- deprecation_version="0.5.8",
- removal_version="0.6.0",
- )
- return (
- LinearGradient.create
- if name == "lineargradient"
- else globals()[name.capitalize()].create
- )
-
- try:
- return globals()[name]
- except KeyError:
- raise AttributeError(f"module '{__name__} has no attribute '{name}'") from None
diff --git a/reflex/components/el/elements/media.pyi b/reflex/components/el/elements/media.pyi
index ba5f14137..b172d0c07 100644
--- a/reflex/components/el/elements/media.pyi
+++ b/reflex/components/el/elements/media.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
from reflex import ComponentNamespace
from reflex.constants.colors import Color
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .base import BaseHTML
@@ -19,94 +19,64 @@ class Area(BaseHTML):
def create( # type: ignore
cls,
*children,
- alt: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- coords: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- download: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- href_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- ping: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ coords: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ download: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ ping: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
referrer_policy: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- rel: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- shape: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ shape: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Area":
"""Create the component.
@@ -124,7 +94,7 @@ class Area(BaseHTML):
rel: Specifies the relationship of the target object to the link object
shape: Defines the shape of the area (rectangle, circle, polygon)
target: Specifies where to open the linked document
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -159,91 +129,61 @@ class Audio(BaseHTML):
def create( # type: ignore
cls,
*children,
- auto_play: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- buffered: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- controls: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ auto_play: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ buffered: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ controls: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
cross_origin: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- loop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- muted: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- preload: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ loop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ muted: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ preload: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Audio":
"""Create the component.
@@ -258,7 +198,7 @@ class Audio(BaseHTML):
muted: Indicates whether the audio is muted by default
preload: Specifies how the audio file should be preloaded
src: URL of the audio to play
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -293,99 +233,69 @@ class Img(BaseHTML):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- alt: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
cross_origin: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- decoding: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ decoding: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
intrinsicsize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- ismap: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- loading: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ ismap: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ loading: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
referrer_policy: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- sizes: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- src: Optional[Union[Var[Any], Any]] = None,
- src_set: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- use_map: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ sizes: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ src: Optional[Union[Any, Var[Any]]] = None,
+ src_set: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Img":
"""Override create method to apply source attribute to value if user fails to pass in attribute.
@@ -404,7 +314,7 @@ class Img(BaseHTML):
src: URL of the image to display
src_set: A set of source sizes and URLs for responsive images
use_map: The name of the map to use with the image
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -430,7 +340,6 @@ class Img(BaseHTML):
Returns:
The component.
-
"""
...
@@ -440,82 +349,52 @@ class Map(BaseHTML):
def create( # type: ignore
cls,
*children,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Map":
"""Create the component.
@@ -523,7 +402,7 @@ class Map(BaseHTML):
Args:
*children: The children of the component.
name: Name of the map, referenced by the 'usemap' attribute in 'img' and 'object' elements
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -558,86 +437,56 @@ class Track(BaseHTML):
def create( # type: ignore
cls,
*children,
- default: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- kind: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- label: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- src_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ default: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ kind: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ label: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ src_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Track":
"""Create the component.
@@ -649,7 +498,7 @@ class Track(BaseHTML):
label: Title of the text track, used by the browser when listing available text tracks
src: URL of the track file
src_lang: Language of the track text data
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -684,95 +533,65 @@ class Video(BaseHTML):
def create( # type: ignore
cls,
*children,
- auto_play: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- buffered: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- controls: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ auto_play: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ buffered: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ controls: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
cross_origin: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- loop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- muted: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ loop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ muted: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
plays_inline: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- poster: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- preload: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ poster: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ preload: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Video":
"""Create the component.
@@ -789,7 +608,7 @@ class Video(BaseHTML):
poster: URL of an image to show while the video is downloading, or until the user hits the play button
preload: Specifies how the video file should be preloaded
src: URL of the video to play
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -824,83 +643,53 @@ class Embed(BaseHTML):
def create( # type: ignore
cls,
*children,
- src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Embed":
"""Create the component.
@@ -909,7 +698,7 @@ class Embed(BaseHTML):
*children: The children of the component.
src: URL of the embedded content
type: Media type of the embedded content
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -944,92 +733,62 @@ class Iframe(BaseHTML):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- allow: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- csp: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- loading: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ allow: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ csp: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ loading: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
referrer_policy: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- sandbox: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- src_doc: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ sandbox: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ src_doc: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Iframe":
"""Create the component.
@@ -1045,7 +804,7 @@ class Iframe(BaseHTML):
sandbox: Security restrictions for the content in the iframe
src: URL of the document to display in the iframe
src_doc: HTML content to embed directly within the iframe
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1080,86 +839,56 @@ class Object(BaseHTML):
def create( # type: ignore
cls,
*children,
- data: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- use_map: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ data: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Object":
"""Create the component.
@@ -1171,7 +900,7 @@ class Object(BaseHTML):
name: Name of the object, used for scripting or as a target for forms and links
type: Media type of the data specified in the data attribute
use_map: Name of an image map to use with the object
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1206,88 +935,58 @@ class Picture(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Picture":
"""Create the component.
Args:
*children: The children of the component.
- access_key: No unique attributes, only common ones are inherited Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1322,88 +1021,58 @@ class Portal(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Portal":
"""Create the component.
Args:
*children: The children of the component.
- access_key: No unique attributes, only common ones are inherited Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1438,86 +1107,56 @@ class Source(BaseHTML):
def create( # type: ignore
cls,
*children,
- media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- sizes: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- src_set: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ sizes: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ src_set: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Source":
"""Create the component.
@@ -1529,7 +1168,7 @@ class Source(BaseHTML):
src: URL of the media file or an image for the element to use
src_set: A set of source sizes and URLs for responsive images
type: Media type of the source
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1564,84 +1203,54 @@ class Svg(BaseHTML):
def create( # type: ignore
cls,
*children,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
xmlns: Optional[Union[Var[str], str]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Svg":
"""Create the component.
@@ -1651,7 +1260,203 @@ class Svg(BaseHTML):
width: The width of the svg.
height: The height of the svg.
xmlns: The XML namespace declaration.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
+ content_editable: Indicates whether the element's content is editable.
+ context_menu: Defines the ID of a element which will serve as the element's context menu.
+ dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
+ draggable: Defines whether the element can be dragged.
+ enter_key_hint: Hints what media types the media element is able to play.
+ hidden: Defines whether the element is hidden.
+ input_mode: Defines the type of the element.
+ item_prop: Defines the name of the element for metadata purposes.
+ lang: Defines the language used in the element.
+ role: Defines the role of the element.
+ slot: Assigns a slot in a shadow DOM shadow tree to an element.
+ spell_check: Defines whether the element may be checked for spelling errors.
+ tab_index: Defines the position of the current element in the tabbing order.
+ title: Defines a tooltip for the element.
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: The props of the component.
+
+ Returns:
+ The component.
+ """
+ ...
+
+class Text(BaseHTML):
+ @overload
+ @classmethod
+ def create( # type: ignore
+ cls,
+ *children,
+ x: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ dx: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ dy: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ rotate: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ length_adjust: Optional[Union[Var[str], str]] = None,
+ text_length: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ auto_capitalize: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ content_editable: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ context_menu: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ enter_key_hint: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ style: Optional[Style] = None,
+ key: Optional[Any] = None,
+ id: Optional[Any] = None,
+ class_name: Optional[Any] = None,
+ autofocus: Optional[bool] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
+ **props,
+ ) -> "Text":
+ """Create the component.
+
+ Args:
+ *children: The children of the component.
+ x: The x coordinate of the starting point of the text baseline.
+ y: The y coordinate of the starting point of the text baseline.
+ dx: Shifts the text position horizontally from a previous text element.
+ dy: Shifts the text position vertically from a previous text element.
+ rotate: Rotates orientation of each individual glyph.
+ length_adjust: How the text is stretched or compressed to fit the width defined by the text_length attribute.
+ text_length: A width that the text should be scaled to fit.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
+ content_editable: Indicates whether the element's content is editable.
+ context_menu: Defines the ID of a element which will serve as the element's context menu.
+ dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
+ draggable: Defines whether the element can be dragged.
+ enter_key_hint: Hints what media types the media element is able to play.
+ hidden: Defines whether the element is hidden.
+ input_mode: Defines the type of the element.
+ item_prop: Defines the name of the element for metadata purposes.
+ lang: Defines the language used in the element.
+ role: Defines the role of the element.
+ slot: Assigns a slot in a shadow DOM shadow tree to an element.
+ spell_check: Defines whether the element may be checked for spelling errors.
+ tab_index: Defines the position of the current element in the tabbing order.
+ title: Defines a tooltip for the element.
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: The props of the component.
+
+ Returns:
+ The component.
+ """
+ ...
+
+class Line(BaseHTML):
+ @overload
+ @classmethod
+ def create( # type: ignore
+ cls,
+ *children,
+ x1: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ x2: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y1: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y2: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ path_length: Optional[Union[Var[int], int]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ auto_capitalize: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ content_editable: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ context_menu: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ enter_key_hint: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ style: Optional[Style] = None,
+ key: Optional[Any] = None,
+ id: Optional[Any] = None,
+ class_name: Optional[Any] = None,
+ autofocus: Optional[bool] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
+ **props,
+ ) -> "Line":
+ """Create the component.
+
+ Args:
+ *children: The children of the component.
+ x1: The x-axis coordinate of the line starting point.
+ x2: The x-axis coordinate of the the line ending point.
+ y1: The y-axis coordinate of the line starting point.
+ y2: The y-axis coordinate of the the line ending point.
+ path_length: The total path length, in user units.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1686,85 +1491,55 @@ class Circle(BaseHTML):
def create( # type: ignore
cls,
*children,
- cx: Optional[Union[Var[Union[int, str]], str, int]] = None,
- cy: Optional[Union[Var[Union[int, str]], str, int]] = None,
- r: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ cx: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ cy: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ r: Optional[Union[Var[Union[int, str]], int, str]] = None,
path_length: Optional[Union[Var[int], int]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Circle":
"""Create the component.
@@ -1775,7 +1550,103 @@ class Circle(BaseHTML):
cy: The y-axis coordinate of the center of the circle.
r: The radius of the circle.
path_length: The total length for the circle's circumference, in user units.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
+ content_editable: Indicates whether the element's content is editable.
+ context_menu: Defines the ID of a element which will serve as the element's context menu.
+ dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
+ draggable: Defines whether the element can be dragged.
+ enter_key_hint: Hints what media types the media element is able to play.
+ hidden: Defines whether the element is hidden.
+ input_mode: Defines the type of the element.
+ item_prop: Defines the name of the element for metadata purposes.
+ lang: Defines the language used in the element.
+ role: Defines the role of the element.
+ slot: Assigns a slot in a shadow DOM shadow tree to an element.
+ spell_check: Defines whether the element may be checked for spelling errors.
+ tab_index: Defines the position of the current element in the tabbing order.
+ title: Defines a tooltip for the element.
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: The props of the component.
+
+ Returns:
+ The component.
+ """
+ ...
+
+class Ellipse(BaseHTML):
+ @overload
+ @classmethod
+ def create( # type: ignore
+ cls,
+ *children,
+ cx: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ cy: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ rx: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ ry: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ path_length: Optional[Union[Var[int], int]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ auto_capitalize: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ content_editable: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ context_menu: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ enter_key_hint: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ style: Optional[Style] = None,
+ key: Optional[Any] = None,
+ id: Optional[Any] = None,
+ class_name: Optional[Any] = None,
+ autofocus: Optional[bool] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
+ **props,
+ ) -> "Ellipse":
+ """Create the component.
+
+ Args:
+ *children: The children of the component.
+ cx: The x position of the center of the ellipse.
+ cy: The y position of the center of the ellipse.
+ rx: The radius of the ellipse on the x axis.
+ ry: The radius of the ellipse on the y axis.
+ path_length: The total length for the ellipse's circumference, in user units.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1810,88 +1681,58 @@ class Rect(BaseHTML):
def create( # type: ignore
cls,
*children,
- x: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y: Optional[Union[Var[Union[int, str]], str, int]] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
- rx: Optional[Union[Var[Union[int, str]], str, int]] = None,
- ry: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ x: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ rx: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ ry: Optional[Union[Var[Union[int, str]], int, str]] = None,
path_length: Optional[Union[Var[int], int]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Rect":
"""Create the component.
@@ -1905,7 +1746,7 @@ class Rect(BaseHTML):
rx: The horizontal corner radius of the rect. Defaults to ry if it is specified.
ry: The vertical corner radius of the rect. Defaults to rx if it is specified.
path_length: The total length of the rectangle's perimeter, in user units.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1942,81 +1783,51 @@ class Polygon(BaseHTML):
*children,
points: Optional[Union[Var[str], str]] = None,
path_length: Optional[Union[Var[int], int]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Polygon":
"""Create the component.
@@ -2025,7 +1836,7 @@ class Polygon(BaseHTML):
*children: The children of the component.
points: defines the list of points (pairs of x,y absolute coordinates) required to draw the polygon.
path_length: This prop lets specify the total length for the path, in user units.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2060,88 +1871,58 @@ class Defs(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Defs":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2176,88 +1957,58 @@ class LinearGradient(BaseHTML):
def create( # type: ignore
cls,
*children,
- gradient_units: Optional[Union[Var[Union[bool, str]], str, bool]] = None,
- gradient_transform: Optional[Union[Var[Union[bool, str]], str, bool]] = None,
- spread_method: Optional[Union[Var[Union[bool, str]], str, bool]] = None,
- x1: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- x2: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- y1: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- y2: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ gradient_units: Optional[Union[Var[Union[bool, str]], bool, str]] = None,
+ gradient_transform: Optional[Union[Var[Union[bool, str]], bool, str]] = None,
+ spread_method: Optional[Union[Var[Union[bool, str]], bool, str]] = None,
+ x1: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ x2: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ y1: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ y2: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "LinearGradient":
"""Create the component.
@@ -2271,7 +2022,111 @@ class LinearGradient(BaseHTML):
x2: X coordinate of the ending point of the gradient.
y1: Y coordinate of the starting point of the gradient.
y2: Y coordinate of the ending point of the gradient.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
+ content_editable: Indicates whether the element's content is editable.
+ context_menu: Defines the ID of a element which will serve as the element's context menu.
+ dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
+ draggable: Defines whether the element can be dragged.
+ enter_key_hint: Hints what media types the media element is able to play.
+ hidden: Defines whether the element is hidden.
+ input_mode: Defines the type of the element.
+ item_prop: Defines the name of the element for metadata purposes.
+ lang: Defines the language used in the element.
+ role: Defines the role of the element.
+ slot: Assigns a slot in a shadow DOM shadow tree to an element.
+ spell_check: Defines whether the element may be checked for spelling errors.
+ tab_index: Defines the position of the current element in the tabbing order.
+ title: Defines a tooltip for the element.
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: The props of the component.
+
+ Returns:
+ The component.
+ """
+ ...
+
+class RadialGradient(BaseHTML):
+ @overload
+ @classmethod
+ def create( # type: ignore
+ cls,
+ *children,
+ cx: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ cy: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ fr: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ fx: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ fy: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ gradient_units: Optional[Union[Var[Union[bool, str]], bool, str]] = None,
+ gradient_transform: Optional[Union[Var[Union[bool, str]], bool, str]] = None,
+ r: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spread_method: Optional[Union[Var[Union[bool, str]], bool, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ auto_capitalize: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ content_editable: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ context_menu: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ enter_key_hint: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ style: Optional[Style] = None,
+ key: Optional[Any] = None,
+ id: Optional[Any] = None,
+ class_name: Optional[Any] = None,
+ autofocus: Optional[bool] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
+ **props,
+ ) -> "RadialGradient":
+ """Create the component.
+
+ Args:
+ *children: The children of the component.
+ cx: The x coordinate of the end circle of the radial gradient.
+ cy: The y coordinate of the end circle of the radial gradient.
+ fr: The radius of the start circle of the radial gradient.
+ fx: The x coordinate of the start circle of the radial gradient.
+ fy: The y coordinate of the start circle of the radial gradient.
+ gradient_units: Units for the gradient.
+ gradient_transform: Transform applied to the gradient.
+ r: The radius of the end circle of the radial gradient.
+ spread_method: Method used to spread the gradient.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2306,88 +2161,58 @@ class Stop(BaseHTML):
def create( # type: ignore
cls,
*children,
- offset: Optional[Union[Var[Union[float, int, str]], str, float, int]] = None,
+ offset: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None,
stop_color: Optional[
- Union[Var[Union[Color, bool, str]], str, Color, bool]
+ Union[Color, Var[Union[Color, bool, str]], bool, str]
] = None,
stop_opacity: Optional[
- Union[Var[Union[bool, float, int, str]], str, float, int, bool]
+ Union[Var[Union[bool, float, int, str]], bool, float, int, str]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Stop":
"""Create the component.
@@ -2397,7 +2222,7 @@ class Stop(BaseHTML):
offset: Offset of the gradient stop.
stop_color: Color of the gradient stop.
stop_opacity: Opacity of the gradient stop.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2432,82 +2257,52 @@ class Path(BaseHTML):
def create( # type: ignore
cls,
*children,
- d: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ d: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Path":
"""Create the component.
@@ -2515,7 +2310,7 @@ class Path(BaseHTML):
Args:
*children: The children of the component.
d: Defines the shape of the path.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -2545,95 +2340,69 @@ class Path(BaseHTML):
...
class SVG(ComponentNamespace):
+ text = staticmethod(Text.create)
+ line = staticmethod(Line.create)
circle = staticmethod(Circle.create)
+ ellipse = staticmethod(Ellipse.create)
rect = staticmethod(Rect.create)
polygon = staticmethod(Polygon.create)
path = staticmethod(Path.create)
stop = staticmethod(Stop.create)
linear_gradient = staticmethod(LinearGradient.create)
+ radial_gradient = staticmethod(RadialGradient.create)
defs = staticmethod(Defs.create)
@staticmethod
def __call__(
*children,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
xmlns: Optional[Union[Var[str], str]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Svg":
"""Create the component.
@@ -2643,7 +2412,7 @@ class SVG(ComponentNamespace):
width: The width of the svg.
height: The height of the svg.
xmlns: The XML namespace declaration.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/el/elements/metadata.py b/reflex/components/el/elements/metadata.py
index 9a4d18b73..8e0fbcd4d 100644
--- a/reflex/components/el/elements/metadata.py
+++ b/reflex/components/el/elements/metadata.py
@@ -1,14 +1,14 @@
-"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
+"""Metadata classes."""
-from typing import Set, Union
+from typing import List, Union
from reflex.components.el.element import Element
-from reflex.vars import Var as Var
+from reflex.vars.base import Var
from .base import BaseHTML
-class Base(BaseHTML): # noqa: E742
+class Base(BaseHTML):
"""Display the base element."""
tag = "base"
@@ -18,13 +18,13 @@ class Base(BaseHTML): # noqa: E742
target: Var[Union[str, int, bool]]
-class Head(BaseHTML): # noqa: E742
+class Head(BaseHTML):
"""Display the head element."""
tag = "head"
-class Link(BaseHTML): # noqa: E742
+class Link(BaseHTML):
"""Display the link element."""
tag = "link"
@@ -75,23 +75,21 @@ class Meta(BaseHTML): # Inherits common attributes from BaseHTML
name: Var[Union[str, int, bool]]
-class Title(Element): # noqa: E742
+class Title(Element):
"""Display the title element."""
tag = "title"
-# Had to be named with an underscore so it doesnt conflict with reflex.style Style in pyi
-class StyleEl(Element): # noqa: E742
+# Had to be named with an underscore so it doesn't conflict with reflex.style Style in pyi
+class StyleEl(Element):
"""Display the style element."""
tag = "style"
media: Var[Union[str, int, bool]]
- special_props: Set[Var] = {
- Var.create_safe("suppressHydrationWarning", _var_is_string=False)
- }
+ special_props: List[Var] = [Var(_js_expr="suppressHydrationWarning")]
base = Base.create
diff --git a/reflex/components/el/elements/metadata.pyi b/reflex/components/el/elements/metadata.pyi
index e08c1d723..08cd2fd76 100644
--- a/reflex/components/el/elements/metadata.pyi
+++ b/reflex/components/el/elements/metadata.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
from reflex.components.el.element import Element
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .base import BaseHTML
@@ -18,90 +18,60 @@ class Base(BaseHTML):
def create( # type: ignore
cls,
*children,
- href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Base":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -136,88 +106,58 @@ class Head(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Head":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -253,93 +193,63 @@ class Link(BaseHTML):
cls,
*children,
cross_origin: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- href_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- integrity: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ integrity: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
referrer_policy: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- rel: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- sizes: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ sizes: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Link":
"""Create the component.
@@ -355,7 +265,7 @@ class Link(BaseHTML):
rel: Specifies the relationship between the current document and the linked one
sizes: Specifies the sizes of icons for visual media
type: Specifies the MIME type of the linked document
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -390,85 +300,55 @@ class Meta(BaseHTML):
def create( # type: ignore
cls,
*children,
- char_set: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- content: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- http_equiv: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ char_set: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ content: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ http_equiv: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Meta":
"""Create the component.
@@ -479,7 +359,7 @@ class Meta(BaseHTML):
content: Defines the content of the metadata
http_equiv: Provides an HTTP header for the information/value of the content attribute
name: Specifies a name for the metadata
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -519,52 +399,22 @@ class Title(Element):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Title":
"""Create the component.
@@ -590,58 +440,28 @@ class StyleEl(Element):
def create( # type: ignore
cls,
*children,
- media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "StyleEl":
"""Create the component.
diff --git a/reflex/components/el/elements/other.py b/reflex/components/el/elements/other.py
index 560ed5138..4e7f0f227 100644
--- a/reflex/components/el/elements/other.py
+++ b/reflex/components/el/elements/other.py
@@ -1,8 +1,8 @@
-"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
+"""Other classes."""
from typing import Union
-from reflex.vars import Var as Var
+from reflex.vars.base import Var
from .base import BaseHTML
@@ -26,31 +26,39 @@ class Dialog(BaseHTML):
class Summary(BaseHTML):
- """Display the summary element."""
+ """Display the summary element.
+
+ Used as a summary or caption for a element.
+ """
tag = "summary"
- # No unique attributes, only common ones are inherited; used as a summary or caption for a element
class Slot(BaseHTML):
- """Display the slot element."""
+ """Display the slot element.
+
+ Used as a placeholder inside a web component.
+ """
tag = "slot"
- # No unique attributes, only common ones are inherited; used as a placeholder inside a web component
class Template(BaseHTML):
- """Display the template element."""
+ """Display the template element.
+
+ Used for declaring fragments of HTML that can be cloned and inserted in the document.
+ """
tag = "template"
- # No unique attributes, only common ones are inherited; used for declaring fragments of HTML that can be cloned and inserted in the document
class Math(BaseHTML):
- """Display the math element."""
+ """Display the math element.
+
+ Represents a mathematical expression.
+ """
tag = "math"
- # No unique attributes, only common ones are inherited; used for displaying mathematical expressions
class Html(BaseHTML):
diff --git a/reflex/components/el/elements/other.pyi b/reflex/components/el/elements/other.pyi
index 6dc5d0aa1..57e4ab24b 100644
--- a/reflex/components/el/elements/other.pyi
+++ b/reflex/components/el/elements/other.pyi
@@ -3,11 +3,11 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .base import BaseHTML
@@ -17,82 +17,52 @@ class Details(BaseHTML):
def create( # type: ignore
cls,
*children,
- open: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ open: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Details":
"""Create the component.
@@ -100,7 +70,7 @@ class Details(BaseHTML):
Args:
*children: The children of the component.
open: Indicates whether the details will be visible (expanded) to the user
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -135,82 +105,52 @@ class Dialog(BaseHTML):
def create( # type: ignore
cls,
*children,
- open: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ open: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Dialog":
"""Create the component.
@@ -218,7 +158,7 @@ class Dialog(BaseHTML):
Args:
*children: The children of the component.
open: Indicates whether the dialog is active and can be interacted with
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -253,88 +193,58 @@ class Summary(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Summary":
"""Create the component.
Args:
*children: The children of the component.
- access_key: No unique attributes, only common ones are inherited; used as a summary or caption for a element Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -369,88 +279,58 @@ class Slot(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Slot":
"""Create the component.
Args:
*children: The children of the component.
- access_key: No unique attributes, only common ones are inherited; used as a placeholder inside a web component Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -485,88 +365,58 @@ class Template(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Template":
"""Create the component.
Args:
*children: The children of the component.
- access_key: No unique attributes, only common ones are inherited; used for declaring fragments of HTML that can be cloned and inserted in the document Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -601,88 +451,58 @@ class Math(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Math":
"""Create the component.
Args:
*children: The children of the component.
- access_key: No unique attributes, only common ones are inherited; used for displaying mathematical expressions Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -717,82 +537,52 @@ class Html(BaseHTML):
def create( # type: ignore
cls,
*children,
- manifest: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ manifest: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Html":
"""Create the component.
@@ -800,7 +590,7 @@ class Html(BaseHTML):
Args:
*children: The children of the component.
manifest: Specifies the URL of the document's cache manifest (obsolete in HTML5)
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/el/elements/scripts.py b/reflex/components/el/elements/scripts.py
index 09a9fd17a..c30931e99 100644
--- a/reflex/components/el/elements/scripts.py
+++ b/reflex/components/el/elements/scripts.py
@@ -1,8 +1,8 @@
-"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
+"""Scripts classes."""
from typing import Union
-from reflex.vars import Var as Var
+from reflex.vars.base import Var
from .base import BaseHTML
@@ -17,7 +17,6 @@ class Noscript(BaseHTML):
"""Display the noscript element."""
tag = "noscript"
- # No unique attributes, only common ones are inherited
class Script(BaseHTML):
diff --git a/reflex/components/el/elements/scripts.pyi b/reflex/components/el/elements/scripts.pyi
index d7858dde8..c66e150af 100644
--- a/reflex/components/el/elements/scripts.pyi
+++ b/reflex/components/el/elements/scripts.pyi
@@ -3,11 +3,11 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .base import BaseHTML
@@ -17,88 +17,58 @@ class Canvas(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Canvas":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -133,88 +103,58 @@ class Noscript(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Noscript":
"""Create the component.
Args:
*children: The children of the component.
- access_key: No unique attributes, only common ones are inherited Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -249,94 +189,64 @@ class Script(BaseHTML):
def create( # type: ignore
cls,
*children,
- async_: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- char_set: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ async_: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ char_set: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
cross_origin: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- defer: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- integrity: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- language: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ defer: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ integrity: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ language: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
referrer_policy: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Script":
"""Create the component.
@@ -352,7 +262,7 @@ class Script(BaseHTML):
referrer_policy: Specifies which referrer information to send when fetching the script
src: URL of an external script
type: Specifies the MIME type of the script
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/el/elements/sectioning.py b/reflex/components/el/elements/sectioning.py
index e1544bd15..cfe82b6d5 100644
--- a/reflex/components/el/elements/sectioning.py
+++ b/reflex/components/el/elements/sectioning.py
@@ -1,95 +1,93 @@
-"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
-
-from reflex.vars import Var as Var
+"""Sectioning classes."""
from .base import BaseHTML
-class Body(BaseHTML): # noqa: E742
+class Body(BaseHTML):
"""Display the body element."""
tag = "body"
-class Address(BaseHTML): # noqa: E742
+class Address(BaseHTML):
"""Display the address element."""
tag = "address"
-class Article(BaseHTML): # noqa: E742
+class Article(BaseHTML):
"""Display the article element."""
tag = "article"
-class Aside(BaseHTML): # noqa: E742
+class Aside(BaseHTML):
"""Display the aside element."""
tag = "aside"
-class Footer(BaseHTML): # noqa: E742
+class Footer(BaseHTML):
"""Display the footer element."""
tag = "footer"
-class Header(BaseHTML): # noqa: E742
+class Header(BaseHTML):
"""Display the header element."""
tag = "header"
-class H1(BaseHTML): # noqa: E742
+class H1(BaseHTML):
"""Display the h1 element."""
tag = "h1"
-class H2(BaseHTML): # noqa: E742
+class H2(BaseHTML):
"""Display the h1 element."""
tag = "h2"
-class H3(BaseHTML): # noqa: E742
+class H3(BaseHTML):
"""Display the h1 element."""
tag = "h3"
-class H4(BaseHTML): # noqa: E742
+class H4(BaseHTML):
"""Display the h1 element."""
tag = "h4"
-class H5(BaseHTML): # noqa: E742
+class H5(BaseHTML):
"""Display the h1 element."""
tag = "h5"
-class H6(BaseHTML): # noqa: E742
+class H6(BaseHTML):
"""Display the h1 element."""
tag = "h6"
-class Main(BaseHTML): # noqa: E742
+class Main(BaseHTML):
"""Display the main element."""
tag = "main"
-class Nav(BaseHTML): # noqa: E742
+class Nav(BaseHTML):
"""Display the nav element."""
tag = "nav"
-class Section(BaseHTML): # noqa: E742
+class Section(BaseHTML):
"""Display the section element."""
tag = "section"
diff --git a/reflex/components/el/elements/sectioning.pyi b/reflex/components/el/elements/sectioning.pyi
index a6ea47d9c..ecbabe516 100644
--- a/reflex/components/el/elements/sectioning.pyi
+++ b/reflex/components/el/elements/sectioning.pyi
@@ -3,11 +3,11 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .base import BaseHTML
@@ -17,88 +17,58 @@ class Body(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Body":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -133,88 +103,58 @@ class Address(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Address":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -249,88 +189,58 @@ class Article(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Article":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -365,88 +275,58 @@ class Aside(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Aside":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -481,88 +361,58 @@ class Footer(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Footer":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -597,88 +447,58 @@ class Header(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Header":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -713,88 +533,58 @@ class H1(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "H1":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -829,88 +619,58 @@ class H2(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "H2":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -945,88 +705,58 @@ class H3(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "H3":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1061,88 +791,58 @@ class H4(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "H4":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1177,88 +877,58 @@ class H5(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "H5":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1293,88 +963,58 @@ class H6(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "H6":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1409,88 +1049,58 @@ class Main(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Main":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1525,88 +1135,58 @@ class Nav(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Nav":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1641,88 +1221,58 @@ class Section(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Section":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/el/elements/tables.py b/reflex/components/el/elements/tables.py
index 007879358..a0c10d829 100644
--- a/reflex/components/el/elements/tables.py
+++ b/reflex/components/el/elements/tables.py
@@ -1,8 +1,8 @@
-"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
+"""Tables classes."""
from typing import Union
-from reflex.vars import Var as Var
+from reflex.vars.base import Var
from .base import BaseHTML
diff --git a/reflex/components/el/elements/tables.pyi b/reflex/components/el/elements/tables.pyi
index d06d0cf6d..420bad585 100644
--- a/reflex/components/el/elements/tables.pyi
+++ b/reflex/components/el/elements/tables.pyi
@@ -3,11 +3,11 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .base import BaseHTML
@@ -17,82 +17,52 @@ class Caption(BaseHTML):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Caption":
"""Create the component.
@@ -100,7 +70,7 @@ class Caption(BaseHTML):
Args:
*children: The children of the component.
align: Alignment of the caption
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -135,83 +105,53 @@ class Col(BaseHTML):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Col":
"""Create the component.
@@ -220,7 +160,7 @@ class Col(BaseHTML):
*children: The children of the component.
align: Alignment of the content within the column
span: Number of columns the col element spans
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -255,83 +195,53 @@ class Colgroup(BaseHTML):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Colgroup":
"""Create the component.
@@ -340,7 +250,7 @@ class Colgroup(BaseHTML):
*children: The children of the component.
align: Alignment of the content within the column group
span: Number of columns the colgroup element spans
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -375,83 +285,53 @@ class Table(BaseHTML):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- summary: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ summary: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Table":
"""Create the component.
@@ -460,7 +340,7 @@ class Table(BaseHTML):
*children: The children of the component.
align: Alignment of the table
summary: Provides a summary of the table's purpose and structure
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -495,82 +375,52 @@ class Tbody(BaseHTML):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Tbody":
"""Create the component.
@@ -578,7 +428,7 @@ class Tbody(BaseHTML):
Args:
*children: The children of the component.
align: Alignment of the content within the table body
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -613,85 +463,55 @@ class Td(BaseHTML):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Td":
"""Create the component.
@@ -702,7 +522,7 @@ class Td(BaseHTML):
col_span: Number of columns a cell should span
headers: IDs of the headers associated with this cell
row_span: Number of rows a cell should span
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -737,82 +557,52 @@ class Tfoot(BaseHTML):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Tfoot":
"""Create the component.
@@ -820,7 +610,7 @@ class Tfoot(BaseHTML):
Args:
*children: The children of the component.
align: Alignment of the content within the table footer
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -855,86 +645,56 @@ class Th(BaseHTML):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- scope: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ scope: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Th":
"""Create the component.
@@ -946,7 +706,7 @@ class Th(BaseHTML):
headers: IDs of the headers associated with this header cell
row_span: Number of rows a header cell should span
scope: Scope of the header cell (row, col, rowgroup, colgroup)
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -981,82 +741,52 @@ class Thead(BaseHTML):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Thead":
"""Create the component.
@@ -1064,7 +794,7 @@ class Thead(BaseHTML):
Args:
*children: The children of the component.
align: Alignment of the content within the table header
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1099,82 +829,52 @@ class Tr(BaseHTML):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Tr":
"""Create the component.
@@ -1182,7 +882,7 @@ class Tr(BaseHTML):
Args:
*children: The children of the component.
align: Alignment of the content within the table row
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/el/elements/typography.py b/reflex/components/el/elements/typography.py
index dccad7a6d..9fa5c3a02 100644
--- a/reflex/components/el/elements/typography.py
+++ b/reflex/components/el/elements/typography.py
@@ -1,8 +1,8 @@
-"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
+"""Typography classes."""
from typing import Union
-from reflex.vars import Var as Var
+from reflex.vars.base import Var
from .base import BaseHTML
diff --git a/reflex/components/el/elements/typography.pyi b/reflex/components/el/elements/typography.pyi
index a6deb12e4..8332b3306 100644
--- a/reflex/components/el/elements/typography.pyi
+++ b/reflex/components/el/elements/typography.pyi
@@ -3,11 +3,11 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .base import BaseHTML
@@ -17,82 +17,52 @@ class Blockquote(BaseHTML):
def create( # type: ignore
cls,
*children,
- cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Blockquote":
"""Create the component.
@@ -100,7 +70,7 @@ class Blockquote(BaseHTML):
Args:
*children: The children of the component.
cite: Define the title of a work.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -135,88 +105,58 @@ class Dd(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Dd":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -251,88 +191,58 @@ class Div(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Div":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -367,88 +277,58 @@ class Dl(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Dl":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -483,88 +363,58 @@ class Dt(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Dt":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -599,88 +449,58 @@ class Figcaption(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Figcaption":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -715,82 +535,52 @@ class Hr(BaseHTML):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Hr":
"""Create the component.
@@ -798,7 +588,7 @@ class Hr(BaseHTML):
Args:
*children: The children of the component.
align: Used to specify the alignment of text content of The Element. this attribute is used in all elements.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -833,88 +623,58 @@ class Li(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Li":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -949,82 +709,52 @@ class Menu(BaseHTML):
def create( # type: ignore
cls,
*children,
- type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Menu":
"""Create the component.
@@ -1032,7 +762,7 @@ class Menu(BaseHTML):
Args:
*children: The children of the component.
type: Specifies that the menu element is a context menu.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1067,84 +797,54 @@ class Ol(BaseHTML):
def create( # type: ignore
cls,
*children,
- reversed: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- start: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ reversed: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ start: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Ol":
"""Create the component.
@@ -1154,7 +854,7 @@ class Ol(BaseHTML):
reversed: Reverses the order of the list.
start: Specifies the start value of the first list item in an ordered list.
type: Specifies the kind of marker to use in the list (letters or numbers).
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1189,88 +889,58 @@ class P(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "P":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1305,88 +975,58 @@ class Pre(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Pre":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1421,88 +1061,58 @@ class Ul(BaseHTML):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Ul":
"""Create the component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1537,83 +1147,53 @@ class Ins(BaseHTML):
def create( # type: ignore
cls,
*children,
- cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- date_time: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ date_time: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Ins":
"""Create the component.
@@ -1622,7 +1202,7 @@ class Ins(BaseHTML):
*children: The children of the component.
cite: Specifies the URL of the document that explains the reason why the text was inserted/changed.
date_time: Specifies the date and time of when the text was inserted/changed.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1657,83 +1237,53 @@ class Del(BaseHTML):
def create( # type: ignore
cls,
*children,
- cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- date_time: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ date_time: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Del":
"""Create the component.
@@ -1742,7 +1292,7 @@ class Del(BaseHTML):
*children: The children of the component.
cite: Specifies the URL of the document that explains the reason why the text was deleted.
date_time: Specifies the date and time of when the text was deleted.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/gridjs/datatable.py b/reflex/components/gridjs/datatable.py
index 6d856cf45..bd568d84a 100644
--- a/reflex/components/gridjs/datatable.py
+++ b/reflex/components/gridjs/datatable.py
@@ -9,15 +9,15 @@ from reflex.components.tags import Tag
from reflex.utils import types
from reflex.utils.imports import ImportDict
from reflex.utils.serializers import serialize
-from reflex.vars import BaseVar, ComputedVar, Var
+from reflex.vars.base import LiteralVar, Var, is_computed_var
class Gridjs(Component):
"""A component that wraps a nivo bar component."""
- library = "gridjs-react@6.0.1"
+ library = "gridjs-react@6.1.1"
- lib_dependencies: List[str] = ["gridjs@6.0.6"]
+ lib_dependencies: List[str] = ["gridjs@6.2.0"]
class DataTable(Gridjs):
@@ -65,14 +65,14 @@ class DataTable(Gridjs):
# The annotation should be provided if data is a computed var. We need this to know how to
# render pandas dataframes.
- if isinstance(data, ComputedVar) and data._var_type == Any:
+ if is_computed_var(data) and data._var_type == Any:
raise ValueError(
"Annotation of the computed var assigned to the data field should be provided."
)
if (
columns is not None
- and isinstance(columns, ComputedVar)
+ and is_computed_var(columns)
and columns._var_type == Any
):
raise ValueError(
@@ -113,24 +113,21 @@ class DataTable(Gridjs):
def _render(self) -> Tag:
if isinstance(self.data, Var) and types.is_dataframe(self.data._var_type):
- self.columns = BaseVar(
- _var_name=f"{self.data._var_name}.columns",
+ self.columns = self.data._replace(
+ _js_expr=f"{self.data._js_expr}.columns",
_var_type=List[Any],
- _var_full_name_needs_state_prefix=True,
- _var_data=self.data._var_data,
)
- self.data = BaseVar(
- _var_name=f"{self.data._var_name}.data",
+ self.data = self.data._replace(
+ _js_expr=f"{self.data._js_expr}.data",
_var_type=List[List[Any]],
- _var_full_name_needs_state_prefix=True,
- _var_data=self.data._var_data,
)
if types.is_dataframe(type(self.data)):
# If given a pandas df break up the data and columns
data = serialize(self.data)
- assert isinstance(data, dict), "Serialized dataframe should be a dict."
- self.columns = Var.create_safe(data["columns"])
- self.data = Var.create_safe(data["data"])
+ if not isinstance(data, dict):
+ raise ValueError("Serialized dataframe should be a dict.")
+ self.columns = LiteralVar.create(data["columns"])
+ self.data = LiteralVar.create(data["data"])
# Render the table.
return super()._render()
diff --git a/reflex/components/gridjs/datatable.pyi b/reflex/components/gridjs/datatable.pyi
index ee8bf6f3a..f3f732db3 100644
--- a/reflex/components/gridjs/datatable.pyi
+++ b/reflex/components/gridjs/datatable.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Optional, Union, overload
+from typing import Any, Dict, List, Optional, Union, overload
from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
from reflex.utils.imports import ImportDict
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class Gridjs(Component):
@overload
@@ -22,52 +22,22 @@ class Gridjs(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Gridjs":
"""Create the component.
@@ -94,62 +64,32 @@ class DataTable(Gridjs):
cls,
*children,
data: Optional[Any] = None,
- columns: Optional[Union[Var[List], List]] = None,
+ columns: Optional[Union[List, Var[List]]] = None,
search: Optional[Union[Var[bool], bool]] = None,
sort: Optional[Union[Var[bool], bool]] = None,
resizable: Optional[Union[Var[bool], bool]] = None,
- pagination: Optional[Union[Var[Union[Dict, bool]], bool, Dict]] = None,
+ pagination: Optional[Union[Dict, Var[Union[Dict, bool]], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DataTable":
"""Create a datatable component.
diff --git a/reflex/components/lucide/icon.py b/reflex/components/lucide/icon.py
index e9cf9ab82..b32fb8de3 100644
--- a/reflex/components/lucide/icon.py
+++ b/reflex/components/lucide/icon.py
@@ -1,8 +1,8 @@
"""Lucide Icon component."""
from reflex.components.component import Component
-from reflex.utils import console, format
-from reflex.vars import Var
+from reflex.utils import format
+from reflex.vars.base import Var
class LucideIconComponent(Component):
@@ -36,19 +36,6 @@ class Icon(LucideIconComponent):
Returns:
The created component.
"""
-
- def map_deprecated_icon_names_05(tag: str) -> str:
- new_tag = RENAMED_ICONS_05.get(tag)
- if new_tag is not None:
- console.deprecate(
- feature_name=f"icon {tag}",
- reason=f"it was renamed upstream. Use {new_tag} instead.",
- deprecation_version="0.4.6",
- removal_version="0.6.0",
- )
- return new_tag
- return tag
-
if children:
if len(children) == 1 and isinstance(children[0], str):
props["tag"] = children[0]
@@ -62,8 +49,7 @@ class Icon(LucideIconComponent):
if (
not isinstance(props["tag"], str)
- or map_deprecated_icon_names_05(format.to_snake_case(props["tag"]))
- not in LUCIDE_ICON_LIST
+ or format.to_snake_case(props["tag"]) not in LUCIDE_ICON_LIST
):
raise ValueError(
f"Invalid icon tag: {props['tag']}. Please use one of the following: {', '.join(LUCIDE_ICON_LIST[0:25])}, ..."
@@ -72,120 +58,10 @@ class Icon(LucideIconComponent):
props["tag"] = format.to_title_case(format.to_snake_case(props["tag"])) + "Icon"
props["alias"] = f"Lucide{props['tag']}"
- props.setdefault("color", f"var(--current-color)")
+ props.setdefault("color", "var(--current-color)")
return super().create(*children, **props)
-RENAMED_ICONS_05 = {
- "activity_square": "square_activity",
- "alert_circle": "circle_alert",
- "alert_octagon": "octagon_alert",
- "alert_triangle": "triangle_alert",
- "arrow_down_circle": "circle_arrow_down",
- "arrow_down_left_from_circle": "circle_arrow_out_down_left",
- "arrow_down_left_from_square": "square_arrow_out_down_left",
- "arrow_down_left_square": "square_arrow_down_left",
- "arrow_down_right_from_circle": "circle_arrow_out_down_right",
- "arrow_down_right_from_square": "square_arrow_out_down_right",
- "arrow_down_right_square": "square_arrow_down_right",
- "arrow_down_square": "square_arrow_down",
- "arrow_left_circle": "circle_arrow_left",
- "arrow_left_square": "square_arrow_left",
- "arrow_right_circle": "circle_arrow_right",
- "arrow_right_square": "square_arrow_right",
- "arrow_up_circle": "circle_arrow_up",
- "arrow_up_left_from_circle": "circle_arrow_out_up_left",
- "arrow_up_left_from_square": "square_arrow_out_up_left",
- "arrow_up_left_square": "square_arrow_up_left",
- "arrow_up_right_from_circle": "circle_arrow_out_up_right",
- "arrow_up_right_from_square": "square_arrow_out_up_right",
- "arrow_up_right_square": "square_arrow_up_right",
- "arrow_up_square": "square_arrow_up",
- "asterisk_square": "square_asterisk",
- "check_circle": "circle_check_big",
- "check_circle_2": "circle_check",
- "check_square": "square_check_big",
- "check_square_2": "square_check",
- "chevron_down_circle": "circle_chevron_down",
- "chevron_down_square": "square_chevron_down",
- "chevron_left_circle": "circle_chevron_left",
- "chevron_left_square": "square_chevron_left",
- "chevron_right_circle": "circle_chevron_right",
- "chevron_right_square": "square_chevron_right",
- "chevron_up_circle": "circle_chevron_up",
- "chevron_up_square": "square_chevron_up",
- "code_2": "code_xml",
- "code_square": "square_code",
- "contact_2": "contact_round",
- "divide_circle": "circle_divide",
- "divide_square": "square_divide",
- "dot_square": "square_dot",
- "download_cloud": "cloud_download",
- "equal_square": "square_equal",
- "form_input": "rectangle_ellipsis",
- "function_square": "square_function",
- "gantt_chart_square": "square_gantt_chart",
- "gauge_circle": "circle_gauge",
- "globe_2": "earth",
- "help_circle": "circle_help",
- "helping_hand": "hand_helping",
- "ice_cream": "ice_cream_cone",
- "ice_cream_2": "ice_cream_bowl",
- "indent": "indent_increase",
- "kanban_square": "square_kanban",
- "kanban_square_dashed": "square_dashed_kanban",
- "laptop_2": "laptop_minimal",
- "library_square": "square_library",
- "loader_2": "loader_circle",
- "m_square": "square_m",
- "menu_square": "square_menu",
- "mic_2": "mic_vocal",
- "minus_circle": "circle_minus",
- "minus_square": "square_minus",
- "more_horizontal": "ellipsis",
- "more_vertical": "ellipsis_vertical",
- "mouse_pointer_square": "square_mouse_pointer",
- "mouse_pointer_square_dashed": "square_dashed_mouse_pointer",
- "outdent": "indent_decrease",
- "palm_tree": "tree_palm",
- "parking_circle": "circle_parking",
- "parking_circle_off": "circle_parking_off",
- "parking_square": "square_parking",
- "parking_square_off": "square_parking_off",
- "pause_circle": "circle_pause",
- "pause_octagon": "octagon_pause",
- "percent_circle": "circle_percent",
- "percent_diamond": "diamond_percent",
- "percent_square": "square_percent",
- "pi_square": "square_pi",
- "pilcrow_square": "square_pilcrow",
- "play_circle": "circle_play",
- "play_square": "square_play",
- "plus_circle": "circle_plus",
- "plus_square": "square_plus",
- "power_circle": "circle_power",
- "power_square": "square_power",
- "school_2": "university",
- "scissors_square": "square_scissors",
- "scissors_square_dashed_bottom": "square_bottom_dashed_scissors",
- "sigma_square": "square_sigma",
- "slash_circle": "circle_slash",
- "sliders": "sliders_vertical",
- "split_square_horizontal": "square_split_horizontal",
- "split_square_vertical": "square_split_vertical",
- "stop_circle": "circle_stop",
- "subtitles": "captions",
- "test_tube_2": "test_tube_diagonal",
- "unlock": "lock_open",
- "unlock_keyhole": "lock_keyhole_open",
- "upload_cloud": "cloud_upload",
- "wallet_2": "wallet_minimal",
- "wand_2": "wand_sparkles",
- "x_circle": "circle_x",
- "x_octagon": "octagon_x",
- "x_square": "square_x",
-}
-
LUCIDE_ICON_LIST = [
"a_arrow_down",
"a_arrow_up",
diff --git a/reflex/components/lucide/icon.pyi b/reflex/components/lucide/icon.pyi
index 7fc7ee38d..7f59edec5 100644
--- a/reflex/components/lucide/icon.pyi
+++ b/reflex/components/lucide/icon.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class LucideIconComponent(Component):
@overload
@@ -21,52 +21,22 @@ class LucideIconComponent(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "LucideIconComponent":
"""Create the component.
@@ -98,52 +68,22 @@ class Icon(LucideIconComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Icon":
"""Initialize the Icon component.
@@ -170,115 +110,6 @@ class Icon(LucideIconComponent):
"""
...
-RENAMED_ICONS_05 = {
- "activity_square": "square_activity",
- "alert_circle": "circle_alert",
- "alert_octagon": "octagon_alert",
- "alert_triangle": "triangle_alert",
- "arrow_down_circle": "circle_arrow_down",
- "arrow_down_left_from_circle": "circle_arrow_out_down_left",
- "arrow_down_left_from_square": "square_arrow_out_down_left",
- "arrow_down_left_square": "square_arrow_down_left",
- "arrow_down_right_from_circle": "circle_arrow_out_down_right",
- "arrow_down_right_from_square": "square_arrow_out_down_right",
- "arrow_down_right_square": "square_arrow_down_right",
- "arrow_down_square": "square_arrow_down",
- "arrow_left_circle": "circle_arrow_left",
- "arrow_left_square": "square_arrow_left",
- "arrow_right_circle": "circle_arrow_right",
- "arrow_right_square": "square_arrow_right",
- "arrow_up_circle": "circle_arrow_up",
- "arrow_up_left_from_circle": "circle_arrow_out_up_left",
- "arrow_up_left_from_square": "square_arrow_out_up_left",
- "arrow_up_left_square": "square_arrow_up_left",
- "arrow_up_right_from_circle": "circle_arrow_out_up_right",
- "arrow_up_right_from_square": "square_arrow_out_up_right",
- "arrow_up_right_square": "square_arrow_up_right",
- "arrow_up_square": "square_arrow_up",
- "asterisk_square": "square_asterisk",
- "check_circle": "circle_check_big",
- "check_circle_2": "circle_check",
- "check_square": "square_check_big",
- "check_square_2": "square_check",
- "chevron_down_circle": "circle_chevron_down",
- "chevron_down_square": "square_chevron_down",
- "chevron_left_circle": "circle_chevron_left",
- "chevron_left_square": "square_chevron_left",
- "chevron_right_circle": "circle_chevron_right",
- "chevron_right_square": "square_chevron_right",
- "chevron_up_circle": "circle_chevron_up",
- "chevron_up_square": "square_chevron_up",
- "code_2": "code_xml",
- "code_square": "square_code",
- "contact_2": "contact_round",
- "divide_circle": "circle_divide",
- "divide_square": "square_divide",
- "dot_square": "square_dot",
- "download_cloud": "cloud_download",
- "equal_square": "square_equal",
- "form_input": "rectangle_ellipsis",
- "function_square": "square_function",
- "gantt_chart_square": "square_gantt_chart",
- "gauge_circle": "circle_gauge",
- "globe_2": "earth",
- "help_circle": "circle_help",
- "helping_hand": "hand_helping",
- "ice_cream": "ice_cream_cone",
- "ice_cream_2": "ice_cream_bowl",
- "indent": "indent_increase",
- "kanban_square": "square_kanban",
- "kanban_square_dashed": "square_dashed_kanban",
- "laptop_2": "laptop_minimal",
- "library_square": "square_library",
- "loader_2": "loader_circle",
- "m_square": "square_m",
- "menu_square": "square_menu",
- "mic_2": "mic_vocal",
- "minus_circle": "circle_minus",
- "minus_square": "square_minus",
- "more_horizontal": "ellipsis",
- "more_vertical": "ellipsis_vertical",
- "mouse_pointer_square": "square_mouse_pointer",
- "mouse_pointer_square_dashed": "square_dashed_mouse_pointer",
- "outdent": "indent_decrease",
- "palm_tree": "tree_palm",
- "parking_circle": "circle_parking",
- "parking_circle_off": "circle_parking_off",
- "parking_square": "square_parking",
- "parking_square_off": "square_parking_off",
- "pause_circle": "circle_pause",
- "pause_octagon": "octagon_pause",
- "percent_circle": "circle_percent",
- "percent_diamond": "diamond_percent",
- "percent_square": "square_percent",
- "pi_square": "square_pi",
- "pilcrow_square": "square_pilcrow",
- "play_circle": "circle_play",
- "play_square": "square_play",
- "plus_circle": "circle_plus",
- "plus_square": "square_plus",
- "power_circle": "circle_power",
- "power_square": "square_power",
- "school_2": "university",
- "scissors_square": "square_scissors",
- "scissors_square_dashed_bottom": "square_bottom_dashed_scissors",
- "sigma_square": "square_sigma",
- "slash_circle": "circle_slash",
- "sliders": "sliders_vertical",
- "split_square_horizontal": "square_split_horizontal",
- "split_square_vertical": "square_split_vertical",
- "stop_circle": "circle_stop",
- "subtitles": "captions",
- "test_tube_2": "test_tube_diagonal",
- "unlock": "lock_open",
- "unlock_keyhole": "lock_keyhole_open",
- "upload_cloud": "cloud_upload",
- "wallet_2": "wallet_minimal",
- "wand_2": "wand_sparkles",
- "x_circle": "circle_x",
- "x_octagon": "octagon_x",
- "x_square": "square_x",
-}
LUCIDE_ICON_LIST = [
"a_arrow_down",
"a_arrow_up",
diff --git a/reflex/components/markdown/markdown.py b/reflex/components/markdown/markdown.py
index e62c85af3..cd82d5903 100644
--- a/reflex/components/markdown/markdown.py
+++ b/reflex/components/markdown/markdown.py
@@ -2,44 +2,37 @@
from __future__ import annotations
+import dataclasses
import textwrap
from functools import lru_cache
from hashlib import md5
-from typing import Any, Callable, Dict, Union
+from typing import Any, Callable, Dict, Sequence, Union
from reflex.components.component import Component, CustomComponent
-from reflex.components.radix.themes.layout.list import (
- ListItem,
- OrderedList,
- UnorderedList,
-)
-from reflex.components.radix.themes.typography.heading import Heading
-from reflex.components.radix.themes.typography.link import Link
-from reflex.components.radix.themes.typography.text import Text
from reflex.components.tags.tag import Tag
from reflex.utils import types
from reflex.utils.imports import ImportDict, ImportVar
-from reflex.vars import Var
+from reflex.vars.base import LiteralVar, Var
+from reflex.vars.function import ARRAY_ISARRAY, ArgsFunctionOperation, DestructuredArg
+from reflex.vars.number import ternary_operation
# Special vars used in the component map.
-_CHILDREN = Var.create_safe("children", _var_is_local=False, _var_is_string=False)
-_PROPS = Var.create_safe("...props", _var_is_local=False, _var_is_string=False)
-_MOCK_ARG = Var.create_safe("", _var_is_string=False)
+_CHILDREN = Var(_js_expr="children", _var_type=str)
+_PROPS = Var(_js_expr="...props")
+_PROPS_IN_TAG = Var(_js_expr="{...props}")
+_MOCK_ARG = Var(_js_expr="", _var_type=str)
+_LANGUAGE = Var(_js_expr="_language", _var_type=str)
# Special remark plugins.
-_REMARK_MATH = Var.create_safe("remarkMath", _var_is_local=False, _var_is_string=False)
-_REMARK_GFM = Var.create_safe("remarkGfm", _var_is_local=False, _var_is_string=False)
-_REMARK_UNWRAP_IMAGES = Var.create_safe(
- "remarkUnwrapImages", _var_is_local=False, _var_is_string=False
-)
-_REMARK_PLUGINS = Var.create_safe([_REMARK_MATH, _REMARK_GFM, _REMARK_UNWRAP_IMAGES])
+_REMARK_MATH = Var(_js_expr="remarkMath")
+_REMARK_GFM = Var(_js_expr="remarkGfm")
+_REMARK_UNWRAP_IMAGES = Var(_js_expr="remarkUnwrapImages")
+_REMARK_PLUGINS = LiteralVar.create([_REMARK_MATH, _REMARK_GFM, _REMARK_UNWRAP_IMAGES])
# Special rehype plugins.
-_REHYPE_KATEX = Var.create_safe(
- "rehypeKatex", _var_is_local=False, _var_is_string=False
-)
-_REHYPE_RAW = Var.create_safe("rehypeRaw", _var_is_local=False, _var_is_string=False)
-_REHYPE_PLUGINS = Var.create_safe([_REHYPE_KATEX, _REHYPE_RAW])
+_REHYPE_KATEX = Var(_js_expr="rehypeKatex")
+_REHYPE_RAW = Var(_js_expr="rehypeRaw")
+_REHYPE_PLUGINS = LiteralVar.create([_REHYPE_KATEX, _REHYPE_RAW])
# These tags do NOT get props passed to them
NO_PROPS_TAGS = ("ul", "ol", "li")
@@ -54,7 +47,15 @@ def get_base_component_map() -> dict[str, Callable]:
The base component map.
"""
from reflex.components.datadisplay.code import CodeBlock
+ from reflex.components.radix.themes.layout.list import (
+ ListItem,
+ OrderedList,
+ UnorderedList,
+ )
from reflex.components.radix.themes.typography.code import Code
+ from reflex.components.radix.themes.typography.heading import Heading
+ from reflex.components.radix.themes.typography.link import Link
+ from reflex.components.radix.themes.typography.text import Text
return {
"h1": lambda value: Heading.create(value, as_="h1", size="6", margin_y="0.5em"),
@@ -70,11 +71,72 @@ def get_base_component_map() -> dict[str, Callable]:
"a": lambda value: Link.create(value),
"code": lambda value: Code.create(value),
"codeblock": lambda value, **props: CodeBlock.create(
- value, margin_y="1em", **props
+ value, margin_y="1em", wrap_long_lines=True, **props
),
}
+@dataclasses.dataclass()
+class MarkdownComponentMap:
+ """Mixin class for handling custom component maps in Markdown components."""
+
+ _explicit_return: bool = dataclasses.field(default=False)
+
+ @classmethod
+ def get_component_map_custom_code(cls) -> str:
+ """Get the custom code for the component map.
+
+ Returns:
+ The custom code for the component map.
+ """
+ return ""
+
+ @classmethod
+ def create_map_fn_var(
+ cls,
+ fn_body: Var | None = None,
+ fn_args: Sequence[str] | None = None,
+ explicit_return: bool | None = None,
+ ) -> Var:
+ """Create a function Var for the component map.
+
+ Args:
+ fn_body: The formatted component as a string.
+ fn_args: The function arguments.
+ explicit_return: Whether to use explicit return syntax.
+
+ Returns:
+ The function Var for the component map.
+ """
+ fn_args = fn_args or cls.get_fn_args()
+ fn_body = fn_body if fn_body is not None else cls.get_fn_body()
+ explicit_return = explicit_return or cls._explicit_return
+
+ return ArgsFunctionOperation.create(
+ args_names=(DestructuredArg(fields=tuple(fn_args)),),
+ return_expr=fn_body,
+ explicit_return=explicit_return,
+ )
+
+ @classmethod
+ def get_fn_args(cls) -> Sequence[str]:
+ """Get the function arguments for the component map.
+
+ Returns:
+ The function arguments as a list of strings.
+ """
+ return ["node", _CHILDREN._js_expr, _PROPS._js_expr]
+
+ @classmethod
+ def get_fn_body(cls) -> Var:
+ """Get the function body for the component map.
+
+ Returns:
+ The function body as a string.
+ """
+ return Var(_js_expr="undefined", _var_type=None)
+
+
class Markdown(Component):
"""A markdown component."""
@@ -98,12 +160,16 @@ class Markdown(Component):
*children: The children of the component.
**props: The properties of the component.
+ Raises:
+ ValueError: If the children are not valid.
+
Returns:
The markdown component.
"""
- assert (
- len(children) == 1 and types._isinstance(children[0], Union[str, Var])
- ), "Markdown component must have exactly one child containing the markdown source."
+ if len(children) != 1 or not types._isinstance(children[0], Union[str, Var]):
+ raise ValueError(
+ "Markdown component must have exactly one child containing the markdown source."
+ )
# Update the base component map with the custom component map.
component_map = {**get_base_component_map(), **props.pop("component_map", {})}
@@ -150,36 +216,94 @@ class Markdown(Component):
Returns:
The imports for the markdown component.
"""
- from reflex.components.datadisplay.code import CodeBlock
- from reflex.components.radix.themes.typography.code import Code
-
return [
{
"": "katex/dist/katex.min.css",
"remark-math@5.1.1": ImportVar(
- tag=_REMARK_MATH._var_name, is_default=True
+ tag=_REMARK_MATH._js_expr, is_default=True
),
"remark-gfm@3.0.1": ImportVar(
- tag=_REMARK_GFM._var_name, is_default=True
+ tag=_REMARK_GFM._js_expr, is_default=True
),
"remark-unwrap-images@4.0.0": ImportVar(
- tag=_REMARK_UNWRAP_IMAGES._var_name, is_default=True
+ tag=_REMARK_UNWRAP_IMAGES._js_expr, is_default=True
),
"rehype-katex@6.0.3": ImportVar(
- tag=_REHYPE_KATEX._var_name, is_default=True
+ tag=_REHYPE_KATEX._js_expr, is_default=True
),
"rehype-raw@6.1.1": ImportVar(
- tag=_REHYPE_RAW._var_name, is_default=True
+ tag=_REHYPE_RAW._js_expr, is_default=True
),
},
*[
- component(_MOCK_ARG)._get_imports() # type: ignore
+ component(_MOCK_ARG)._get_all_imports() # type: ignore
for component in self.component_map.values()
],
- CodeBlock.create(theme="light")._get_imports(), # type: ignore,
- Code.create()._get_imports(), # type: ignore,
]
+ def _get_tag_map_fn_var(self, tag: str) -> Var:
+ return self._get_map_fn_var_from_children(self.get_component(tag), tag)
+
+ def format_component_map(self) -> dict[str, Var]:
+ """Format the component map for rendering.
+
+ Returns:
+ The formatted component map.
+ """
+ components = {
+ tag: self._get_tag_map_fn_var(tag)
+ for tag in self.component_map
+ if tag not in ("code", "codeblock")
+ }
+
+ # Separate out inline code and code blocks.
+ components["code"] = self._get_inline_code_fn_var()
+
+ return components
+
+ def _get_inline_code_fn_var(self) -> Var:
+ """Get the function variable for inline code.
+
+ This function creates a Var that represents a function to handle
+ both inline code and code blocks in markdown.
+
+ Returns:
+ The Var for inline code.
+ """
+ # Get any custom code from the codeblock and code components.
+ custom_code_list = self._get_map_fn_custom_code_from_children(
+ self.get_component("codeblock")
+ )
+ custom_code_list.extend(
+ self._get_map_fn_custom_code_from_children(self.get_component("code"))
+ )
+
+ codeblock_custom_code = "\n".join(custom_code_list)
+
+ # Format the code to handle inline and block code.
+ formatted_code = f"""
+const match = (className || '').match(/language-(?.*)/);
+const {_LANGUAGE!s} = match ? match[1] : '';
+{codeblock_custom_code};
+ return inline ? (
+ {self.format_component("code")}
+ ) : (
+ {self.format_component("codeblock", language=_LANGUAGE)}
+ );
+ """.replace("\n", " ")
+
+ return MarkdownComponentMap.create_map_fn_var(
+ fn_args=(
+ "node",
+ "inline",
+ "className",
+ _CHILDREN._js_expr,
+ _PROPS._js_expr,
+ ),
+ fn_body=Var(_js_expr=formatted_code),
+ explicit_return=True,
+ )
+
def get_component(self, tag: str, **props) -> Component:
"""Get the component for a tag and props.
@@ -197,21 +321,27 @@ class Markdown(Component):
if tag not in self.component_map:
raise ValueError(f"No markdown component found for tag: {tag}.")
- special_props = {_PROPS}
- children = [_CHILDREN]
+ special_props = [_PROPS_IN_TAG]
+ children = [
+ _CHILDREN
+ if tag != "codeblock"
+ # For codeblock, the mapping for some cases returns an array of elements. Let's join them into a string.
+ else ternary_operation(
+ ARRAY_ISARRAY.call(_CHILDREN), # type: ignore
+ _CHILDREN.to(list).join("\n"),
+ _CHILDREN,
+ ).to(str)
+ ]
# For certain tags, the props from the markdown renderer are not actually valid for the component.
if tag in NO_PROPS_TAGS:
- special_props = set()
+ special_props = []
# If the children are set as a prop, don't pass them as children.
children_prop = props.pop("children", None)
if children_prop is not None:
- special_props.add(
- Var.create_safe(f"children={str(children_prop)}", _var_is_string=False)
- )
+ special_props.append(Var(_js_expr=f"children={{{children_prop!s}}}"))
children = []
-
# Get the component.
component = self.component_map[tag](*children, **props).set(
special_props=special_props
@@ -230,41 +360,53 @@ class Markdown(Component):
"""
return str(self.get_component(tag, **props)).replace("\n", "")
- def format_component_map(self) -> dict[str, str]:
- """Format the component map for rendering.
+ def _get_map_fn_var_from_children(self, component: Component, tag: str) -> Var:
+ """Create a function Var for the component map for the specified tag.
+
+ Args:
+ component: The component to check for custom code.
+ tag: The tag of the component.
Returns:
- The formatted component map.
+ The function Var for the component map.
"""
- components = {
- tag: f"{{({{node, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {self.format_component(tag)}}}"
- for tag in self.component_map
- }
+ formatted_component = Var(
+ _js_expr=f"({self.format_component(tag)})", _var_type=str
+ )
+ if isinstance(component, MarkdownComponentMap):
+ return component.create_map_fn_var(fn_body=formatted_component)
- # Separate out inline code and code blocks.
- components[
- "code"
- ] = f"""{{({{node, inline, className, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {{
- const match = (className || '').match(/language-(?.*)/);
- const language = match ? match[1] : '';
- if (language) {{
- (async () => {{
- try {{
- const module = await import(`react-syntax-highlighter/dist/cjs/languages/prism/${{language}}`);
- SyntaxHighlighter.registerLanguage(language, module.default);
- }} catch (error) {{
- console.error(`Error importing language module for ${{language}}:`, error);
- }}
- }})();
- }}
- return inline ? (
- {self.format_component("code")}
- ) : (
- {self.format_component("codeblock", language=Var.create_safe("language", _var_is_local=False, _var_is_string=False))}
- );
- }}}}""".replace("\n", " ")
+ # fallback to the default fn Var creation if the component is not a MarkdownComponentMap.
+ return MarkdownComponentMap.create_map_fn_var(fn_body=formatted_component)
- return components
+ def _get_map_fn_custom_code_from_children(self, component) -> list[str]:
+ """Recursively get markdown custom code from children components.
+
+ Args:
+ component: The component to check for custom code.
+
+ Returns:
+ A list of markdown custom code strings.
+ """
+ custom_code_list = []
+ if isinstance(component, MarkdownComponentMap):
+ custom_code_list.append(component.get_component_map_custom_code())
+
+ # If the component is a custom component(rx.memo), obtain the underlining
+ # component and get the custom code from the children.
+ if isinstance(component, CustomComponent):
+ custom_code_list.extend(
+ self._get_map_fn_custom_code_from_children(
+ component.component_fn(*component.get_prop_vars())
+ )
+ )
+ elif isinstance(component, Component):
+ for child in component.children:
+ custom_code_list.extend(
+ self._get_map_fn_custom_code_from_children(child)
+ )
+
+ return custom_code_list
@staticmethod
def _component_map_hash(component_map) -> str:
@@ -277,17 +419,17 @@ class Markdown(Component):
return f"ComponentMap_{self.component_map_hash}"
def _get_custom_code(self) -> str | None:
- hooks = set()
+ hooks = {}
for _component in self.component_map.values():
comp = _component(_MOCK_ARG)
hooks.update(comp._get_all_hooks_internal())
hooks.update(comp._get_all_hooks())
- formatted_hooks = "\n".join(hooks)
+ formatted_hooks = "\n".join(hooks.keys())
return f"""
function {self._get_component_map_name()} () {{
{formatted_hooks}
return (
- {str(Var.create(self.format_component_map()))}
+ {LiteralVar.create(self.format_component_map())!s}
)
}}
"""
@@ -299,14 +441,8 @@ class Markdown(Component):
.add_props(
remark_plugins=_REMARK_PLUGINS,
rehype_plugins=_REHYPE_PLUGINS,
+ components=Var(_js_expr=f"{self._get_component_map_name()}()"),
)
.remove_props("componentMap", "componentMapHash")
)
- tag.special_props.add(
- Var.create_safe(
- f"components={{{self._get_component_map_name()}()}}",
- _var_is_local=True,
- _var_is_string=False,
- ),
- )
return tag
diff --git a/reflex/components/markdown/markdown.pyi b/reflex/components/markdown/markdown.pyi
index e0eb43454..1c329fb8c 100644
--- a/reflex/components/markdown/markdown.pyi
+++ b/reflex/components/markdown/markdown.pyi
@@ -3,33 +3,47 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
+import dataclasses
from functools import lru_cache
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Callable, Dict, Optional, Sequence, Union, overload
from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
from reflex.utils.imports import ImportDict
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import LiteralVar, Var
-_CHILDREN = Var.create_safe("children", _var_is_local=False, _var_is_string=False)
-_PROPS = Var.create_safe("...props", _var_is_local=False, _var_is_string=False)
-_MOCK_ARG = Var.create_safe("", _var_is_string=False)
-_REMARK_MATH = Var.create_safe("remarkMath", _var_is_local=False, _var_is_string=False)
-_REMARK_GFM = Var.create_safe("remarkGfm", _var_is_local=False, _var_is_string=False)
-_REMARK_UNWRAP_IMAGES = Var.create_safe(
- "remarkUnwrapImages", _var_is_local=False, _var_is_string=False
-)
-_REMARK_PLUGINS = Var.create_safe([_REMARK_MATH, _REMARK_GFM, _REMARK_UNWRAP_IMAGES])
-_REHYPE_KATEX = Var.create_safe(
- "rehypeKatex", _var_is_local=False, _var_is_string=False
-)
-_REHYPE_RAW = Var.create_safe("rehypeRaw", _var_is_local=False, _var_is_string=False)
-_REHYPE_PLUGINS = Var.create_safe([_REHYPE_KATEX, _REHYPE_RAW])
+_CHILDREN = Var(_js_expr="children", _var_type=str)
+_PROPS = Var(_js_expr="...props")
+_PROPS_IN_TAG = Var(_js_expr="{...props}")
+_MOCK_ARG = Var(_js_expr="", _var_type=str)
+_LANGUAGE = Var(_js_expr="_language", _var_type=str)
+_REMARK_MATH = Var(_js_expr="remarkMath")
+_REMARK_GFM = Var(_js_expr="remarkGfm")
+_REMARK_UNWRAP_IMAGES = Var(_js_expr="remarkUnwrapImages")
+_REMARK_PLUGINS = LiteralVar.create([_REMARK_MATH, _REMARK_GFM, _REMARK_UNWRAP_IMAGES])
+_REHYPE_KATEX = Var(_js_expr="rehypeKatex")
+_REHYPE_RAW = Var(_js_expr="rehypeRaw")
+_REHYPE_PLUGINS = LiteralVar.create([_REHYPE_KATEX, _REHYPE_RAW])
NO_PROPS_TAGS = ("ul", "ol", "li")
@lru_cache
def get_base_component_map() -> dict[str, Callable]: ...
+@dataclasses.dataclass()
+class MarkdownComponentMap:
+ @classmethod
+ def get_component_map_custom_code(cls) -> str: ...
+ @classmethod
+ def create_map_fn_var(
+ cls,
+ fn_body: Var | None = None,
+ fn_args: Sequence[str] | None = None,
+ explicit_return: bool | None = None,
+ ) -> Var: ...
+ @classmethod
+ def get_fn_args(cls) -> Sequence[str]: ...
+ @classmethod
+ def get_fn_body(cls) -> Var: ...
class Markdown(Component):
@overload
@@ -44,52 +58,22 @@ class Markdown(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Markdown":
"""Create a markdown component.
@@ -106,12 +90,15 @@ class Markdown(Component):
custom_attrs: custom attribute
**props: The properties of the component.
+ Raises:
+ ValueError: If the children are not valid.
+
Returns:
The markdown component.
"""
...
def add_imports(self) -> ImportDict | list[ImportDict]: ...
+ def format_component_map(self) -> dict[str, Var]: ...
def get_component(self, tag: str, **props) -> Component: ...
def format_component(self, tag: str, **props) -> str: ...
- def format_component_map(self) -> dict[str, str]: ...
diff --git a/reflex/components/media/__init__.py b/reflex/components/media/__init__.py
deleted file mode 100644
index ee11c77e0..000000000
--- a/reflex/components/media/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-"""Temporary shim for Chakra icon class."""
diff --git a/reflex/components/media/icon.py b/reflex/components/media/icon.py
deleted file mode 100644
index eaca071e7..000000000
--- a/reflex/components/media/icon.py
+++ /dev/null
@@ -1,3 +0,0 @@
-"""Shim for reflex.components.chakra.media.icon."""
-
-from reflex.components.chakra.media.icon import *
diff --git a/reflex/components/moment/moment.py b/reflex/components/moment/moment.py
index 958ba6c57..80940d228 100644
--- a/reflex/components/moment/moment.py
+++ b/reflex/components/moment/moment.py
@@ -1,26 +1,28 @@
"""Moment component for humanized date rendering."""
-from typing import List, Optional
+import dataclasses
+from datetime import date, datetime, time, timedelta
+from typing import List, Optional, Union
-from reflex.base import Base
-from reflex.components.component import Component, NoSSRComponent
-from reflex.event import EventHandler
+from reflex.components.component import NoSSRComponent
+from reflex.event import EventHandler, passthrough_event_spec
from reflex.utils.imports import ImportDict
-from reflex.vars import Var
+from reflex.vars.base import LiteralVar, Var
-class MomentDelta(Base):
+@dataclasses.dataclass(frozen=True)
+class MomentDelta:
"""A delta used for add/subtract prop in Moment."""
- years: Optional[int]
- quarters: Optional[int]
- months: Optional[int]
- weeks: Optional[int]
- days: Optional[int]
- hours: Optional[int]
- minutess: Optional[int]
- seconds: Optional[int]
- milliseconds: Optional[int]
+ years: Optional[int] = dataclasses.field(default=None)
+ quarters: Optional[int] = dataclasses.field(default=None)
+ months: Optional[int] = dataclasses.field(default=None)
+ weeks: Optional[int] = dataclasses.field(default=None)
+ days: Optional[int] = dataclasses.field(default=None)
+ hours: Optional[int] = dataclasses.field(default=None)
+ minutes: Optional[int] = dataclasses.field(default=None)
+ seconds: Optional[int] = dataclasses.field(default=None)
+ milliseconds: Optional[int] = dataclasses.field(default=None)
class Moment(NoSSRComponent):
@@ -77,7 +79,7 @@ class Moment(NoSSRComponent):
duration: Var[str]
# The date to display (also work if passed as children).
- date: Var[str]
+ date: Var[Union[str, datetime, date, time, timedelta]]
# Shows the duration (elapsed time) between now and the provided datetime.
duration_from_now: Var[bool]
@@ -91,8 +93,11 @@ class Moment(NoSSRComponent):
# Display the date in the given timezone.
tz: Var[str]
+ # The locale to use when rendering.
+ locale: Var[str]
+
# Fires when the date changes.
- on_change: EventHandler[lambda date: [date]]
+ on_change: EventHandler[passthrough_event_spec(str)]
def add_imports(self) -> ImportDict:
"""Add the imports for the Moment component.
@@ -100,22 +105,15 @@ class Moment(NoSSRComponent):
Returns:
The import dict for the component.
"""
+ imports = {}
+
+ if isinstance(self.locale, LiteralVar):
+ imports[""] = f"moment/locale/{self.locale._var_value}"
+ elif self.locale is not None:
+ # If the user is using a variable for the locale, we can't know the
+ # value at compile time so import all locales available.
+ imports[""] = "moment/min/locales"
if self.tz is not None:
- return {"moment-timezone": ""}
- return {}
+ imports["moment-timezone"] = ""
- @classmethod
- def create(cls, *children, **props) -> Component:
- """Create a Moment component.
-
- Args:
- *children: The children of the component.
- **props: The properties of the component.
-
- Returns:
- The Moment Component.
- """
- comp = super().create(*children, **props)
- if "tz" in props:
- comp.lib_dependencies.append("moment-timezone")
- return comp
+ return imports
diff --git a/reflex/components/moment/moment.pyi b/reflex/components/moment/moment.pyi
index 5497a5336..83ab670b0 100644
--- a/reflex/components/moment/moment.pyi
+++ b/reflex/components/moment/moment.pyi
@@ -3,23 +3,25 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+import dataclasses
+from datetime import date, datetime, time, timedelta
+from typing import Any, Dict, Optional, Union, overload
-from reflex.base import Base
from reflex.components.component import NoSSRComponent
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
from reflex.utils.imports import ImportDict
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
-class MomentDelta(Base):
+@dataclasses.dataclass(frozen=True)
+class MomentDelta:
years: Optional[int]
quarters: Optional[int]
months: Optional[int]
weeks: Optional[int]
days: Optional[int]
hours: Optional[int]
- minutess: Optional[int]
+ minutes: Optional[int]
seconds: Optional[int]
milliseconds: Optional[int]
@@ -34,8 +36,8 @@ class Moment(NoSSRComponent):
format: Optional[Union[Var[str], str]] = None,
trim: Optional[Union[Var[bool], bool]] = None,
parse: Optional[Union[Var[str], str]] = None,
- add: Optional[Union[Var[MomentDelta], MomentDelta]] = None,
- subtract: Optional[Union[Var[MomentDelta], MomentDelta]] = None,
+ add: Optional[Union[MomentDelta, Var[MomentDelta]]] = None,
+ subtract: Optional[Union[MomentDelta, Var[MomentDelta]]] = None,
from_now: Optional[Union[Var[bool], bool]] = None,
from_now_during: Optional[Union[Var[int], int]] = None,
to_now: Optional[Union[Var[bool], bool]] = None,
@@ -45,68 +47,48 @@ class Moment(NoSSRComponent):
decimal: Optional[Union[Var[bool], bool]] = None,
unit: Optional[Union[Var[str], str]] = None,
duration: Optional[Union[Var[str], str]] = None,
- date: Optional[Union[Var[str], str]] = None,
+ date: Optional[
+ Union[
+ Var[Union[date, datetime, str, time, timedelta]],
+ date,
+ datetime,
+ str,
+ time,
+ timedelta,
+ ]
+ ] = None,
duration_from_now: Optional[Union[Var[bool], bool]] = None,
unix: Optional[Union[Var[bool], bool]] = None,
local: Optional[Union[Var[bool], bool]] = None,
tz: Optional[Union[Var[str], str]] = None,
+ locale: Optional[Union[Var[str], str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Moment":
- """Create a Moment component.
+ """Create the component.
Args:
*children: The children of the component.
@@ -130,15 +112,17 @@ class Moment(NoSSRComponent):
unix: Tells Moment to parse the given date value as a unix timestamp.
local: Outputs the result in local time.
tz: Display the date in the given timezone.
+ locale: The locale to use when rendering.
+ on_change: Fires when the date changes.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
class_name: The class name for the component.
autofocus: Whether the component should take the focus once the page is loaded
custom_attrs: custom attribute
- **props: The properties of the component.
+ **props: The props of the component.
Returns:
- The Moment Component.
+ The component.
"""
...
diff --git a/reflex/components/next/base.pyi b/reflex/components/next/base.pyi
index fd561fbec..4a82d7bef 100644
--- a/reflex/components/next/base.pyi
+++ b/reflex/components/next/base.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class NextComponent(Component):
...
@@ -23,52 +23,22 @@ class NextComponent(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "NextComponent":
"""Create the component.
diff --git a/reflex/components/next/image.py b/reflex/components/next/image.py
index 108d17452..2011505d8 100644
--- a/reflex/components/next/image.py
+++ b/reflex/components/next/image.py
@@ -2,9 +2,9 @@
from typing import Any, Literal, Optional, Union
-from reflex.event import EventHandler
+from reflex.event import EventHandler, no_args_event_spec
from reflex.utils import types
-from reflex.vars import Var
+from reflex.vars.base import Var
from .base import NextComponent
@@ -47,7 +47,7 @@ class Image(NextComponent):
placeholder: Var[str]
# Allows passing CSS styles to the underlying image element.
- # style: Var[Any]
+ # style: Var[Any] #noqa: ERA001
# The loading behavior of the image. Defaults to lazy. Can hurt performance, recommended to use `priority` instead.
loading: Var[Literal["lazy", "eager"]]
@@ -56,10 +56,10 @@ class Image(NextComponent):
blurDataURL: Var[str]
# Fires when the image has loaded.
- on_load: EventHandler[lambda: []]
+ on_load: EventHandler[no_args_event_spec]
# Fires when the image has an error.
- on_error: EventHandler[lambda: []]
+ on_error: EventHandler[no_args_event_spec]
@classmethod
def create(
@@ -102,8 +102,4 @@ class Image(NextComponent):
# mysteriously, following `sizes` prop is needed to avoid blury images.
props["sizes"] = "100vw"
- src = props.get("src", None)
- if src is not None and not isinstance(src, (Var)):
- props["src"] = Var.create(value=src, _var_is_string=True)
-
return super().create(*children, **props)
diff --git a/reflex/components/next/image.pyi b/reflex/components/next/image.pyi
index a27a3420c..dd9dd38c3 100644
--- a/reflex/components/next/image.pyi
+++ b/reflex/components/next/image.pyi
@@ -3,11 +3,11 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .base import NextComponent
@@ -19,16 +19,16 @@ class Image(NextComponent):
*children,
width: Optional[Union[int, str]] = None,
height: Optional[Union[int, str]] = None,
- src: Optional[Union[Var[Any], Any]] = None,
+ src: Optional[Union[Any, Var[Any]]] = None,
alt: Optional[Union[Var[str], str]] = None,
- loader: Optional[Union[Var[Any], Any]] = None,
+ loader: Optional[Union[Any, Var[Any]]] = None,
fill: Optional[Union[Var[bool], bool]] = None,
sizes: Optional[Union[Var[str], str]] = None,
quality: Optional[Union[Var[int], int]] = None,
priority: Optional[Union[Var[bool], bool]] = None,
placeholder: Optional[Union[Var[str], str]] = None,
loading: Optional[
- Union[Var[Literal["lazy", "eager"]], Literal["lazy", "eager"]]
+ Union[Literal["eager", "lazy"], Var[Literal["eager", "lazy"]]]
] = None,
blurDataURL: Optional[Union[Var[str], str]] = None,
style: Optional[Style] = None,
@@ -36,58 +36,24 @@ class Image(NextComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_error: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_load: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_error: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_load: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Image":
"""Create an Image component from next/image.
@@ -104,8 +70,10 @@ class Image(NextComponent):
quality: The quality of the optimized image, an integer between 1 and 100, where 100 is the best quality and therefore largest file size. Defaults to 75.
priority: When true, the image will be considered high priority and preload. Lazy loading is automatically disabled for images using priority.
placeholder: A placeholder to use while the image is loading. Possible values are blur, empty, or data:image/.... Defaults to empty.
- loading: Allows passing CSS styles to the underlying image element. style: Var[Any] The loading behavior of the image. Defaults to lazy. Can hurt performance, recommended to use `priority` instead.
+ loading: The loading behavior of the image. Defaults to lazy. Can hurt performance, recommended to use `priority` instead.
blurDataURL: A Data URL to be used as a placeholder image before the src image successfully loads. Only takes effect when combined with placeholder="blur".
+ on_load: Fires when the image has loaded.
+ on_error: Fires when the image has an error.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/next/link.py b/reflex/components/next/link.py
index be32cd8e5..0f7c81296 100644
--- a/reflex/components/next/link.py
+++ b/reflex/components/next/link.py
@@ -1,7 +1,7 @@
"""A link component."""
from reflex.components.component import Component
-from reflex.vars import Var
+from reflex.vars.base import Var
class NextLink(Component):
diff --git a/reflex/components/next/link.pyi b/reflex/components/next/link.pyi
index 06d138176..fdccc9ee6 100644
--- a/reflex/components/next/link.pyi
+++ b/reflex/components/next/link.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class NextLink(Component):
@overload
@@ -23,52 +23,22 @@ class NextLink(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "NextLink":
"""Create the component.
diff --git a/reflex/components/next/video.py b/reflex/components/next/video.py
index ae6007671..435f4401f 100644
--- a/reflex/components/next/video.py
+++ b/reflex/components/next/video.py
@@ -3,7 +3,7 @@
from typing import Optional
from reflex.components.component import Component
-from reflex.vars import Var
+from reflex.vars.base import Var
from .base import NextComponent
diff --git a/reflex/components/next/video.pyi b/reflex/components/next/video.pyi
index eb28fab46..8f31748f7 100644
--- a/reflex/components/next/video.pyi
+++ b/reflex/components/next/video.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .base import NextComponent
@@ -25,52 +25,22 @@ class Video(NextComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Video":
"""Create a Video component.
diff --git a/reflex/components/plotly/plotly.py b/reflex/components/plotly/plotly.py
index a2393fdca..3bdef7875 100644
--- a/reflex/components/plotly/plotly.py
+++ b/reflex/components/plotly/plotly.py
@@ -2,14 +2,15 @@
from __future__ import annotations
-from typing import Any, Dict, List
+from typing import Any, Dict, List, Tuple, Union
+
+from typing_extensions import TypedDict, TypeVar
-from reflex.base import Base
from reflex.components.component import Component, NoSSRComponent
from reflex.components.core.cond import color_mode_cond
-from reflex.event import EventHandler
+from reflex.event import EventHandler, no_args_event_spec
from reflex.utils import console
-from reflex.vars import Var
+from reflex.vars.base import LiteralVar, Var
try:
from plotly.graph_objects import Figure, layout
@@ -21,19 +22,7 @@ except ImportError:
Template = Any # type: ignore
-def _event_data_signature(e0: Var) -> List[Any]:
- """For plotly events with event data and no points.
-
- Args:
- e0: The event data.
-
- Returns:
- The event key extracted from the event data (if defined).
- """
- return [Var.create_safe(f"{e0}?.event", _var_is_string=False)]
-
-
-def _event_points_data_signature(e0: Var) -> List[Any]:
+def _event_points_data_signature(e0: Var) -> Tuple[Var[List[Point]]]:
"""For plotly events with event data containing a point array.
Args:
@@ -42,54 +31,63 @@ def _event_points_data_signature(e0: Var) -> List[Any]:
Returns:
The event data and the extracted points.
"""
- return [
- Var.create_safe(f"{e0}?.event", _var_is_string=False),
- Var.create_safe(
- f"extractPoints({e0}?.points)",
- _var_is_string=False,
- ),
+ return (Var(_js_expr=f"extractPoints({e0}?.points)"),)
+
+
+T = TypeVar("T")
+
+ItemOrList = Union[T, List[T]]
+
+
+class BBox(TypedDict):
+ """Bounding box for a point in a plotly graph."""
+
+ x0: Union[float, int, None]
+ x1: Union[float, int, None]
+ y0: Union[float, int, None]
+ y1: Union[float, int, None]
+ z0: Union[float, int, None]
+ z1: Union[float, int, None]
+
+
+class Point(TypedDict):
+ """A point in a plotly graph."""
+
+ x: Union[float, int, None]
+ y: Union[float, int, None]
+ z: Union[float, int, None]
+ lat: Union[float, int, None]
+ lon: Union[float, int, None]
+ curveNumber: Union[int, None]
+ pointNumber: Union[int, None]
+ pointNumbers: Union[List[int], None]
+ pointIndex: Union[int, None]
+ markerColor: Union[
+ ItemOrList[
+ ItemOrList[
+ Union[
+ float,
+ int,
+ str,
+ None,
+ ]
+ ]
+ ],
+ None,
]
-
-
-class _ButtonClickData(Base):
- """Event data structure for plotly UI buttons."""
-
- menu: Any
- button: Any
- active: Any
-
-
-def _button_click_signature(e0: _ButtonClickData) -> List[Any]:
- """For plotly button click events.
-
- Args:
- e0: The button click data.
-
- Returns:
- The menu, button, and active state.
- """
- return [e0.menu, e0.button, e0.active]
-
-
-def _passthrough_signature(e0: Var) -> List[Any]:
- """For plotly events with arbitrary serializable data, passed through directly.
-
- Args:
- e0: The event data.
-
- Returns:
- The event data.
- """
- return [e0]
-
-
-def _null_signature() -> List[Any]:
- """For plotly events with no data or non-serializable data. Nothing passed through.
-
- Returns:
- An empty list (nothing passed through).
- """
- return []
+ markerSize: Union[
+ ItemOrList[
+ ItemOrList[
+ Union[
+ float,
+ int,
+ None,
+ ]
+ ]
+ ],
+ None,
+ ]
+ bbox: Union[BBox, None]
class Plotly(NoSSRComponent):
@@ -97,71 +95,71 @@ class Plotly(NoSSRComponent):
library = "react-plotly.js@2.6.0"
- lib_dependencies: List[str] = ["plotly.js@2.22.0"]
+ lib_dependencies: List[str] = ["plotly.js@2.35.2"]
tag = "Plot"
is_default = True
# The figure to display. This can be a plotly figure or a plotly data json.
- data: Var[Figure]
+ data: Var[Figure] # type: ignore
# The layout of the graph.
layout: Var[Dict]
# The template for visual appearance of the graph.
- template: Var[Template]
+ template: Var[Template] # type: ignore
# The config of the graph.
config: Var[Dict]
# If true, the graph will resize when the window is resized.
- use_resize_handler: Var[bool] = Var.create_safe(True)
+ use_resize_handler: Var[bool] = LiteralVar.create(True)
# Fired after the plot is redrawn.
- on_after_plot: EventHandler[_passthrough_signature]
+ on_after_plot: EventHandler[no_args_event_spec]
# Fired after the plot was animated.
- on_animated: EventHandler[_null_signature]
+ on_animated: EventHandler[no_args_event_spec]
# Fired while animating a single frame (does not currently pass data through).
- on_animating_frame: EventHandler[_null_signature]
+ on_animating_frame: EventHandler[no_args_event_spec]
# Fired when an animation is interrupted (to start a new animation for example).
- on_animation_interrupted: EventHandler[_null_signature]
+ on_animation_interrupted: EventHandler[no_args_event_spec]
# Fired when the plot is responsively sized.
- on_autosize: EventHandler[_event_data_signature]
+ on_autosize: EventHandler[no_args_event_spec]
# Fired whenever mouse moves over a plot.
- on_before_hover: EventHandler[_event_data_signature]
+ on_before_hover: EventHandler[no_args_event_spec]
# Fired when a plotly UI button is clicked.
- on_button_clicked: EventHandler[_button_click_signature]
+ on_button_clicked: EventHandler[no_args_event_spec]
# Fired when the plot is clicked.
on_click: EventHandler[_event_points_data_signature]
# Fired when a selection is cleared (via double click).
- on_deselect: EventHandler[_null_signature]
+ on_deselect: EventHandler[no_args_event_spec]
# Fired when the plot is double clicked.
- on_double_click: EventHandler[_passthrough_signature]
+ on_double_click: EventHandler[no_args_event_spec]
# Fired when a plot element is hovered over.
on_hover: EventHandler[_event_points_data_signature]
- # Fired after the plot is layed out (zoom, pan, etc).
- on_relayout: EventHandler[_passthrough_signature]
+ # Fired after the plot is laid out (zoom, pan, etc).
+ on_relayout: EventHandler[no_args_event_spec]
- # Fired while the plot is being layed out.
- on_relayouting: EventHandler[_passthrough_signature]
+ # Fired while the plot is being laid out.
+ on_relayouting: EventHandler[no_args_event_spec]
# Fired after the plot style is changed.
- on_restyle: EventHandler[_passthrough_signature]
+ on_restyle: EventHandler[no_args_event_spec]
# Fired after the plot is redrawn.
- on_redraw: EventHandler[_event_data_signature]
+ on_redraw: EventHandler[no_args_event_spec]
# Fired after selecting plot elements.
on_selected: EventHandler[_event_points_data_signature]
@@ -169,11 +167,11 @@ class Plotly(NoSSRComponent):
# Fired while dragging a selection.
on_selecting: EventHandler[_event_points_data_signature]
- # Fired while an animation is occuring.
- on_transitioning: EventHandler[_event_data_signature]
+ # Fired while an animation is occurring.
+ on_transitioning: EventHandler[no_args_event_spec]
# Fired when a transition is stopped early.
- on_transition_interrupted: EventHandler[_event_data_signature]
+ on_transition_interrupted: EventHandler[no_args_event_spec]
# Fired when a hovered element is no longer hovered.
on_unhover: EventHandler[_event_points_data_signature]
@@ -219,8 +217,8 @@ const extractPoints = (points) => {
pointNumber: point.pointNumber,
pointNumbers: point.pointNumbers,
pointIndex: point.pointIndex,
- 'marker.color': point['marker.color'],
- 'marker.size': point['marker.size'],
+ markerColor: point['marker.color'],
+ markerSize: point['marker.size'],
bbox: bbox,
})
})
@@ -242,8 +240,8 @@ const extractPoints = (points) => {
from plotly.io import templates
responsive_template = color_mode_cond(
- light=Var.create_safe(templates["plotly"]).to(dict),
- dark=Var.create_safe(templates["plotly_dark"]).to(dict),
+ light=LiteralVar.create(templates["plotly"]),
+ dark=LiteralVar.create(templates["plotly_dark"]),
)
if isinstance(responsive_template, Var):
# Mark the conditional Var as a Template to avoid type mismatch
@@ -257,36 +255,26 @@ const extractPoints = (points) => {
def _render(self):
tag = super()._render()
- figure = self.data.to(dict)
+ figure = self.data.to(dict) if self.data is not None else Var.create({})
merge_dicts = [] # Data will be merged and spread from these dict Vars
if self.layout is not None:
# Why is this not a literal dict? Great question... it didn't work
# reliably because of how _var_name_unwrapped strips the outer curly
# brackets if any of the contained Vars depend on state.
- layout_dict = Var.create_safe(
- f"{{'layout': {self.layout.to(dict)._var_name_unwrapped}}}"
- ).to(dict)
+ layout_dict = LiteralVar.create({"layout": self.layout})
merge_dicts.append(layout_dict)
if self.template is not None:
- template_dict = Var.create_safe(
- {"layout": {"template": self.template.to(dict)}}
- )
- template_dict._var_data = None # To avoid stripping outer curly brackets
- merge_dicts.append(template_dict)
+ template_dict = LiteralVar.create({"layout": {"template": self.template}})
+ merge_dicts.append(template_dict._without_data())
if merge_dicts:
- tag.special_props.add(
+ tag.special_props.append(
# Merge all dictionaries and spread the result over props.
- Var.create_safe(
- f"{{...mergician({figure._var_name_unwrapped},"
- f"{','.join(md._var_name_unwrapped for md in merge_dicts)})}}",
- _var_is_string=False,
+ Var(
+ _js_expr=f"{{...mergician({figure!s},"
+ f"{','.join(str(md) for md in merge_dicts)})}}",
),
)
else:
# Spread the figure dict over props, nothing to merge.
- tag.special_props.add(
- Var.create_safe(
- f"{{...{figure._var_name_unwrapped}}}", _var_is_string=False
- )
- )
+ tag.special_props.append(Var(_js_expr=f"{{...{figure!s}}}"))
return tag
diff --git a/reflex/components/plotly/plotly.pyi b/reflex/components/plotly/plotly.pyi
index 219f113bc..ca1ddef39 100644
--- a/reflex/components/plotly/plotly.pyi
+++ b/reflex/components/plotly/plotly.pyi
@@ -3,14 +3,15 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, List, Optional, Union, overload
+
+from typing_extensions import TypedDict, TypeVar
-from reflex.base import Base
from reflex.components.component import NoSSRComponent
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
from reflex.utils import console
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
try:
from plotly.graph_objects import Figure, layout
@@ -20,11 +21,30 @@ except ImportError:
console.warn("Plotly is not installed. Please run `pip install plotly`.")
Figure = Any
Template = Any
+T = TypeVar("T")
+ItemOrList = Union[T, List[T]]
-class _ButtonClickData(Base):
- menu: Any
- button: Any
- active: Any
+class BBox(TypedDict):
+ x0: Union[float, int, None]
+ x1: Union[float, int, None]
+ y0: Union[float, int, None]
+ y1: Union[float, int, None]
+ z0: Union[float, int, None]
+ z1: Union[float, int, None]
+
+class Point(TypedDict):
+ x: Union[float, int, None]
+ y: Union[float, int, None]
+ z: Union[float, int, None]
+ lat: Union[float, int, None]
+ lon: Union[float, int, None]
+ curveNumber: Union[int, None]
+ pointNumber: Union[int, None]
+ pointNumbers: Union[List[int], None]
+ pointIndex: Union[int, None]
+ markerColor: Union[ItemOrList[ItemOrList[Union[float, int, str, None]]], None]
+ markerSize: Union[ItemOrList[ItemOrList[Union[float, int, None]]], None]
+ bbox: Union[BBox, None]
class Plotly(NoSSRComponent):
def add_imports(self) -> dict[str, str]: ...
@@ -34,116 +54,60 @@ class Plotly(NoSSRComponent):
def create( # type: ignore
cls,
*children,
- data: Optional[Union[Var[Figure], Figure]] = None, # type: ignore
- layout: Optional[Union[Var[Dict], Dict]] = None,
- template: Optional[Union[Var[Template], Template]] = None, # type: ignore
- config: Optional[Union[Var[Dict], Dict]] = None,
+ data: Optional[Union[Figure, Var[Figure]]] = None, # type: ignore
+ layout: Optional[Union[Dict, Var[Dict]]] = None,
+ template: Optional[Union[Template, Var[Template]]] = None, # type: ignore
+ config: Optional[Union[Dict, Var[Dict]]] = None,
use_resize_handler: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_after_plot: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_animated: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_animating_frame: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_animation_interrupted: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_autosize: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_before_hover: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_button_clicked: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_after_plot: Optional[EventType[[], BASE_STATE]] = None,
+ on_animated: Optional[EventType[[], BASE_STATE]] = None,
+ on_animating_frame: Optional[EventType[[], BASE_STATE]] = None,
+ on_animation_interrupted: Optional[EventType[[], BASE_STATE]] = None,
+ on_autosize: Optional[EventType[[], BASE_STATE]] = None,
+ on_before_hover: Optional[EventType[[], BASE_STATE]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_button_clicked: Optional[EventType[[], BASE_STATE]] = None,
on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_deselect: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[List[Point]], BASE_STATE]]
] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_deselect: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
on_hover: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_redraw: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_relayout: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_relayouting: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_restyle: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[List[Point]], BASE_STATE]]
] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_redraw: Optional[EventType[[], BASE_STATE]] = None,
+ on_relayout: Optional[EventType[[], BASE_STATE]] = None,
+ on_relayouting: Optional[EventType[[], BASE_STATE]] = None,
+ on_restyle: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
on_selected: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[List[Point]], BASE_STATE]]
] = None,
on_selecting: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_transition_interrupted: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_transitioning: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[List[Point]], BASE_STATE]]
] = None,
+ on_transition_interrupted: Optional[EventType[[], BASE_STATE]] = None,
+ on_transitioning: Optional[EventType[[], BASE_STATE]] = None,
on_unhover: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[List[Point]], BASE_STATE]]
] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Plotly":
"""Create the Plotly component.
@@ -155,6 +119,26 @@ class Plotly(NoSSRComponent):
template: The template for visual appearance of the graph.
config: The config of the graph.
use_resize_handler: If true, the graph will resize when the window is resized.
+ on_after_plot: Fired after the plot is redrawn.
+ on_animated: Fired after the plot was animated.
+ on_animating_frame: Fired while animating a single frame (does not currently pass data through).
+ on_animation_interrupted: Fired when an animation is interrupted (to start a new animation for example).
+ on_autosize: Fired when the plot is responsively sized.
+ on_before_hover: Fired whenever mouse moves over a plot.
+ on_button_clicked: Fired when a plotly UI button is clicked.
+ on_click: Fired when the plot is clicked.
+ on_deselect: Fired when a selection is cleared (via double click).
+ on_double_click: Fired when the plot is double clicked.
+ on_hover: Fired when a plot element is hovered over.
+ on_relayout: Fired after the plot is laid out (zoom, pan, etc).
+ on_relayouting: Fired while the plot is being laid out.
+ on_restyle: Fired after the plot style is changed.
+ on_redraw: Fired after the plot is redrawn.
+ on_selected: Fired after selecting plot elements.
+ on_selecting: Fired while dragging a selection.
+ on_transitioning: Fired while an animation is occurring.
+ on_transition_interrupted: Fired when a transition is stopped early.
+ on_unhover: Fired when a hovered element is no longer hovered.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/props.py b/reflex/components/props.py
index a66ba7f2f..adce134fc 100644
--- a/reflex/components/props.py
+++ b/reflex/components/props.py
@@ -2,9 +2,12 @@
from __future__ import annotations
+from pydantic import ValidationError
+
from reflex.base import Base
from reflex.utils import format
-from reflex.utils.serializers import serialize
+from reflex.utils.exceptions import InvalidPropValueError
+from reflex.vars.object import LiteralObjectVar
class PropsBase(Base):
@@ -20,12 +23,54 @@ class PropsBase(Base):
Returns:
The object as a Javascript Object literal.
"""
- return format.unwrap_vars(
- self.__config__.json_dumps(
- {
- format.to_camel_case(key): value
- for key, value in self.dict().items()
- },
- default=serialize,
- )
- )
+ return LiteralObjectVar.create(
+ {format.to_camel_case(key): value for key, value in self.dict().items()}
+ ).json()
+
+ def dict(self, *args, **kwargs):
+ """Convert the object to a dictionary.
+
+ Keys will be converted to camelCase.
+
+ Args:
+ *args: Arguments to pass to the parent class.
+ **kwargs: Keyword arguments to pass to the parent class.
+
+ Returns:
+ The object as a dictionary.
+ """
+ return {
+ format.to_camel_case(key): value
+ for key, value in super().dict(*args, **kwargs).items()
+ }
+
+
+class NoExtrasAllowedProps(Base):
+ """A class that holds props to be passed or applied to a component with no extra props allowed."""
+
+ def __init__(self, component_name=None, **kwargs):
+ """Initialize the props.
+
+ Args:
+ component_name: The custom name of the component.
+ kwargs: Kwargs to initialize the props.
+
+ Raises:
+ InvalidPropValueError: If invalid props are passed on instantiation.
+ """
+ component_name = component_name or type(self).__name__
+ try:
+ super().__init__(**kwargs)
+ except ValidationError as e:
+ invalid_fields = ", ".join([error["loc"][0] for error in e.errors()]) # type: ignore
+ supported_props_str = ", ".join(f'"{field}"' for field in self.get_fields())
+ raise InvalidPropValueError(
+ f"Invalid prop(s) {invalid_fields} for {component_name!r}. Supported props are {supported_props_str}"
+ ) from None
+
+ class Config:
+ """Pydantic config."""
+
+ arbitrary_types_allowed = True
+ use_enum_values = True
+ extra = "forbid"
diff --git a/reflex/components/radix/__init__.pyi b/reflex/components/radix/__init__.pyi
index b61659320..f4e81666a 100644
--- a/reflex/components/radix/__init__.pyi
+++ b/reflex/components/radix/__init__.pyi
@@ -8,7 +8,6 @@ from . import themes as themes
from .primitives.accordion import accordion as accordion
from .primitives.drawer import drawer as drawer
from .primitives.form import form as form
-from .primitives.progress import progress as progress
from .themes.base import theme as theme
from .themes.base import theme_panel as theme_panel
from .themes.color_mode import color_mode as color_mode
@@ -31,6 +30,7 @@ from .themes.components.hover_card import hover_card as hover_card
from .themes.components.icon_button import icon_button as icon_button
from .themes.components.inset import inset as inset
from .themes.components.popover import popover as popover
+from .themes.components.progress import progress as progress
from .themes.components.radio_cards import radio_cards as radio_cards
from .themes.components.radio_group import radio as radio
from .themes.components.radio_group import radio_group as radio_group
@@ -55,6 +55,7 @@ from .themes.layout.container import container as container
from .themes.layout.flex import flex as flex
from .themes.layout.grid import grid as grid
from .themes.layout.list import list_item as list_item
+from .themes.layout.list import list_ns as list # noqa
from .themes.layout.list import ordered_list as ordered_list
from .themes.layout.list import unordered_list as unordered_list
from .themes.layout.section import section as section
diff --git a/reflex/components/radix/primitives/accordion.py b/reflex/components/radix/primitives/accordion.py
index b93bbf284..0ba618e21 100644
--- a/reflex/components/radix/primitives/accordion.py
+++ b/reflex/components/radix/primitives/accordion.py
@@ -2,7 +2,7 @@
from __future__ import annotations
-from typing import Any, List, Literal, Optional, Union
+from typing import Any, List, Literal, Tuple, Union
from reflex.components.component import Component, ComponentNamespace
from reflex.components.core.colors import color
@@ -12,7 +12,8 @@ from reflex.components.radix.primitives.base import RadixPrimitiveComponent
from reflex.components.radix.themes.base import LiteralAccentColor, LiteralRadius
from reflex.event import EventHandler
from reflex.style import Style
-from reflex.vars import Var, get_uuid_string_var
+from reflex.vars import get_uuid_string_var
+from reflex.vars.base import LiteralVar, Var
LiteralAccordionType = Literal["single", "multiple"]
LiteralAccordionDir = Literal["ltr", "rtl"]
@@ -70,6 +71,18 @@ class AccordionComponent(RadixPrimitiveComponent):
return ["color_scheme", "variant"]
+def on_value_change(value: Var[str | List[str]]) -> Tuple[Var[str | List[str]]]:
+ """Handle the on_value_change event.
+
+ Args:
+ value: The value of the event.
+
+ Returns:
+ The value of the event.
+ """
+ return (value,)
+
+
class AccordionRoot(AccordionComponent):
"""An accordion component."""
@@ -102,10 +115,10 @@ class AccordionRoot(AccordionComponent):
radius: Var[LiteralRadius]
# The time in milliseconds to animate open and close
- duration: Var[int] = Var.create_safe(DEFAULT_ANIMATION_DURATION)
+ duration: Var[int] = LiteralVar.create(DEFAULT_ANIMATION_DURATION)
# The easing function to use for the animation.
- easing: Var[str] = Var.create_safe(DEFAULT_ANIMATION_EASING, _var_is_string=True)
+ easing: Var[str] = LiteralVar.create(DEFAULT_ANIMATION_EASING)
# Whether to show divider lines between items.
show_dividers: Var[bool]
@@ -113,10 +126,11 @@ class AccordionRoot(AccordionComponent):
_valid_children: List[str] = ["AccordionItem"]
# Fired when the opened the accordions changes.
- on_value_change: EventHandler[lambda e0: [e0]]
+ on_value_change: EventHandler[on_value_change]
def _exclude_props(self) -> list[str]:
- return super()._exclude_props() + [
+ return [
+ *super()._exclude_props(),
"radius",
"duration",
"easing",
@@ -180,6 +194,11 @@ class AccordionItem(AccordionComponent):
# When true, prevents the user from interacting with the item.
disabled: Var[bool]
+ # The header of the accordion item.
+ header: Var[Union[Component, str]]
+ # The content of the accordion item.
+ content: Var[Union[Component, str]] = Var.create(None)
+
_valid_children: List[str] = [
"AccordionHeader",
"AccordionTrigger",
@@ -192,21 +211,20 @@ class AccordionItem(AccordionComponent):
def create(
cls,
*children,
- header: Optional[Component | Var] = None,
- content: Optional[Component | Var] = None,
**props,
) -> Component:
"""Create an accordion item.
Args:
*children: The list of children to use if header and content are not provided.
- header: The header of the accordion item.
- content: The content of the accordion item.
**props: Additional properties to apply to the accordion item.
Returns:
The accordion item.
"""
+ header = props.pop("header", None)
+ content = props.pop("content", None)
+
# The item requires a value to toggle (use a random unique name if not provided).
value = props.pop("value", get_uuid_string_var())
@@ -278,6 +296,9 @@ class AccordionItem(AccordionComponent):
},
}
+ def _exclude_props(self) -> list[str]:
+ return ["header", "content"]
+
class AccordionHeader(AccordionComponent):
"""An accordion component."""
@@ -362,7 +383,7 @@ class AccordionTrigger(AccordionComponent):
"background_color": color("accent", 4),
},
"& > .AccordionChevron": {
- "transition": f"transform var(--animation-duration) var(--animation-easing)",
+ "transition": "transform var(--animation-duration) var(--animation-easing)",
},
_inherited_variant_selector("classic"): {
"color": "var(--accent-contrast)",
@@ -464,14 +485,12 @@ to {
Returns:
The style of the component.
"""
- slideDown = Var.create(
- f"${{slideDown}} var(--animation-duration) var(--animation-easing)",
- _var_is_string=True,
+ slideDown = LiteralVar.create(
+ "${slideDown} var(--animation-duration) var(--animation-easing)",
)
- slideUp = Var.create(
- f"${{slideUp}} var(--animation-duration) var(--animation-easing)",
- _var_is_string=True,
+ slideUp = LiteralVar.create(
+ "${slideUp} var(--animation-duration) var(--animation-easing)",
)
return {
diff --git a/reflex/components/radix/primitives/accordion.pyi b/reflex/components/radix/primitives/accordion.pyi
index 7cc1059ab..03208f496 100644
--- a/reflex/components/radix/primitives/accordion.pyi
+++ b/reflex/components/radix/primitives/accordion.pyi
@@ -3,14 +3,14 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload
from reflex.components.component import Component, ComponentNamespace
from reflex.components.lucide.icon import Icon
from reflex.components.radix.primitives.base import RadixPrimitiveComponent
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
LiteralAccordionType = Literal["single", "multiple"]
LiteralAccordionDir = Literal["ltr", "rtl"]
@@ -28,70 +28,70 @@ class AccordionComponent(RadixPrimitiveComponent):
*children,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "soft", "surface", "outline", "ghost"]],
- Literal["classic", "soft", "surface", "outline", "ghost"],
+ Literal["classic", "ghost", "outline", "soft", "surface"],
+ Var[Literal["classic", "ghost", "outline", "soft", "surface"]],
]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
@@ -100,52 +100,22 @@ class AccordionComponent(RadixPrimitiveComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AccordionComponent":
"""Create the component.
@@ -168,6 +138,8 @@ class AccordionComponent(RadixPrimitiveComponent):
"""
...
+def on_value_change(value: Var[str | List[str]]) -> Tuple[Var[str | List[str]]]: ...
+
class AccordionRoot(AccordionComponent):
def add_style(self): ...
@overload
@@ -176,25 +148,25 @@ class AccordionRoot(AccordionComponent):
cls,
*children,
type: Optional[
- Union[Var[Literal["single", "multiple"]], Literal["single", "multiple"]]
+ Union[Literal["multiple", "single"], Var[Literal["multiple", "single"]]]
] = None,
- value: Optional[Union[Var[Union[List[str], str]], str, List[str]]] = None,
+ value: Optional[Union[List[str], Var[Union[List[str], str]], str]] = None,
default_value: Optional[
- Union[Var[Union[List[str], str]], str, List[str]]
+ Union[List[str], Var[Union[List[str], str]], str]
] = None,
collapsible: Optional[Union[Var[bool], bool]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
- dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None,
+ dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None,
orientation: Optional[
Union[
- Var[Literal["vertical", "horizontal"]],
- Literal["vertical", "horizontal"],
+ Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
duration: Optional[Union[Var[int], int]] = None,
@@ -202,70 +174,70 @@ class AccordionRoot(AccordionComponent):
show_dividers: Optional[Union[Var[bool], bool]] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "soft", "surface", "outline", "ghost"]],
- Literal["classic", "soft", "surface", "outline", "ghost"],
+ Literal["classic", "ghost", "outline", "soft", "surface"],
+ Var[Literal["classic", "ghost", "outline", "soft", "surface"]],
]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
@@ -274,54 +246,24 @@ class AccordionRoot(AccordionComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
on_value_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str | List[str]], BASE_STATE]]
] = None,
**props,
) -> "AccordionRoot":
@@ -340,6 +282,7 @@ class AccordionRoot(AccordionComponent):
duration: The time in milliseconds to animate open and close
easing: The easing function to use for the animation.
show_dividers: Whether to show divider lines between items.
+ on_value_change: Fired when the opened the accordions changes.
color_scheme: The color scheme of the component.
variant: The variant of the component.
as_child: Change the default rendered element for the one passed as a child.
@@ -362,76 +305,76 @@ class AccordionItem(AccordionComponent):
def create( # type: ignore
cls,
*children,
- header: Optional[Union[Component, Var]] = None,
- content: Optional[Union[Component, Var]] = None,
value: Optional[Union[Var[str], str]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
+ header: Optional[Union[Component, Var[Union[Component, str]], str]] = None,
+ content: Optional[Union[Component, Var[Union[Component, str]], str]] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "soft", "surface", "outline", "ghost"]],
- Literal["classic", "soft", "surface", "outline", "ghost"],
+ Literal["classic", "ghost", "outline", "soft", "surface"],
+ Var[Literal["classic", "ghost", "outline", "soft", "surface"]],
]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
@@ -440,62 +383,32 @@ class AccordionItem(AccordionComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AccordionItem":
"""Create an accordion item.
Args:
*children: The list of children to use if header and content are not provided.
- header: The header of the accordion item.
- content: The content of the accordion item.
value: A unique identifier for the item.
disabled: When true, prevents the user from interacting with the item.
+ header: The header of the accordion item.
+ content: The content of the accordion item.
color_scheme: The color scheme of the component.
variant: The variant of the component.
as_child: Change the default rendered element for the one passed as a child.
@@ -522,70 +435,70 @@ class AccordionHeader(AccordionComponent):
*children,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "soft", "surface", "outline", "ghost"]],
- Literal["classic", "soft", "surface", "outline", "ghost"],
+ Literal["classic", "ghost", "outline", "soft", "surface"],
+ Var[Literal["classic", "ghost", "outline", "soft", "surface"]],
]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
@@ -594,52 +507,22 @@ class AccordionHeader(AccordionComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AccordionHeader":
"""Create the Accordion header component.
@@ -672,70 +555,70 @@ class AccordionTrigger(AccordionComponent):
*children,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "soft", "surface", "outline", "ghost"]],
- Literal["classic", "soft", "surface", "outline", "ghost"],
+ Literal["classic", "ghost", "outline", "soft", "surface"],
+ Var[Literal["classic", "ghost", "outline", "soft", "surface"]],
]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
@@ -744,52 +627,22 @@ class AccordionTrigger(AccordionComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AccordionTrigger":
"""Create the Accordion trigger component.
@@ -826,52 +679,22 @@ class AccordionIcon(Icon):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AccordionIcon":
"""Create the Accordion icon component.
@@ -901,70 +724,70 @@ class AccordionContent(AccordionComponent):
*children,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "soft", "surface", "outline", "ghost"]],
- Literal["classic", "soft", "surface", "outline", "ghost"],
+ Literal["classic", "ghost", "outline", "soft", "surface"],
+ Var[Literal["classic", "ghost", "outline", "soft", "surface"]],
]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
@@ -973,52 +796,22 @@ class AccordionContent(AccordionComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AccordionContent":
"""Create the Accordion content component.
diff --git a/reflex/components/radix/primitives/base.py b/reflex/components/radix/primitives/base.py
index 857e80b5a..479cd2912 100644
--- a/reflex/components/radix/primitives/base.py
+++ b/reflex/components/radix/primitives/base.py
@@ -5,7 +5,7 @@ from typing import List
from reflex.components.component import Component
from reflex.components.tags.tag import Tag
from reflex.utils import format
-from reflex.vars import Var
+from reflex.vars.base import Var
class RadixPrimitiveComponent(Component):
diff --git a/reflex/components/radix/primitives/base.pyi b/reflex/components/radix/primitives/base.pyi
index 0ddea6cb5..42847f160 100644
--- a/reflex/components/radix/primitives/base.pyi
+++ b/reflex/components/radix/primitives/base.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
from reflex.components.component import Component
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class RadixPrimitiveComponent(Component):
@overload
@@ -22,52 +22,22 @@ class RadixPrimitiveComponent(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "RadixPrimitiveComponent":
"""Create the component.
@@ -100,52 +70,22 @@ class RadixPrimitiveComponentWithClassName(RadixPrimitiveComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "RadixPrimitiveComponentWithClassName":
"""Create the component.
diff --git a/reflex/components/radix/primitives/drawer.py b/reflex/components/radix/primitives/drawer.py
index 1c8a91837..ed57dcbd8 100644
--- a/reflex/components/radix/primitives/drawer.py
+++ b/reflex/components/radix/primitives/drawer.py
@@ -10,8 +10,8 @@ from reflex.components.component import Component, ComponentNamespace
from reflex.components.radix.primitives.base import RadixPrimitiveComponent
from reflex.components.radix.themes.base import Theme
from reflex.components.radix.themes.layout.flex import Flex
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec
+from reflex.vars.base import Var
class DrawerComponent(RadixPrimitiveComponent):
@@ -32,14 +32,29 @@ class DrawerRoot(DrawerComponent):
alias = "Vaul" + tag
+ # The open state of the drawer when it is initially rendered. Use when you do not need to control its open state.
+ default_open: Var[bool]
+
# Whether the drawer is open or not.
open: Var[bool]
- # Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background.
- should_scale_background: Var[bool]
+ # Fires when the drawer is opened or closed.
+ on_open_change: EventHandler[passthrough_event_spec(bool)]
- # Number between 0 and 1 that determines when the drawer should be closed.
- close_threshold: Var[float]
+ # When `False`, it allows interaction with elements outside of the drawer without closing it. Defaults to `True`.
+ modal: Var[bool]
+
+ # Direction of the drawer. This adjusts the animations and the drag direction. Defaults to `"bottom"`
+ direction: Var[LiteralDirectionType]
+
+ # Gets triggered after the open or close animation ends, it receives an open argument with the open state of the drawer by the time the function was triggered.
+ on_animation_end: EventHandler[passthrough_event_spec(bool)]
+
+ # When `False`, dragging, clicking outside, pressing esc, etc. will not close the drawer. Use this in combination with the open prop, otherwise you won't be able to open/close the drawer.
+ dismissible: Var[bool]
+
+ # When `True`, dragging will only be possible by the handle.
+ handle_only: Var[bool]
# Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account.
snap_points: Optional[List[Union[str, float]]]
@@ -50,17 +65,14 @@ class DrawerRoot(DrawerComponent):
# Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms
scroll_lock_timeout: Var[int]
- # When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`.
- modal: Var[bool]
-
- # Direction of the drawer. Defaults to `"bottom"`
- direction: Var[LiteralDirectionType]
-
# When `True`, it prevents scroll restoration. Defaults to `True`.
preventScrollRestoration: Var[bool]
- # Fires when the drawer is opened.
- on_open_change: EventHandler[lambda e0: [e0]]
+ # Enable background scaling, it requires container element with `vaul-drawer-wrapper` attribute to scale its background.
+ should_scale_background: Var[bool]
+
+ # Number between 0 and 1 that determines when the drawer should be closed.
+ close_threshold: Var[float]
class DrawerTrigger(DrawerComponent):
@@ -78,8 +90,8 @@ class DrawerTrigger(DrawerComponent):
"""Create a new DrawerTrigger instance.
Args:
- children: The children of the element.
- props: The properties of the element.
+ *children: The children of the element.
+ **props: The properties of the element.
Returns:
The new DrawerTrigger instance.
@@ -128,19 +140,19 @@ class DrawerContent(DrawerComponent):
return {"css": base_style}
# Fired when the drawer content is opened.
- on_open_auto_focus: EventHandler[lambda e0: [e0.target.value]]
+ on_open_auto_focus: EventHandler[no_args_event_spec]
# Fired when the drawer content is closed.
- on_close_auto_focus: EventHandler[lambda e0: [e0.target.value]]
+ on_close_auto_focus: EventHandler[no_args_event_spec]
# Fired when the escape key is pressed.
- on_escape_key_down: EventHandler[lambda e0: [e0.target.value]]
+ on_escape_key_down: EventHandler[no_args_event_spec]
# Fired when the pointer is down outside the drawer content.
- on_pointer_down_outside: EventHandler[lambda e0: [e0.target.value]]
+ on_pointer_down_outside: EventHandler[no_args_event_spec]
# Fired when interacting outside the drawer content.
- on_interact_outside: EventHandler[lambda e0: [e0.target.value]]
+ on_interact_outside: EventHandler[no_args_event_spec]
@classmethod
def create(cls, *children, **props):
@@ -245,6 +257,14 @@ class DrawerDescription(DrawerComponent):
return {"css": base_style}
+class DrawerHandle(DrawerComponent):
+ """A description for the drawer."""
+
+ tag = "Drawer.Handle"
+
+ alias = "Vaul" + tag
+
+
class Drawer(ComponentNamespace):
"""A namespace for Drawer components."""
@@ -256,6 +276,7 @@ class Drawer(ComponentNamespace):
close = staticmethod(DrawerClose.create)
title = staticmethod(DrawerTitle.create)
description = staticmethod(DrawerDescription.create)
+ handle = staticmethod(DrawerHandle.create)
drawer = Drawer()
diff --git a/reflex/components/radix/primitives/drawer.pyi b/reflex/components/radix/primitives/drawer.pyi
index dcbebfa15..1ca1e4325 100644
--- a/reflex/components/radix/primitives/drawer.pyi
+++ b/reflex/components/radix/primitives/drawer.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.radix.primitives.base import RadixPrimitiveComponent
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class DrawerComponent(RadixPrimitiveComponent):
@overload
@@ -23,52 +23,22 @@ class DrawerComponent(RadixPrimitiveComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DrawerComponent":
"""Create the component.
@@ -97,90 +67,71 @@ class DrawerRoot(DrawerComponent):
def create( # type: ignore
cls,
*children,
+ default_open: Optional[Union[Var[bool], bool]] = None,
open: Optional[Union[Var[bool], bool]] = None,
- should_scale_background: Optional[Union[Var[bool], bool]] = None,
- close_threshold: Optional[Union[Var[float], float]] = None,
- snap_points: Optional[List[Union[float, str]]] = None,
- fade_from_index: Optional[Union[Var[int], int]] = None,
- scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
modal: Optional[Union[Var[bool], bool]] = None,
direction: Optional[
Union[
- Var[Literal["top", "bottom", "left", "right"]],
- Literal["top", "bottom", "left", "right"],
+ Literal["bottom", "left", "right", "top"],
+ Var[Literal["bottom", "left", "right", "top"]],
]
] = None,
+ dismissible: Optional[Union[Var[bool], bool]] = None,
+ handle_only: Optional[Union[Var[bool], bool]] = None,
+ snap_points: Optional[List[Union[float, str]]] = None,
+ fade_from_index: Optional[Union[Var[int], int]] = None,
+ scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
preventScrollRestoration: Optional[Union[Var[bool], bool]] = None,
+ should_scale_background: Optional[Union[Var[bool], bool]] = None,
+ close_threshold: Optional[Union[Var[float], float]] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_animation_end: Optional[
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DrawerRoot":
"""Create the component.
Args:
*children: The children of the component.
+ default_open: The open state of the drawer when it is initially rendered. Use when you do not need to control its open state.
open: Whether the drawer is open or not.
- should_scale_background: Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background.
- close_threshold: Number between 0 and 1 that determines when the drawer should be closed.
+ on_open_change: Fires when the drawer is opened or closed.
+ modal: When `False`, it allows interaction with elements outside of the drawer without closing it. Defaults to `True`.
+ direction: Direction of the drawer. This adjusts the animations and the drag direction. Defaults to `"bottom"`
+ on_animation_end: Gets triggered after the open or close animation ends, it receives an open argument with the open state of the drawer by the time the function was triggered.
+ dismissible: When `False`, dragging, clicking outside, pressing esc, etc. will not close the drawer. Use this in combination with the open prop, otherwise you won't be able to open/close the drawer.
+ handle_only: When `True`, dragging will only be possible by the handle.
snap_points: Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account.
fade_from_index: Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point.
scroll_lock_timeout: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms
- modal: When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`.
- direction: Direction of the drawer. Defaults to `"bottom"`
preventScrollRestoration: When `True`, it prevents scroll restoration. Defaults to `True`.
+ should_scale_background: Enable background scaling, it requires container element with `vaul-drawer-wrapper` attribute to scale its background.
+ close_threshold: Number between 0 and 1 that determines when the drawer should be closed.
as_child: Change the default rendered element for the one passed as a child.
style: The style of the component.
key: A unique key for the component.
@@ -207,59 +158,36 @@ class DrawerTrigger(DrawerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DrawerTrigger":
"""Create a new DrawerTrigger instance.
Args:
- children: The children of the element.
- props: The properties of the element.
+ *children: The children of the element.
+ as_child: Change the default rendered element for the one passed as a child.
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: The properties of the element.
Returns:
The new DrawerTrigger instance.
@@ -278,52 +206,22 @@ class DrawerPortal(DrawerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DrawerPortal":
"""Create the component.
@@ -356,67 +254,27 @@ class DrawerContent(DrawerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close_auto_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_escape_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_interact_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_open_auto_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_pointer_down_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_interact_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_open_auto_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DrawerContent":
"""Create a Drawer Content.
@@ -453,52 +311,22 @@ class DrawerOverlay(DrawerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DrawerOverlay":
"""Create the component.
@@ -531,59 +359,36 @@ class DrawerClose(DrawerTrigger):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DrawerClose":
"""Create a new DrawerTrigger instance.
Args:
- children: The children of the element.
- props: The properties of the element.
+ *children: The children of the element.
+ as_child: Change the default rendered element for the one passed as a child.
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: The properties of the element.
Returns:
The new DrawerTrigger instance.
@@ -602,52 +407,22 @@ class DrawerTitle(DrawerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DrawerTitle":
"""Create the component.
@@ -680,52 +455,22 @@ class DrawerDescription(DrawerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DrawerDescription":
"""Create the component.
@@ -746,6 +491,54 @@ class DrawerDescription(DrawerComponent):
"""
...
+class DrawerHandle(DrawerComponent):
+ @overload
+ @classmethod
+ def create( # type: ignore
+ cls,
+ *children,
+ as_child: Optional[Union[Var[bool], bool]] = None,
+ style: Optional[Style] = None,
+ key: Optional[Any] = None,
+ id: Optional[Any] = None,
+ class_name: Optional[Any] = None,
+ autofocus: Optional[bool] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
+ **props,
+ ) -> "DrawerHandle":
+ """Create the component.
+
+ Args:
+ *children: The children of the component.
+ as_child: Change the default rendered element for the one passed as a child.
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: The props of the component.
+
+ Returns:
+ The component.
+ """
+ ...
+
class Drawer(ComponentNamespace):
root = staticmethod(DrawerRoot.create)
trigger = staticmethod(DrawerTrigger.create)
@@ -755,94 +548,76 @@ class Drawer(ComponentNamespace):
close = staticmethod(DrawerClose.create)
title = staticmethod(DrawerTitle.create)
description = staticmethod(DrawerDescription.create)
+ handle = staticmethod(DrawerHandle.create)
@staticmethod
def __call__(
*children,
+ default_open: Optional[Union[Var[bool], bool]] = None,
open: Optional[Union[Var[bool], bool]] = None,
- should_scale_background: Optional[Union[Var[bool], bool]] = None,
- close_threshold: Optional[Union[Var[float], float]] = None,
- snap_points: Optional[List[Union[float, str]]] = None,
- fade_from_index: Optional[Union[Var[int], int]] = None,
- scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
modal: Optional[Union[Var[bool], bool]] = None,
direction: Optional[
Union[
- Var[Literal["top", "bottom", "left", "right"]],
- Literal["top", "bottom", "left", "right"],
+ Literal["bottom", "left", "right", "top"],
+ Var[Literal["bottom", "left", "right", "top"]],
]
] = None,
+ dismissible: Optional[Union[Var[bool], bool]] = None,
+ handle_only: Optional[Union[Var[bool], bool]] = None,
+ snap_points: Optional[List[Union[float, str]]] = None,
+ fade_from_index: Optional[Union[Var[int], int]] = None,
+ scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
preventScrollRestoration: Optional[Union[Var[bool], bool]] = None,
+ should_scale_background: Optional[Union[Var[bool], bool]] = None,
+ close_threshold: Optional[Union[Var[float], float]] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_animation_end: Optional[
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DrawerRoot":
"""Create the component.
Args:
*children: The children of the component.
+ default_open: The open state of the drawer when it is initially rendered. Use when you do not need to control its open state.
open: Whether the drawer is open or not.
- should_scale_background: Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background.
- close_threshold: Number between 0 and 1 that determines when the drawer should be closed.
+ on_open_change: Fires when the drawer is opened or closed.
+ modal: When `False`, it allows interaction with elements outside of the drawer without closing it. Defaults to `True`.
+ direction: Direction of the drawer. This adjusts the animations and the drag direction. Defaults to `"bottom"`
+ on_animation_end: Gets triggered after the open or close animation ends, it receives an open argument with the open state of the drawer by the time the function was triggered.
+ dismissible: When `False`, dragging, clicking outside, pressing esc, etc. will not close the drawer. Use this in combination with the open prop, otherwise you won't be able to open/close the drawer.
+ handle_only: When `True`, dragging will only be possible by the handle.
snap_points: Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account.
fade_from_index: Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point.
scroll_lock_timeout: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms
- modal: When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`.
- direction: Direction of the drawer. Defaults to `"bottom"`
preventScrollRestoration: When `True`, it prevents scroll restoration. Defaults to `True`.
+ should_scale_background: Enable background scaling, it requires container element with `vaul-drawer-wrapper` attribute to scale its background.
+ close_threshold: Number between 0 and 1 that determines when the drawer should be closed.
as_child: Change the default rendered element for the one passed as a child.
style: The style of the component.
key: A unique key for the component.
diff --git a/reflex/components/radix/primitives/form.py b/reflex/components/radix/primitives/form.py
index 3b871d0af..f2b8201ad 100644
--- a/reflex/components/radix/primitives/form.py
+++ b/reflex/components/radix/primitives/form.py
@@ -8,8 +8,8 @@ from reflex.components.component import ComponentNamespace
from reflex.components.core.debounce import DebounceInput
from reflex.components.el.elements.forms import Form as HTMLForm
from reflex.components.radix.themes.components.text_field import TextFieldRoot
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, no_args_event_spec
+from reflex.vars.base import Var
from .base import RadixPrimitiveComponentWithClassName
@@ -17,7 +17,7 @@ from .base import RadixPrimitiveComponentWithClassName
class FormComponent(RadixPrimitiveComponentWithClassName):
"""Base class for all @radix-ui/react-form components."""
- library = "@radix-ui/react-form@^0.0.3"
+ library = "@radix-ui/react-form@^0.1.0"
class FormRoot(FormComponent, HTMLForm):
@@ -28,7 +28,7 @@ class FormRoot(FormComponent, HTMLForm):
alias = "RadixFormRoot"
# Fired when the errors are cleared.
- on_clear_server_errors: EventHandler[lambda: []]
+ on_clear_server_errors: EventHandler[no_args_event_spec]
def add_style(self) -> dict[str, Any] | None:
"""Add style to the component.
diff --git a/reflex/components/radix/primitives/form.pyi b/reflex/components/radix/primitives/form.pyi
index 43bd0bbd2..83e65a54d 100644
--- a/reflex/components/radix/primitives/form.pyi
+++ b/reflex/components/radix/primitives/form.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.el.elements.forms import Form as HTMLForm
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .base import RadixPrimitiveComponentWithClassName
@@ -25,52 +25,22 @@ class FormComponent(RadixPrimitiveComponentWithClassName):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "FormComponent":
"""Create the component.
@@ -99,108 +69,84 @@ class FormRoot(FormComponent, HTMLForm):
cls,
*children,
as_child: Optional[Union[Var[bool], bool]] = None,
- accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
accept_charset: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_complete: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- enc_type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- no_validate: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ enc_type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ no_validate: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
reset_on_submit: Optional[Union[Var[bool], bool]] = None,
handle_submit_unique_name: Optional[Union[Var[str], str]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_clear_server_errors: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_clear_server_errors: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
on_submit: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ Union[
+ EventType[[], BASE_STATE], EventType[[Dict[str, Any]], BASE_STATE]
+ ],
+ Union[
+ EventType[[], BASE_STATE], EventType[[Dict[str, str]], BASE_STATE]
+ ],
+ ]
] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "FormRoot":
"""Create a form component.
Args:
*children: The children of the form.
+ on_clear_server_errors: Fired when the errors are cleared.
as_child: Change the default rendered element for the one passed as a child.
accept: MIME types the server accepts for file upload
accept_charset: Character encodings to be used for form submission
@@ -213,7 +159,8 @@ class FormRoot(FormComponent, HTMLForm):
target: Where to display the response after submitting the form
reset_on_submit: If true, the form will be cleared after submit.
handle_submit_unique_name: The name used to make this form's submit handler function unique.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ on_submit: Fired when the form is submitted
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -257,52 +204,22 @@ class FormField(FormComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "FormField":
"""Create the component.
@@ -338,52 +255,22 @@ class FormLabel(FormComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "FormLabel":
"""Create the component.
@@ -416,52 +303,22 @@ class FormControl(FormComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "FormControl":
"""Create a Form Control component.
@@ -509,6 +366,18 @@ class FormMessage(FormComponent):
name: Optional[Union[Var[str], str]] = None,
match: Optional[
Union[
+ Literal[
+ "badInput",
+ "patternMismatch",
+ "rangeOverflow",
+ "rangeUnderflow",
+ "stepMismatch",
+ "tooLong",
+ "tooShort",
+ "typeMismatch",
+ "valid",
+ "valueMissing",
+ ],
Var[
Literal[
"badInput",
@@ -523,18 +392,6 @@ class FormMessage(FormComponent):
"valueMissing",
]
],
- Literal[
- "badInput",
- "patternMismatch",
- "rangeOverflow",
- "rangeUnderflow",
- "stepMismatch",
- "tooLong",
- "tooShort",
- "typeMismatch",
- "valid",
- "valueMissing",
- ],
]
] = None,
force_match: Optional[Union[Var[bool], bool]] = None,
@@ -544,52 +401,22 @@ class FormMessage(FormComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "FormMessage":
"""Create the component.
@@ -625,52 +452,22 @@ class FormValidityState(FormComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "FormValidityState":
"""Create the component.
@@ -703,52 +500,22 @@ class FormSubmit(FormComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "FormSubmit":
"""Create the component.
@@ -778,108 +545,84 @@ class Form(FormRoot):
cls,
*children,
as_child: Optional[Union[Var[bool], bool]] = None,
- accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
accept_charset: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_complete: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- enc_type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- no_validate: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ enc_type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ no_validate: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
reset_on_submit: Optional[Union[Var[bool], bool]] = None,
handle_submit_unique_name: Optional[Union[Var[str], str]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_clear_server_errors: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_clear_server_errors: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
on_submit: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ Union[
+ EventType[[], BASE_STATE], EventType[[Dict[str, Any]], BASE_STATE]
+ ],
+ Union[
+ EventType[[], BASE_STATE], EventType[[Dict[str, str]], BASE_STATE]
+ ],
+ ]
] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Form":
"""Create a form component.
Args:
*children: The children of the form.
+ on_clear_server_errors: Fired when the errors are cleared.
as_child: Change the default rendered element for the one passed as a child.
accept: MIME types the server accepts for file upload
accept_charset: Character encodings to be used for form submission
@@ -892,7 +635,8 @@ class Form(FormRoot):
target: Where to display the response after submitting the form
reset_on_submit: If true, the form will be cleared after submit.
handle_submit_unique_name: The name used to make this form's submit handler function unique.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ on_submit: Fired when the form is submitted
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -934,108 +678,84 @@ class FormNamespace(ComponentNamespace):
def __call__(
*children,
as_child: Optional[Union[Var[bool], bool]] = None,
- accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
accept_charset: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_complete: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- enc_type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- no_validate: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ enc_type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ no_validate: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
reset_on_submit: Optional[Union[Var[bool], bool]] = None,
handle_submit_unique_name: Optional[Union[Var[str], str]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_clear_server_errors: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_clear_server_errors: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
on_submit: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ Union[
+ EventType[[], BASE_STATE], EventType[[Dict[str, Any]], BASE_STATE]
+ ],
+ Union[
+ EventType[[], BASE_STATE], EventType[[Dict[str, str]], BASE_STATE]
+ ],
+ ]
] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Form":
"""Create a form component.
Args:
*children: The children of the form.
+ on_clear_server_errors: Fired when the errors are cleared.
as_child: Change the default rendered element for the one passed as a child.
accept: MIME types the server accepts for file upload
accept_charset: Character encodings to be used for form submission
@@ -1048,7 +768,8 @@ class FormNamespace(ComponentNamespace):
target: Where to display the response after submitting the form
reset_on_submit: If true, the form will be cleared after submit.
handle_submit_unique_name: The name used to make this form's submit handler function unique.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ on_submit: Fired when the form is submitted
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/primitives/progress.py b/reflex/components/radix/primitives/progress.py
index 976daf505..72aee1038 100644
--- a/reflex/components/radix/primitives/progress.py
+++ b/reflex/components/radix/primitives/progress.py
@@ -9,7 +9,7 @@ from reflex.components.core.colors import color
from reflex.components.radix.primitives.accordion import DEFAULT_ANIMATION_DURATION
from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName
from reflex.components.radix.themes.base import LiteralAccentColor, LiteralRadius
-from reflex.vars import Var
+from reflex.vars.base import Var
class ProgressComponent(RadixPrimitiveComponentWithClassName):
diff --git a/reflex/components/radix/primitives/progress.pyi b/reflex/components/radix/primitives/progress.pyi
index 99609c0fc..32e4bb155 100644
--- a/reflex/components/radix/primitives/progress.pyi
+++ b/reflex/components/radix/primitives/progress.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class ProgressComponent(RadixPrimitiveComponentWithClassName):
@overload
@@ -23,52 +23,22 @@ class ProgressComponent(RadixPrimitiveComponentWithClassName):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ProgressComponent":
"""Create the component.
@@ -98,8 +68,8 @@ class ProgressRoot(ProgressComponent):
*children,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
@@ -108,52 +78,22 @@ class ProgressRoot(ProgressComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ProgressRoot":
"""Create the component.
@@ -186,63 +126,63 @@ class ProgressIndicator(ProgressComponent):
max: Optional[Union[Var[Optional[int]], int]] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -252,52 +192,22 @@ class ProgressIndicator(ProgressComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ProgressIndicator":
"""Create the component.
@@ -329,63 +239,63 @@ class Progress(ProgressRoot):
*children,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -393,8 +303,8 @@ class Progress(ProgressRoot):
max: Optional[Union[Var[Optional[int]], int]] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
@@ -403,52 +313,22 @@ class Progress(ProgressRoot):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Progress":
"""High-level API for progress bar.
@@ -481,63 +361,63 @@ class ProgressNamespace(ComponentNamespace):
*children,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -545,8 +425,8 @@ class ProgressNamespace(ComponentNamespace):
max: Optional[Union[Var[Optional[int]], int]] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
@@ -555,52 +435,22 @@ class ProgressNamespace(ComponentNamespace):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Progress":
"""High-level API for progress bar.
diff --git a/reflex/components/radix/primitives/slider.py b/reflex/components/radix/primitives/slider.py
index b8abd23b5..68f39e32c 100644
--- a/reflex/components/radix/primitives/slider.py
+++ b/reflex/components/radix/primitives/slider.py
@@ -2,12 +2,12 @@
from __future__ import annotations
-from typing import Any, List, Literal
+from typing import Any, List, Literal, Tuple
from reflex.components.component import Component, ComponentNamespace
from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName
from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.vars.base import Var
LiteralSliderOrientation = Literal["horizontal", "vertical"]
LiteralSliderDir = Literal["ltr", "rtl"]
@@ -19,8 +19,22 @@ class SliderComponent(RadixPrimitiveComponentWithClassName):
library = "@radix-ui/react-slider@^1.1.2"
+def on_value_event_spec(
+ value: Var[List[int]],
+) -> Tuple[Var[List[int]]]:
+ """Event handler spec for the value event.
+
+ Args:
+ value: The value of the event.
+
+ Returns:
+ The event handler spec.
+ """
+ return (value,) # type: ignore
+
+
class SliderRoot(SliderComponent):
- """The Slider component comtaining all slider parts."""
+ """The Slider component containing all slider parts."""
tag = "Root"
alias = "RadixSliderRoot"
@@ -48,10 +62,10 @@ class SliderRoot(SliderComponent):
min_steps_between_thumbs: Var[int]
# Fired when the value of a thumb changes.
- on_value_change: EventHandler[lambda e0: [e0]]
+ on_value_change: EventHandler[on_value_event_spec]
# Fired when a thumb is released.
- on_value_commit: EventHandler[lambda e0: [e0]]
+ on_value_commit: EventHandler[on_value_event_spec]
def add_style(self) -> dict[str, Any] | None:
"""Add style to the component.
@@ -174,7 +188,7 @@ class Slider(ComponentNamespace):
else:
children = [
track,
- # Foreach.create(props.get("value"), lambda e: SliderThumb.create()), # foreach doesn't render Thumbs properly
+ # Foreach.create(props.get("value"), lambda e: SliderThumb.create()), # foreach doesn't render Thumbs properly # noqa: ERA001
]
return SliderRoot.create(*children, **props)
diff --git a/reflex/components/radix/primitives/slider.pyi b/reflex/components/radix/primitives/slider.pyi
index 0094bc3bb..2a14ba518 100644
--- a/reflex/components/radix/primitives/slider.pyi
+++ b/reflex/components/radix/primitives/slider.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload
from reflex.components.component import Component, ComponentNamespace
from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
LiteralSliderOrientation = Literal["horizontal", "vertical"]
LiteralSliderDir = Literal["ltr", "rtl"]
@@ -26,52 +26,22 @@ class SliderComponent(RadixPrimitiveComponentWithClassName):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SliderComponent":
"""Create the component.
@@ -92,6 +62,8 @@ class SliderComponent(RadixPrimitiveComponentWithClassName):
"""
...
+def on_value_event_spec(value: Var[List[int]]) -> Tuple[Var[List[int]]]: ...
+
class SliderRoot(SliderComponent):
def add_style(self) -> dict[str, Any] | None: ...
@overload
@@ -99,17 +71,17 @@ class SliderRoot(SliderComponent):
def create( # type: ignore
cls,
*children,
- default_value: Optional[Union[Var[List[int]], List[int]]] = None,
- value: Optional[Union[Var[List[int]], List[int]]] = None,
+ default_value: Optional[Union[List[int], Var[List[int]]]] = None,
+ value: Optional[Union[List[int], Var[List[int]]]] = None,
name: Optional[Union[Var[str], str]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
orientation: Optional[
Union[
- Var[Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
- dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None,
+ dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None,
inverted: Optional[Union[Var[bool], bool]] = None,
min: Optional[Union[Var[int], int]] = None,
max: Optional[Union[Var[int], int]] = None,
@@ -121,57 +93,27 @@ class SliderRoot(SliderComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
on_value_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[List[int]], BASE_STATE]]
] = None,
on_value_commit: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[List[int]], BASE_STATE]]
] = None,
**props,
) -> "SliderRoot":
@@ -179,6 +121,8 @@ class SliderRoot(SliderComponent):
Args:
*children: The children of the component.
+ on_value_change: Fired when the value of a thumb changes.
+ on_value_commit: Fired when a thumb is released.
as_child: Change the default rendered element for the one passed as a child.
style: The style of the component.
key: A unique key for the component.
@@ -206,52 +150,22 @@ class SliderTrack(SliderComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SliderTrack":
"""Create the component.
@@ -285,52 +199,22 @@ class SliderRange(SliderComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SliderRange":
"""Create the component.
@@ -364,52 +248,22 @@ class SliderThumb(SliderComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SliderThumb":
"""Create the component.
diff --git a/reflex/components/radix/themes/base.py b/reflex/components/radix/themes/base.py
index e0e05cc81..19e805f7a 100644
--- a/reflex/components/radix/themes/base.py
+++ b/reflex/components/radix/themes/base.py
@@ -5,10 +5,11 @@ from __future__ import annotations
from typing import Any, Dict, Literal
from reflex.components import Component
+from reflex.components.core.breakpoints import Responsive
from reflex.components.tags import Tag
from reflex.config import get_config
from reflex.utils.imports import ImportDict, ImportVar
-from reflex.vars import Var
+from reflex.vars.base import Var
LiteralAlign = Literal["start", "center", "end", "baseline", "stretch"]
LiteralJustify = Literal["start", "center", "end", "between"]
@@ -52,7 +53,7 @@ LiteralAccentColor = Literal[
class CommonMarginProps(Component):
"""Many radix-themes elements accept shorthand margin props."""
- # Margin: "0" - "9"
+ # Margin: "0" - "9" # noqa: ERA001
m: Var[LiteralSpacing]
# Margin horizontal: "0" - "9"
@@ -74,6 +75,31 @@ class CommonMarginProps(Component):
ml: Var[LiteralSpacing]
+class CommonPaddingProps(Component):
+ """Many radix-themes elements accept shorthand padding props."""
+
+ # Padding: "0" - "9" # noqa: ERA001
+ p: Var[Responsive[LiteralSpacing]]
+
+ # Padding horizontal: "0" - "9"
+ px: Var[Responsive[LiteralSpacing]]
+
+ # Padding vertical: "0" - "9"
+ py: Var[Responsive[LiteralSpacing]]
+
+ # Padding top: "0" - "9"
+ pt: Var[Responsive[LiteralSpacing]]
+
+ # Padding right: "0" - "9"
+ pr: Var[Responsive[LiteralSpacing]]
+
+ # Padding bottom: "0" - "9"
+ pb: Var[Responsive[LiteralSpacing]]
+
+ # Padding left: "0" - "9"
+ pl: Var[Responsive[LiteralSpacing]]
+
+
class RadixLoadingProp(Component):
"""Base class for components that can be in a loading state."""
@@ -86,6 +112,9 @@ class RadixThemesComponent(Component):
library = "@radix-ui/themes@^3.0.0"
+ # Temporary pin < 3.1.5 until radix-ui/themes#627 is resolved.
+ library = library + " && <3.1.5"
+
# "Fake" prop color_scheme is used to avoid shadowing CSS prop "color".
_rename_props: Dict[str, str] = {"colorScheme": "color"}
@@ -110,9 +139,7 @@ class RadixThemesComponent(Component):
component = super().create(*children, **props)
if component.library is None:
component.library = RadixThemesComponent.__fields__["library"].default
- component.alias = "RadixThemes" + (
- component.tag or component.__class__.__name__
- )
+ component.alias = "RadixThemes" + (component.tag or type(component).__name__)
return component
@staticmethod
@@ -216,7 +243,7 @@ class Theme(RadixThemesComponent):
The import dict.
"""
_imports: ImportDict = {
- "/utils/theme.js": [ImportVar(tag="theme", is_default=True)],
+ "$/utils/theme.js": [ImportVar(tag="theme", is_default=True)],
}
if get_config().tailwind is None:
# When tailwind is disabled, import the radix-ui styles directly because they will
@@ -230,12 +257,11 @@ class Theme(RadixThemesComponent):
def _render(self, props: dict[str, Any] | None = None) -> Tag:
tag = super()._render(props)
tag.add_props(
- css=Var.create(
- "{{...theme.styles.global[':root'], ...theme.styles.global.body}}",
- _var_is_local=False,
- _var_is_string=False,
+ css=Var(
+ _js_expr="{...theme.styles.global[':root'], ...theme.styles.global.body}"
),
)
+ tag.remove_props("appearance")
return tag
@@ -258,31 +284,11 @@ class ThemePanel(RadixThemesComponent):
"""
return {"react": "useEffect"}
- def add_hooks(self) -> list[str]:
- """Add a hook on the ThemePanel to clear chakra-ui-color-mode.
-
- Returns:
- The hooks to render.
- """
- # The panel freezes the tab if the user color preference differs from the
- # theme "appearance", so clear it out when theme panel is used.
- return [
- """
- useEffect(() => {
- if (typeof window !== 'undefined') {
- window.onbeforeunload = () => {
- localStorage.removeItem('chakra-ui-color-mode');
- }
- window.onbeforeunload();
- }
- }, [])"""
- ]
-
class RadixThemesColorModeProvider(Component):
"""Next-themes integration for radix themes components."""
- library = "/components/reflex/radix_themes_color_mode_provider.js"
+ library = "$/components/reflex/radix_themes_color_mode_provider.js"
tag = "RadixThemesColorModeProvider"
is_default = True
diff --git a/reflex/components/radix/themes/base.pyi b/reflex/components/radix/themes/base.pyi
index 3014b5013..b0a8e2fcb 100644
--- a/reflex/components/radix/themes/base.pyi
+++ b/reflex/components/radix/themes/base.pyi
@@ -3,13 +3,14 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components import Component
-from reflex.event import EventHandler, EventSpec
+from reflex.components.core.breakpoints import Breakpoints
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
from reflex.utils.imports import ImportDict
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
LiteralAlign = Literal["start", "center", "end", "baseline", "stretch"]
LiteralJustify = Literal["start", "center", "end", "between"]
@@ -57,44 +58,44 @@ class CommonMarginProps(Component):
*children,
m: Optional[
Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
mx: Optional[
Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
my: Optional[
Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
mt: Optional[
Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
mr: Optional[
Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
mb: Optional[
Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
ml: Optional[
Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
style: Optional[Style] = None,
@@ -102,52 +103,22 @@ class CommonMarginProps(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "CommonMarginProps":
"""Create the component.
@@ -174,6 +145,178 @@ class CommonMarginProps(Component):
"""
...
+class CommonPaddingProps(Component):
+ @overload
+ @classmethod
+ def create( # type: ignore
+ cls,
+ *children,
+ p: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ px: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ py: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ pt: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ pr: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ pb: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ pl: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ style: Optional[Style] = None,
+ key: Optional[Any] = None,
+ id: Optional[Any] = None,
+ class_name: Optional[Any] = None,
+ autofocus: Optional[bool] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
+ **props,
+ ) -> "CommonPaddingProps":
+ """Create the component.
+
+ Args:
+ *children: The children of the component.
+ p: Padding: "0" - "9"
+ px: Padding horizontal: "0" - "9"
+ py: Padding vertical: "0" - "9"
+ pt: Padding top: "0" - "9"
+ pr: Padding right: "0" - "9"
+ pb: Padding bottom: "0" - "9"
+ pl: Padding left: "0" - "9"
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: The props of the component.
+
+ Returns:
+ The component.
+ """
+ ...
+
class RadixLoadingProp(Component):
@overload
@classmethod
@@ -186,52 +329,22 @@ class RadixLoadingProp(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "RadixLoadingProp":
"""Create the component.
@@ -263,52 +376,22 @@ class RadixThemesComponent(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "RadixThemesComponent":
"""Create a new component instance.
@@ -342,52 +425,22 @@ class RadixThemesTriggerComponent(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "RadixThemesTriggerComponent":
"""Create a new RadixThemesTriggerComponent instance.
@@ -407,96 +460,96 @@ class Theme(RadixThemesComponent):
def create( # type: ignore
cls,
*children,
- color_mode: Optional[Literal["inherit", "light", "dark"]] = None,
+ color_mode: Optional[Literal["dark", "inherit", "light"]] = None,
theme_panel: Optional[bool] = False,
has_background: Optional[Union[Var[bool], bool]] = None,
appearance: Optional[
Union[
- Var[Literal["inherit", "light", "dark"]],
- Literal["inherit", "light", "dark"],
+ Literal["dark", "inherit", "light"],
+ Var[Literal["dark", "inherit", "light"]],
]
] = None,
accent_color: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
gray_color: Optional[
Union[
- Var[Literal["gray", "mauve", "slate", "sage", "olive", "sand", "auto"]],
- Literal["gray", "mauve", "slate", "sage", "olive", "sand", "auto"],
+ Literal["auto", "gray", "mauve", "olive", "sage", "sand", "slate"],
+ Var[Literal["auto", "gray", "mauve", "olive", "sage", "sand", "slate"]],
]
] = None,
panel_background: Optional[
- Union[Var[Literal["solid", "translucent"]], Literal["solid", "translucent"]]
+ Union[Literal["solid", "translucent"], Var[Literal["solid", "translucent"]]]
] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
scaling: Optional[
Union[
- Var[Literal["90%", "95%", "100%", "105%", "110%"]],
- Literal["90%", "95%", "100%", "105%", "110%"],
+ Literal["100%", "105%", "110%", "90%", "95%"],
+ Var[Literal["100%", "105%", "110%", "90%", "95%"]],
]
] = None,
style: Optional[Style] = None,
@@ -504,52 +557,22 @@ class Theme(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Theme":
"""Create a new Radix Theme specification.
@@ -582,7 +605,6 @@ class Theme(RadixThemesComponent):
class ThemePanel(RadixThemesComponent):
def add_imports(self) -> dict[str, str]: ...
- def add_hooks(self) -> list[str]: ...
@overload
@classmethod
def create( # type: ignore
@@ -594,52 +616,22 @@ class ThemePanel(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ThemePanel":
"""Create a new component instance.
@@ -674,52 +666,22 @@ class RadixThemesColorModeProvider(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "RadixThemesColorModeProvider":
"""Create the component.
diff --git a/reflex/components/radix/themes/color_mode.py b/reflex/components/radix/themes/color_mode.py
index 8243a822a..2dd0f5e83 100644
--- a/reflex/components/radix/themes/color_mode.py
+++ b/reflex/components/radix/themes/color_mode.py
@@ -17,8 +17,7 @@ rx.text(
from __future__ import annotations
-import dataclasses
-from typing import Literal, get_args
+from typing import Dict, List, Literal, Optional, Union, get_args
from reflex.components.component import BaseComponent
from reflex.components.core.cond import Cond, color_mode_cond, cond
@@ -32,8 +31,8 @@ from reflex.style import (
set_color_mode,
toggle_color_mode,
)
-from reflex.utils import console
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
+from reflex.vars.sequence import LiteralArrayVar
from .components.icon_button import IconButton
@@ -67,9 +66,9 @@ class ColorModeIcon(Cond):
LiteralPosition = Literal["top-left", "top-right", "bottom-left", "bottom-right"]
-position_values = get_args(LiteralPosition)
+position_values: List[str] = list(get_args(LiteralPosition))
-position_map = {
+position_map: Dict[str, List[str]] = {
"position": position_values,
"left": ["top-left", "bottom-left"],
"right": ["top-right", "bottom-right"],
@@ -79,8 +78,8 @@ position_map = {
# needed to inverse contains for find
-def _find(const, var):
- return Var.create_safe(const, _var_is_string=False).contains(var)
+def _find(const: List[str], var):
+ return LiteralArrayVar.create(const).contains(var)
def _set_var_default(props, position, prop, default1, default2=""):
@@ -97,36 +96,31 @@ def _set_static_default(props, position, prop, default):
class ColorModeIconButton(IconButton):
"""Icon Button for toggling light / dark mode via toggle_color_mode."""
+ # The position of the icon button. Follow document flow if None.
+ position: Optional[Union[LiteralPosition, Var[LiteralPosition]]] = None
+
+ # Allow picking the "system" value for the color mode.
+ allow_system: bool = False
+
@classmethod
def create(
cls,
- *children,
- position: LiteralPosition | None = None,
- allow_system: bool = False,
**props,
):
- """Create a icon button component that calls toggle_color_mode on click.
+ """Create an icon button component that calls toggle_color_mode on click.
Args:
- *children: The children of the component.
- position: The position of the icon button. Follow document flow if None.
- allow_system: Allow picking the "system" value for the color mode.
**props: The props to pass to the component.
Returns:
The button component.
"""
- if children:
- console.deprecate(
- feature_name="passing children to color_mode.button",
- reason=", use color_mode_cond and toggle_color_mode instead to build a custom color_mode component",
- deprecation_version="0.5.0",
- removal_version="0.6.0",
- )
+ position = props.pop("position", None)
+ allow_system = props.pop("allow_system", False)
# position is used to set nice defaults for positioning the icon button
if isinstance(position, Var):
- _set_var_default(props, position, "position", "fixed", position)
+ _set_var_default(props, position, "position", "fixed", position) # type: ignore
_set_var_default(props, position, "bottom", "2rem")
_set_var_default(props, position, "top", "2rem")
_set_var_default(props, position, "left", "2rem")
@@ -166,12 +160,15 @@ class ColorModeIconButton(IconButton):
color_mode_item("system"),
),
)
- return super().create(
+ return IconButton.create(
ColorModeIcon.create(),
on_click=toggle_color_mode,
**props,
)
+ def _exclude_props(self) -> list[str]:
+ return ["position", "allow_system"]
+
class ColorModeSwitch(Switch):
"""Switch for toggling light / dark mode via toggle_color_mode."""
@@ -195,7 +192,7 @@ class ColorModeSwitch(Switch):
)
-class ColorModeNamespace(BaseVar):
+class ColorModeNamespace(Var):
"""Namespace for color mode components."""
icon = staticmethod(ColorModeIcon.create)
@@ -204,5 +201,7 @@ class ColorModeNamespace(BaseVar):
color_mode = color_mode_var_and_namespace = ColorModeNamespace(
- **dataclasses.asdict(color_mode)
+ _js_expr=color_mode._js_expr,
+ _var_type=color_mode._var_type,
+ _var_data=color_mode._get_default_value(),
)
diff --git a/reflex/components/radix/themes/color_mode.pyi b/reflex/components/radix/themes/color_mode.pyi
index 474c4cf36..3a9347017 100644
--- a/reflex/components/radix/themes/color_mode.pyi
+++ b/reflex/components/radix/themes/color_mode.pyi
@@ -3,20 +3,16 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-import dataclasses
-from typing import Any, Callable, Dict, Literal, Optional, Union, get_args, overload
+from typing import Any, Dict, List, Literal, Optional, Union, overload
from reflex.components.component import BaseComponent
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.core.cond import Cond
from reflex.components.lucide.icon import Icon
from reflex.components.radix.themes.components.switch import Switch
-from reflex.event import EventHandler, EventSpec
-from reflex.style import (
- Style,
- color_mode,
-)
-from reflex.vars import BaseVar, Var
+from reflex.event import BASE_STATE, EventType
+from reflex.style import Style, color_mode
+from reflex.vars.base import Var
from .components.icon_button import IconButton
@@ -29,7 +25,7 @@ class ColorModeIcon(Cond):
def create( # type: ignore
cls,
*children,
- cond: Optional[Union[Var[Any], Any]] = None,
+ cond: Optional[Union[Any, Var[Any]]] = None,
comp1: Optional[BaseComponent] = None,
comp2: Optional[BaseComponent] = None,
style: Optional[Style] = None,
@@ -37,52 +33,22 @@ class ColorModeIcon(Cond):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ColorModeIcon":
"""Create an icon component based on color_mode.
@@ -97,14 +63,8 @@ class ColorModeIcon(Cond):
...
LiteralPosition = Literal["top-left", "top-right", "bottom-left", "bottom-right"]
-position_values = get_args(LiteralPosition)
-position_map = {
- "position": position_values,
- "left": ["top-left", "bottom-left"],
- "right": ["top-right", "bottom-right"],
- "top": ["top-left", "top-right"],
- "bottom": ["bottom-left", "bottom-right"],
-}
+position_values: List[str]
+position_map: Dict[str, List[str]]
class ColorModeIconButton(IconButton):
@overload
@@ -113,194 +73,171 @@ class ColorModeIconButton(IconButton):
cls,
*children,
position: Optional[
- Literal["top-left", "top-right", "bottom-left", "bottom-right"]
+ Union[
+ Literal["bottom-left", "bottom-right", "top-left", "top-right"],
+ Union[
+ Literal["bottom-left", "bottom-right", "top-left", "top-right"],
+ Var[
+ Literal["bottom-left", "bottom-right", "top-left", "top-right"]
+ ],
+ ],
+ ]
] = None,
- allow_system: Optional[bool] = False,
+ allow_system: Optional[bool] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4"]],
+ Literal["1", "2", "3", "4"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3", "4"]],
Literal["1", "2", "3", "4"],
]
],
- Literal["1", "2", "3", "4"],
- Breakpoints[str, Literal["1", "2", "3", "4"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]],
- Literal["classic", "solid", "soft", "surface", "outline", "ghost"],
+ Literal["classic", "ghost", "outline", "soft", "solid", "surface"],
+ Var[Literal["classic", "ghost", "outline", "soft", "solid", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
- auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
form_enc_type: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
form_no_validate: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
loading: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ColorModeIconButton":
- """Create a icon button component that calls toggle_color_mode on click.
+ """Create an icon button component that calls toggle_color_mode on click.
Args:
- *children: The children of the component.
position: The position of the icon button. Follow document flow if None.
allow_system: Allow picking the "system" value for the color mode.
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
@@ -320,7 +257,7 @@ class ColorModeIconButton(IconButton):
name: Name of the button, used when sending form data
type: Type of the button (submit, reset, or button)
value: Value of the button, used when sending form data
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -365,87 +302,87 @@ class ColorModeSwitch(Switch):
value: Optional[Union[Var[str], str]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "full"]], Literal["none", "small", "full"]
+ Literal["full", "none", "small"], Var[Literal["full", "none", "small"]]
]
] = None,
style: Optional[Style] = None,
@@ -453,55 +390,25 @@ class ColorModeSwitch(Switch):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ColorModeSwitch":
"""Create a switch component bound to color_mode.
@@ -520,6 +427,7 @@ class ColorModeSwitch(Switch):
color_scheme: Override theme color for switch
high_contrast: Whether to render the switch with higher contrast color against background
radius: Override theme radius for switch: "none" | "small" | "full"
+ on_change: Fired when the value of the switch changes
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -533,11 +441,13 @@ class ColorModeSwitch(Switch):
"""
...
-class ColorModeNamespace(BaseVar):
+class ColorModeNamespace(Var):
icon = staticmethod(ColorModeIcon.create)
button = staticmethod(ColorModeIconButton.create)
switch = staticmethod(ColorModeSwitch.create)
color_mode = color_mode_var_and_namespace = ColorModeNamespace(
- **dataclasses.asdict(color_mode)
+ _js_expr=color_mode._js_expr,
+ _var_type=color_mode._var_type,
+ _var_data=color_mode._get_default_value(),
)
diff --git a/reflex/components/radix/themes/components/__init__.pyi b/reflex/components/radix/themes/components/__init__.pyi
index 6f6df88fa..29f15e311 100644
--- a/reflex/components/radix/themes/components/__init__.pyi
+++ b/reflex/components/radix/themes/components/__init__.pyi
@@ -22,6 +22,7 @@ from .hover_card import hover_card as hover_card
from .icon_button import icon_button as icon_button
from .inset import inset as inset
from .popover import popover as popover
+from .progress import progress as progress
from .radio_cards import radio_cards as radio_cards
from .radio_group import radio as radio
from .radio_group import radio_group as radio_group
diff --git a/reflex/components/radix/themes/components/alert_dialog.py b/reflex/components/radix/themes/components/alert_dialog.py
index e8dfb57b2..36d38532c 100644
--- a/reflex/components/radix/themes/components/alert_dialog.py
+++ b/reflex/components/radix/themes/components/alert_dialog.py
@@ -5,8 +5,8 @@ from typing import Literal
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec
+from reflex.vars.base import Var
from ..base import RadixThemesComponent, RadixThemesTriggerComponent
@@ -22,7 +22,10 @@ class AlertDialogRoot(RadixThemesComponent):
open: Var[bool]
# Fired when the open state changes.
- on_open_change: EventHandler[lambda e0: [e0]]
+ on_open_change: EventHandler[passthrough_event_spec(bool)]
+
+ # The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.
+ default_open: Var[bool]
class AlertDialogTrigger(RadixThemesTriggerComponent):
@@ -43,13 +46,13 @@ class AlertDialogContent(elements.Div, RadixThemesComponent):
force_mount: Var[bool]
# Fired when the dialog is opened.
- on_open_auto_focus: EventHandler[lambda e0: [e0]]
+ on_open_auto_focus: EventHandler[no_args_event_spec]
# Fired when the dialog is closed.
- on_close_auto_focus: EventHandler[lambda e0: [e0]]
+ on_close_auto_focus: EventHandler[no_args_event_spec]
# Fired when the escape key is pressed.
- on_escape_key_down: EventHandler[lambda e0: [e0]]
+ on_escape_key_down: EventHandler[no_args_event_spec]
class AlertDialogTitle(RadixThemesComponent):
diff --git a/reflex/components/radix/themes/components/alert_dialog.pyi b/reflex/components/radix/themes/components/alert_dialog.pyi
index 406d5eb2d..6188fdd45 100644
--- a/reflex/components/radix/themes/components/alert_dialog.pyi
+++ b/reflex/components/radix/themes/components/alert_dialog.pyi
@@ -3,14 +3,14 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent, RadixThemesTriggerComponent
@@ -23,60 +23,31 @@ class AlertDialogRoot(RadixThemesComponent):
cls,
*children,
open: Optional[Union[Var[bool], bool]] = None,
+ default_open: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AlertDialogRoot":
"""Create a new component instance.
@@ -87,6 +58,8 @@ class AlertDialogRoot(RadixThemesComponent):
Args:
*children: Child components.
open: The controlled open state of the dialog.
+ on_open_change: Fired when the open state changes.
+ default_open: The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -111,52 +84,22 @@ class AlertDialogTrigger(RadixThemesTriggerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AlertDialogTrigger":
"""Create a new RadixThemesTriggerComponent instance.
@@ -178,101 +121,65 @@ class AlertDialogContent(elements.Div, RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4"]],
+ Literal["1", "2", "3", "4"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3", "4"]],
Literal["1", "2", "3", "4"],
]
],
- Literal["1", "2", "3", "4"],
- Breakpoints[str, Literal["1", "2", "3", "4"]],
]
] = None,
force_mount: Optional[Union[Var[bool], bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close_auto_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_escape_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_open_auto_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_open_auto_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AlertDialogContent":
"""Create a new component instance.
@@ -284,7 +191,10 @@ class AlertDialogContent(elements.Div, RadixThemesComponent):
*children: Child components.
size: The size of the content.
force_mount: Whether to force mount the content on open.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ on_open_auto_focus: Fired when the dialog is opened.
+ on_close_auto_focus: Fired when the dialog is closed.
+ on_escape_key_down: Fired when the escape key is pressed.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -324,52 +234,22 @@ class AlertDialogTitle(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AlertDialogTitle":
"""Create a new component instance.
@@ -403,52 +283,22 @@ class AlertDialogDescription(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AlertDialogDescription":
"""Create a new component instance.
@@ -482,52 +332,22 @@ class AlertDialogAction(RadixThemesTriggerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AlertDialogAction":
"""Create a new RadixThemesTriggerComponent instance.
@@ -552,52 +372,22 @@ class AlertDialogCancel(RadixThemesTriggerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AlertDialogCancel":
"""Create a new RadixThemesTriggerComponent instance.
diff --git a/reflex/components/radix/themes/components/aspect_ratio.py b/reflex/components/radix/themes/components/aspect_ratio.py
index b06b2d564..fc8052c85 100644
--- a/reflex/components/radix/themes/components/aspect_ratio.py
+++ b/reflex/components/radix/themes/components/aspect_ratio.py
@@ -2,7 +2,7 @@
from typing import Union
-from reflex.vars import Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
diff --git a/reflex/components/radix/themes/components/aspect_ratio.pyi b/reflex/components/radix/themes/components/aspect_ratio.pyi
index 08109b740..882014073 100644
--- a/reflex/components/radix/themes/components/aspect_ratio.pyi
+++ b/reflex/components/radix/themes/components/aspect_ratio.pyi
@@ -3,11 +3,11 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -23,52 +23,22 @@ class AspectRatio(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AspectRatio":
"""Create a new component instance.
diff --git a/reflex/components/radix/themes/components/avatar.py b/reflex/components/radix/themes/components/avatar.py
index 22482f0c9..77a305e29 100644
--- a/reflex/components/radix/themes/components/avatar.py
+++ b/reflex/components/radix/themes/components/avatar.py
@@ -3,13 +3,9 @@
from typing import Literal
from reflex.components.core.breakpoints import Responsive
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- LiteralRadius,
- RadixThemesComponent,
-)
+from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent
LiteralSize = Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]
diff --git a/reflex/components/radix/themes/components/avatar.pyi b/reflex/components/radix/themes/components/avatar.pyi
index 894ee6f67..e0ff0d913 100644
--- a/reflex/components/radix/themes/components/avatar.pyi
+++ b/reflex/components/radix/themes/components/avatar.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -21,10 +21,12 @@ class Avatar(RadixThemesComponent):
cls,
*children,
variant: Optional[
- Union[Var[Literal["solid", "soft"]], Literal["solid", "soft"]]
+ Union[Literal["soft", "solid"], Var[Literal["soft", "solid"]]]
] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -33,77 +35,75 @@ class Avatar(RadixThemesComponent):
Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
src: Optional[Union[Var[str], str]] = None,
@@ -113,52 +113,22 @@ class Avatar(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Avatar":
"""Create a new component instance.
diff --git a/reflex/components/radix/themes/components/badge.py b/reflex/components/radix/themes/components/badge.py
index fd26b17ab..389012bf0 100644
--- a/reflex/components/radix/themes/components/badge.py
+++ b/reflex/components/radix/themes/components/badge.py
@@ -4,13 +4,9 @@ from typing import Literal
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- LiteralRadius,
- RadixThemesComponent,
-)
+from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent
class Badge(elements.Span, RadixThemesComponent):
diff --git a/reflex/components/radix/themes/components/badge.pyi b/reflex/components/radix/themes/components/badge.pyi
index 74d6dec24..38f20efeb 100644
--- a/reflex/components/radix/themes/components/badge.pyi
+++ b/reflex/components/radix/themes/components/badge.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -21,165 +21,135 @@ class Badge(elements.Span, RadixThemesComponent):
*children,
variant: Optional[
Union[
- Var[Literal["solid", "soft", "surface", "outline"]],
- Literal["solid", "soft", "surface", "outline"],
+ Literal["outline", "soft", "solid", "surface"],
+ Var[Literal["outline", "soft", "solid", "surface"]],
]
] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Badge":
"""Create a new component instance.
@@ -194,7 +164,7 @@ class Badge(elements.Span, RadixThemesComponent):
color_scheme: Color theme of the badge
high_contrast: Whether to render the badge with higher contrast color against background
radius: Override theme radius for badge: "none" | "small" | "medium" | "large" | "full"
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/components/button.py b/reflex/components/radix/themes/components/button.py
index 0c52e6ec6..cb44ee684 100644
--- a/reflex/components/radix/themes/components/button.py
+++ b/reflex/components/radix/themes/components/button.py
@@ -4,7 +4,7 @@ from typing import Literal
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.vars import Var
+from reflex.vars.base import Var
from ..base import (
LiteralAccentColor,
diff --git a/reflex/components/radix/themes/components/button.pyi b/reflex/components/radix/themes/components/button.pyi
index 877b7630b..cee24abc4 100644
--- a/reflex/components/radix/themes/components/button.pyi
+++ b/reflex/components/radix/themes/components/button.pyi
@@ -3,18 +3,15 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
-from ..base import (
- RadixLoadingProp,
- RadixThemesComponent,
-)
+from ..base import RadixLoadingProp, RadixThemesComponent
LiteralButtonSize = Literal["1", "2", "3", "4"]
@@ -27,182 +24,152 @@ class Button(elements.Button, RadixLoadingProp, RadixThemesComponent):
as_child: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4"]],
+ Literal["1", "2", "3", "4"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3", "4"]],
Literal["1", "2", "3", "4"],
]
],
- Literal["1", "2", "3", "4"],
- Breakpoints[str, Literal["1", "2", "3", "4"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]],
- Literal["classic", "solid", "soft", "surface", "outline", "ghost"],
+ Literal["classic", "ghost", "outline", "soft", "solid", "surface"],
+ Var[Literal["classic", "ghost", "outline", "soft", "solid", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
- auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
form_enc_type: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
form_no_validate: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
loading: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Button":
"""Create a new component instance.
@@ -229,7 +196,7 @@ class Button(elements.Button, RadixLoadingProp, RadixThemesComponent):
name: Name of the button, used when sending form data
type: Type of the button (submit, reset, or button)
value: Value of the button, used when sending form data
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/components/callout.py b/reflex/components/radix/themes/components/callout.py
index ea8be4623..6b0a1d399 100644
--- a/reflex/components/radix/themes/components/callout.py
+++ b/reflex/components/radix/themes/components/callout.py
@@ -7,12 +7,9 @@ from reflex.components.component import Component, ComponentNamespace
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
from reflex.components.lucide.icon import Icon
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- RadixThemesComponent,
-)
+from ..base import LiteralAccentColor, RadixThemesComponent
CalloutVariant = Literal["soft", "surface", "outline"]
diff --git a/reflex/components/radix/themes/components/callout.pyi b/reflex/components/radix/themes/components/callout.pyi
index 2085fb4f5..2c469956f 100644
--- a/reflex/components/radix/themes/components/callout.pyi
+++ b/reflex/components/radix/themes/components/callout.pyi
@@ -3,14 +3,14 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -25,159 +25,129 @@ class CalloutRoot(elements.Div, RadixThemesComponent):
as_child: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["soft", "surface", "outline"]],
- Literal["soft", "surface", "outline"],
+ Literal["outline", "soft", "surface"],
+ Var[Literal["outline", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "CalloutRoot":
"""Create a new component instance.
@@ -192,7 +162,7 @@ class CalloutRoot(elements.Div, RadixThemesComponent):
variant: Variant of button: "soft" | "surface" | "outline"
color_scheme: Override theme color for button
high_contrast: Whether to render the button with higher contrast color against background
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -227,81 +197,51 @@ class CalloutIcon(elements.Div, RadixThemesComponent):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "CalloutIcon":
"""Create a new component instance.
@@ -311,7 +251,7 @@ class CalloutIcon(elements.Div, RadixThemesComponent):
Args:
*children: Child components.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -346,81 +286,51 @@ class CalloutText(elements.P, RadixThemesComponent):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "CalloutText":
"""Create a new component instance.
@@ -430,7 +340,7 @@ class CalloutText(elements.P, RadixThemesComponent):
Args:
*children: Child components.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -470,159 +380,129 @@ class Callout(CalloutRoot):
as_child: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["soft", "surface", "outline"]],
- Literal["soft", "surface", "outline"],
+ Literal["outline", "soft", "surface"],
+ Var[Literal["outline", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Callout":
"""Create a callout component.
@@ -636,7 +516,7 @@ class Callout(CalloutRoot):
variant: Variant of button: "soft" | "surface" | "outline"
color_scheme: Override theme color for button
high_contrast: Whether to render the button with higher contrast color against background
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -678,159 +558,129 @@ class CalloutNamespace(ComponentNamespace):
as_child: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["soft", "surface", "outline"]],
- Literal["soft", "surface", "outline"],
+ Literal["outline", "soft", "surface"],
+ Var[Literal["outline", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Callout":
"""Create a callout component.
@@ -844,7 +694,7 @@ class CalloutNamespace(ComponentNamespace):
variant: Variant of button: "soft" | "surface" | "outline"
color_scheme: Override theme color for button
high_contrast: Whether to render the button with higher contrast color against background
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/components/card.py b/reflex/components/radix/themes/components/card.py
index 574336b1b..30823de56 100644
--- a/reflex/components/radix/themes/components/card.py
+++ b/reflex/components/radix/themes/components/card.py
@@ -4,11 +4,9 @@ from typing import Literal
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- RadixThemesComponent,
-)
+from ..base import RadixThemesComponent
class Card(elements.Div, RadixThemesComponent):
diff --git a/reflex/components/radix/themes/components/card.pyi b/reflex/components/radix/themes/components/card.pyi
index dc12b7d88..d8ab6c06b 100644
--- a/reflex/components/radix/themes/components/card.pyi
+++ b/reflex/components/radix/themes/components/card.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -22,97 +22,67 @@ class Card(elements.Div, RadixThemesComponent):
as_child: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4", "5"]],
+ Literal["1", "2", "3", "4", "5"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3", "4", "5"]],
Literal["1", "2", "3", "4", "5"],
]
],
- Literal["1", "2", "3", "4", "5"],
- Breakpoints[str, Literal["1", "2", "3", "4", "5"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["surface", "classic", "ghost"]],
- Literal["surface", "classic", "ghost"],
+ Literal["classic", "ghost", "surface"],
+ Var[Literal["classic", "ghost", "surface"]],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Card":
"""Create a new component instance.
@@ -125,7 +95,7 @@ class Card(elements.Div, RadixThemesComponent):
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
size: Card size: "1" - "5"
variant: Variant of Card: "solid" | "soft" | "outline" | "ghost"
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/components/checkbox.py b/reflex/components/radix/themes/components/checkbox.py
index 4751c4995..42277bfea 100644
--- a/reflex/components/radix/themes/components/checkbox.py
+++ b/reflex/components/radix/themes/components/checkbox.py
@@ -6,14 +6,10 @@ from reflex.components.component import Component, ComponentNamespace
from reflex.components.core.breakpoints import Responsive
from reflex.components.radix.themes.layout.flex import Flex
from reflex.components.radix.themes.typography.text import Text
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, passthrough_event_spec
+from reflex.vars.base import LiteralVar, Var
-from ..base import (
- LiteralAccentColor,
- LiteralSpacing,
- RadixThemesComponent,
-)
+from ..base import LiteralAccentColor, LiteralSpacing, RadixThemesComponent
LiteralCheckboxSize = Literal["1", "2", "3"]
LiteralCheckboxVariant = Literal["classic", "surface", "soft"]
@@ -61,7 +57,7 @@ class Checkbox(RadixThemesComponent):
_rename_props = {"onChange": "onCheckedChange"}
# Fired when the checkbox is checked or unchecked.
- on_change: EventHandler[lambda e0: [e0]]
+ on_change: EventHandler[passthrough_event_spec(bool)]
class HighLevelCheckbox(RadixThemesComponent):
@@ -112,12 +108,10 @@ class HighLevelCheckbox(RadixThemesComponent):
_rename_props = {"onChange": "onCheckedChange"}
# Fired when the checkbox is checked or unchecked.
- on_change: EventHandler[lambda e0: [e0]]
+ on_change: EventHandler[passthrough_event_spec(bool)]
@classmethod
- def create(
- cls, text: Var[str] = Var.create_safe("", _var_is_string=True), **props
- ) -> Component:
+ def create(cls, text: Var[str] = LiteralVar.create(""), **props) -> Component:
"""Create a checkbox with a label.
Args:
diff --git a/reflex/components/radix/themes/components/checkbox.pyi b/reflex/components/radix/themes/components/checkbox.pyi
index d21018e1d..fb6b51434 100644
--- a/reflex/components/radix/themes/components/checkbox.pyi
+++ b/reflex/components/radix/themes/components/checkbox.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -25,80 +25,80 @@ class Checkbox(RadixThemesComponent):
as_child: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -114,55 +114,25 @@ class Checkbox(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Checkbox":
"""Create a new component instance.
@@ -183,6 +153,7 @@ class Checkbox(RadixThemesComponent):
required: Whether the checkbox is required
name: The name of the checkbox control when submitting the form.
value: The value of the checkbox control when submitting the form.
+ on_change: Fired when the checkbox is checked or unchecked.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -205,79 +176,79 @@ class HighLevelCheckbox(RadixThemesComponent):
text: Optional[Union[Var[str], str]] = None,
spacing: Optional[
Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
size: Optional[
- Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]]
+ Union[Literal["1", "2", "3"], Var[Literal["1", "2", "3"]]]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -293,55 +264,25 @@ class HighLevelCheckbox(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "HighLevelCheckbox":
"""Create a checkbox with a label.
@@ -361,6 +302,7 @@ class HighLevelCheckbox(RadixThemesComponent):
required: Whether the checkbox is required
name: The name of the checkbox control when submitting the form.
value: The value of the checkbox control when submitting the form.
+ on_change: Fired when the checkbox is checked or unchecked.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -381,79 +323,79 @@ class CheckboxNamespace(ComponentNamespace):
text: Optional[Union[Var[str], str]] = None,
spacing: Optional[
Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
size: Optional[
- Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]]
+ Union[Literal["1", "2", "3"], Var[Literal["1", "2", "3"]]]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -469,55 +411,25 @@ class CheckboxNamespace(ComponentNamespace):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "HighLevelCheckbox":
"""Create a checkbox with a label.
@@ -537,6 +449,7 @@ class CheckboxNamespace(ComponentNamespace):
required: Whether the checkbox is required
name: The name of the checkbox control when submitting the form.
value: The value of the checkbox control when submitting the form.
+ on_change: Fired when the checkbox is checked or unchecked.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/radix/themes/components/checkbox_cards.py b/reflex/components/radix/themes/components/checkbox_cards.py
index d5042c355..5f5fc3ae3 100644
--- a/reflex/components/radix/themes/components/checkbox_cards.py
+++ b/reflex/components/radix/themes/components/checkbox_cards.py
@@ -4,7 +4,7 @@ from types import SimpleNamespace
from typing import Literal, Union
from reflex.components.core.breakpoints import Responsive
-from reflex.vars import Var
+from reflex.vars.base import Var
from ..base import LiteralAccentColor, RadixThemesComponent
diff --git a/reflex/components/radix/themes/components/checkbox_cards.pyi b/reflex/components/radix/themes/components/checkbox_cards.pyi
index c35754bde..64eb151b0 100644
--- a/reflex/components/radix/themes/components/checkbox_cards.pyi
+++ b/reflex/components/radix/themes/components/checkbox_cards.pyi
@@ -4,12 +4,12 @@
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
from types import SimpleNamespace
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -21,83 +21,88 @@ class CheckboxCardsRoot(RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
- Union[Var[Literal["classic", "surface"]], Literal["classic", "surface"]]
+ Union[Literal["classic", "surface"], Var[Literal["classic", "surface"]]]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
columns: Optional[
Union[
+ Breakpoints[
+ str,
+ Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str],
+ ],
+ Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -112,15 +117,15 @@ class CheckboxCardsRoot(RadixThemesComponent):
]
],
str,
- Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str,
- Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str],
- ],
]
] = None,
gap: Optional[
Union[
+ Breakpoints[
+ str,
+ Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str],
+ ],
+ Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -135,11 +140,6 @@ class CheckboxCardsRoot(RadixThemesComponent):
]
],
str,
- Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str,
- Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str],
- ],
]
] = None,
style: Optional[Style] = None,
@@ -147,52 +147,22 @@ class CheckboxCardsRoot(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "CheckboxCardsRoot":
"""Create a new component instance.
@@ -232,52 +202,22 @@ class CheckboxCardsItem(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "CheckboxCardsItem":
"""Create a new component instance.
diff --git a/reflex/components/radix/themes/components/checkbox_group.py b/reflex/components/radix/themes/components/checkbox_group.py
index 754f354b5..f6379e588 100644
--- a/reflex/components/radix/themes/components/checkbox_group.py
+++ b/reflex/components/radix/themes/components/checkbox_group.py
@@ -4,7 +4,7 @@ from types import SimpleNamespace
from typing import List, Literal
from reflex.components.core.breakpoints import Responsive
-from reflex.vars import Var
+from reflex.vars.base import Var
from ..base import LiteralAccentColor, RadixThemesComponent
diff --git a/reflex/components/radix/themes/components/checkbox_group.pyi b/reflex/components/radix/themes/components/checkbox_group.pyi
index 334ee3dd3..ffeeb75cf 100644
--- a/reflex/components/radix/themes/components/checkbox_group.pyi
+++ b/reflex/components/radix/themes/components/checkbox_group.pyi
@@ -4,12 +4,12 @@
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
from types import SimpleNamespace
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -21,137 +21,107 @@ class CheckboxGroupRoot(RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
- default_value: Optional[Union[Var[List[str]], List[str]]] = None,
+ default_value: Optional[Union[List[str], Var[List[str]]]] = None,
name: Optional[Union[Var[str], str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "CheckboxGroupRoot":
"""Create a new component instance.
@@ -193,52 +163,22 @@ class CheckboxGroupItem(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "CheckboxGroupItem":
"""Create a new component instance.
diff --git a/reflex/components/radix/themes/components/context_menu.py b/reflex/components/radix/themes/components/context_menu.py
index 95a0f2e74..f8512a902 100644
--- a/reflex/components/radix/themes/components/context_menu.py
+++ b/reflex/components/radix/themes/components/context_menu.py
@@ -1,16 +1,29 @@
"""Interactive components provided by @radix-ui/themes."""
-from typing import List, Literal
+from typing import Dict, List, Literal, Union
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- RadixThemesComponent,
-)
+from ..base import LiteralAccentColor, RadixThemesComponent
+from .checkbox import Checkbox
+
+LiteralDirType = Literal["ltr", "rtl"]
+
+LiteralSizeType = Literal["1", "2"]
+
+LiteralVariantType = Literal["solid", "soft"]
+
+LiteralSideType = Literal["top", "right", "bottom", "left"]
+
+LiteralAlignType = Literal["start", "center", "end"]
+
+LiteralStickyType = Literal[
+ "partial",
+ "always",
+]
class ContextMenuRoot(RadixThemesComponent):
@@ -24,7 +37,10 @@ class ContextMenuRoot(RadixThemesComponent):
_invalid_children: List[str] = ["ContextMenuItem"]
# Fired when the open state changes.
- on_open_change: EventHandler[lambda e0: [e0]]
+ on_open_change: EventHandler[passthrough_event_spec(bool)]
+
+ # The reading direction of submenus when applicable. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode.
+ dir: Var[LiteralDirType]
class ContextMenuTrigger(RadixThemesComponent):
@@ -45,38 +61,65 @@ class ContextMenuContent(RadixThemesComponent):
tag = "ContextMenu.Content"
- # Button size "1" - "4"
- size: Var[Responsive[Literal["1", "2"]]]
+ # Dropdown Menu Content size "1" - "2"
+ size: Var[Responsive[LiteralSizeType]]
- # Variant of button: "solid" | "soft" | "outline" | "ghost"
- variant: Var[Literal["solid", "soft"]]
+ # Variant of Dropdown Menu Content: "solid" | "soft"
+ variant: Var[LiteralVariantType]
- # Override theme color for button
+ # Override theme color for Dropdown Menu Content
color_scheme: Var[LiteralAccentColor]
- # Whether to render the button with higher contrast color against background
+ # Renders the Dropdown Menu Content in higher contrast
high_contrast: Var[bool]
- # The vertical distance in pixels from the anchor.
- align_offset: Var[int]
+ # Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
+ as_child: Var[bool]
- # When true, overrides the side and aligns preferences to prevent collisions with boundary edges.
+ # When True, keyboard navigation will loop from last item to first, and vice versa. Defaults to False.
+ loop: Var[bool]
+
+ # Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
+ force_mount: Var[bool]
+
+ # The preferred side of the trigger to render against when open. Will be reversed when collisions occur and `avoid_collisions` is enabled.The position of the tooltip. Defaults to "top".
+ side: Var[LiteralSideType]
+
+ # The distance in pixels from the trigger. Defaults to 0.
+ side_offset: Var[Union[float, int]]
+
+ # The preferred alignment against the trigger. May change when collisions occur. Defaults to "center".
+ align: Var[LiteralAlignType]
+
+ # An offset in pixels from the "start" or "end" alignment options.
+ align_offset: Var[Union[float, int]]
+
+ # When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True.
avoid_collisions: Var[bool]
- # Fired when the context menu is closed.
- on_close_auto_focus: EventHandler[lambda e0: [e0]]
+ # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
+ collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]]
+
+ # The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
+ sticky: Var[LiteralStickyType]
+
+ # Whether to hide the content when the trigger becomes fully occluded. Defaults to False.
+ hide_when_detached: Var[bool]
+
+ # Fired when focus moves back after closing.
+ on_close_auto_focus: EventHandler[no_args_event_spec]
# Fired when the escape key is pressed.
- on_escape_key_down: EventHandler[lambda e0: [e0]]
+ on_escape_key_down: EventHandler[no_args_event_spec]
# Fired when a pointer down event happens outside the context menu.
- on_pointer_down_outside: EventHandler[lambda e0: [e0]]
+ on_pointer_down_outside: EventHandler[no_args_event_spec]
# Fired when focus moves outside the context menu.
- on_focus_outside: EventHandler[lambda e0: [e0]]
+ on_focus_outside: EventHandler[no_args_event_spec]
- # Fired when interacting outside the context menu.
- on_interact_outside: EventHandler[lambda e0: [e0]]
+ # Fired when the pointer interacts outside the context menu.
+ on_interact_outside: EventHandler[no_args_event_spec]
class ContextMenuSub(RadixThemesComponent):
@@ -84,15 +127,30 @@ class ContextMenuSub(RadixThemesComponent):
tag = "ContextMenu.Sub"
+ # The controlled open state of the submenu. Must be used in conjunction with `on_open_change`.
+ open: Var[bool]
+
+ # The open state of the submenu when it is initially rendered. Use when you do not need to control its open state.
+ default_open: Var[bool]
+
+ # Fired when the open state changes.
+ on_open_change: EventHandler[passthrough_event_spec(bool)]
+
class ContextMenuSubTrigger(RadixThemesComponent):
"""An item that opens a submenu."""
tag = "ContextMenu.SubTrigger"
+ # Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
+ as_child: Var[bool]
+
# Whether the trigger is disabled
disabled: Var[bool]
+ # Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item. Use this when the content is complex, or you have non-textual content inside.
+ text_value: Var[str]
+
_valid_parents: List[str] = ["ContextMenuContent", "ContextMenuSub"]
@@ -101,22 +159,46 @@ class ContextMenuSubContent(RadixThemesComponent):
tag = "ContextMenu.SubContent"
- # When true, keyboard navigation will loop from last item to first, and vice versa.
+ # Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
+ as_child: Var[bool]
+
+ # When True, keyboard navigation will loop from last item to first, and vice versa. Defaults to False.
loop: Var[bool]
+ # Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
+ force_mount: Var[bool]
+
+ # The distance in pixels from the trigger. Defaults to 0.
+ side_offset: Var[Union[float, int]]
+
+ # An offset in pixels from the "start" or "end" alignment options.
+ align_offset: Var[Union[float, int]]
+
+ # When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True.
+ avoid_collisions: Var[bool]
+
+ # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
+ collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]]
+
+ # The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
+ sticky: Var[LiteralStickyType]
+
+ # Whether to hide the content when the trigger becomes fully occluded. Defaults to False.
+ hide_when_detached: Var[bool]
+
_valid_parents: List[str] = ["ContextMenuSub"]
# Fired when the escape key is pressed.
- on_escape_key_down: EventHandler[lambda e0: [e0]]
+ on_escape_key_down: EventHandler[no_args_event_spec]
# Fired when a pointer down event happens outside the context menu.
- on_pointer_down_outside: EventHandler[lambda e0: [e0]]
+ on_pointer_down_outside: EventHandler[no_args_event_spec]
# Fired when focus moves outside the context menu.
- on_focus_outside: EventHandler[lambda e0: [e0]]
+ on_focus_outside: EventHandler[no_args_event_spec]
# Fired when interacting outside the context menu.
- on_interact_outside: EventHandler[lambda e0: [e0]]
+ on_interact_outside: EventHandler[no_args_event_spec]
class ContextMenuItem(RadixThemesComponent):
@@ -130,8 +212,20 @@ class ContextMenuItem(RadixThemesComponent):
# Shortcut to render a menu item as a link
shortcut: Var[str]
+ # Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
+ as_child: Var[bool]
+
+ # When true, prevents the user from interacting with the item.
+ disabled: Var[bool]
+
+ # Optional text used for typeahead purposes. By default the typeahead behavior will use the content of the item. Use this when the content is complex, or you have non-textual content inside.
+ text_value: Var[str]
+
_valid_parents: List[str] = ["ContextMenuContent", "ContextMenuSubContent"]
+ # Fired when the item is selected.
+ on_select: EventHandler[no_args_event_spec]
+
class ContextMenuSeparator(RadixThemesComponent):
"""Separates items in a context menu."""
@@ -139,6 +233,15 @@ class ContextMenuSeparator(RadixThemesComponent):
tag = "ContextMenu.Separator"
+class ContextMenuCheckbox(Checkbox):
+ """The component that contains the checkbox."""
+
+ tag = "ContextMenu.CheckboxItem"
+
+ # Text to render as shortcut.
+ shortcut: Var[str]
+
+
class ContextMenu(ComponentNamespace):
"""Menu representing a set of actions, displayed at the origin of a pointer right-click or long-press."""
@@ -150,6 +253,7 @@ class ContextMenu(ComponentNamespace):
sub_content = staticmethod(ContextMenuSubContent.create)
item = staticmethod(ContextMenuItem.create)
separator = staticmethod(ContextMenuSeparator.create)
+ checkbox = staticmethod(ContextMenuCheckbox.create)
context_menu = ContextMenu()
diff --git a/reflex/components/radix/themes/components/context_menu.pyi b/reflex/components/radix/themes/components/context_menu.pyi
index dbe23ee81..2d3ffbebc 100644
--- a/reflex/components/radix/themes/components/context_menu.pyi
+++ b/reflex/components/radix/themes/components/context_menu.pyi
@@ -3,15 +3,23 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
+from .checkbox import Checkbox
+
+LiteralDirType = Literal["ltr", "rtl"]
+LiteralSizeType = Literal["1", "2"]
+LiteralVariantType = Literal["solid", "soft"]
+LiteralSideType = Literal["top", "right", "bottom", "left"]
+LiteralAlignType = Literal["start", "center", "end"]
+LiteralStickyType = Literal["partial", "always"]
class ContextMenuRoot(RadixThemesComponent):
@overload
@@ -20,60 +28,31 @@ class ContextMenuRoot(RadixThemesComponent):
cls,
*children,
modal: Optional[Union[Var[bool], bool]] = None,
+ dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ContextMenuRoot":
"""Create a new component instance.
@@ -84,6 +63,8 @@ class ContextMenuRoot(RadixThemesComponent):
Args:
*children: Child components.
modal: The modality of the context menu. When set to true, interaction with outside elements will be disabled and only menu content will be visible to screen readers.
+ on_open_change: Fired when the open state changes.
+ dir: The reading direction of submenus when applicable. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -109,52 +90,22 @@ class ContextMenuTrigger(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ContextMenuTrigger":
"""Create a new component instance.
@@ -186,145 +137,133 @@ class ContextMenuContent(RadixThemesComponent):
*children,
size: Optional[
Union[
- Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]],
- Literal["1", "2"],
Breakpoints[str, Literal["1", "2"]],
+ Literal["1", "2"],
+ Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]],
]
] = None,
variant: Optional[
- Union[Var[Literal["solid", "soft"]], Literal["solid", "soft"]]
+ Union[Literal["soft", "solid"], Var[Literal["soft", "solid"]]]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
- align_offset: Optional[Union[Var[int], int]] = None,
+ as_child: Optional[Union[Var[bool], bool]] = None,
+ loop: Optional[Union[Var[bool], bool]] = None,
+ force_mount: Optional[Union[Var[bool], bool]] = None,
+ side: Optional[
+ Union[
+ Literal["bottom", "left", "right", "top"],
+ Var[Literal["bottom", "left", "right", "top"]],
+ ]
+ ] = None,
+ side_offset: Optional[Union[Var[Union[float, int]], float, int]] = None,
+ align: Optional[
+ Union[
+ Literal["center", "end", "start"],
+ Var[Literal["center", "end", "start"]],
+ ]
+ ] = None,
+ align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None,
avoid_collisions: Optional[Union[Var[bool], bool]] = None,
+ collision_padding: Optional[
+ Union[
+ Dict[str, Union[float, int]],
+ Var[Union[Dict[str, Union[float, int]], float, int]],
+ float,
+ int,
+ ]
+ ] = None,
+ sticky: Optional[
+ Union[Literal["always", "partial"], Var[Literal["always", "partial"]]]
+ ] = None,
+ hide_when_detached: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close_auto_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_escape_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_interact_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_pointer_down_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_interact_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ContextMenuContent":
"""Create a new component instance.
@@ -334,12 +273,26 @@ class ContextMenuContent(RadixThemesComponent):
Args:
*children: Child components.
- size: Button size "1" - "4"
- variant: Variant of button: "solid" | "soft" | "outline" | "ghost"
- color_scheme: Override theme color for button
- high_contrast: Whether to render the button with higher contrast color against background
- align_offset: The vertical distance in pixels from the anchor.
- avoid_collisions: When true, overrides the side and aligns preferences to prevent collisions with boundary edges.
+ size: Dropdown Menu Content size "1" - "2"
+ variant: Variant of Dropdown Menu Content: "solid" | "soft"
+ color_scheme: Override theme color for Dropdown Menu Content
+ high_contrast: Renders the Dropdown Menu Content in higher contrast
+ as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
+ loop: When True, keyboard navigation will loop from last item to first, and vice versa. Defaults to False.
+ force_mount: Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
+ side: The preferred side of the trigger to render against when open. Will be reversed when collisions occur and `avoid_collisions` is enabled.The position of the tooltip. Defaults to "top".
+ side_offset: The distance in pixels from the trigger. Defaults to 0.
+ align: The preferred alignment against the trigger. May change when collisions occur. Defaults to "center".
+ align_offset: An offset in pixels from the "start" or "end" alignment options.
+ avoid_collisions: When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True.
+ collision_padding: The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
+ sticky: The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
+ hide_when_detached: Whether to hide the content when the trigger becomes fully occluded. Defaults to False.
+ on_close_auto_focus: Fired when focus moves back after closing.
+ on_escape_key_down: Fired when the escape key is pressed.
+ on_pointer_down_outside: Fired when a pointer down event happens outside the context menu.
+ on_focus_outside: Fired when focus moves outside the context menu.
+ on_interact_outside: Fired when the pointer interacts outside the context menu.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -359,57 +312,32 @@ class ContextMenuSub(RadixThemesComponent):
def create( # type: ignore
cls,
*children,
+ open: Optional[Union[Var[bool], bool]] = None,
+ default_open: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_open_change: Optional[
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ContextMenuSub":
"""Create a new component instance.
@@ -419,6 +347,9 @@ class ContextMenuSub(RadixThemesComponent):
Args:
*children: Child components.
+ open: The controlled open state of the submenu. Must be used in conjunction with `on_open_change`.
+ default_open: The open state of the submenu when it is initially rendered. Use when you do not need to control its open state.
+ on_open_change: Fired when the open state changes.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -438,58 +369,30 @@ class ContextMenuSubTrigger(RadixThemesComponent):
def create( # type: ignore
cls,
*children,
+ as_child: Optional[Union[Var[bool], bool]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
+ text_value: Optional[Union[Var[str], str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ContextMenuSubTrigger":
"""Create a new component instance.
@@ -499,7 +402,9 @@ class ContextMenuSubTrigger(RadixThemesComponent):
Args:
*children: Child components.
+ as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
disabled: Whether the trigger is disabled
+ text_value: Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item. Use this when the content is complex, or you have non-textual content inside.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -519,70 +424,49 @@ class ContextMenuSubContent(RadixThemesComponent):
def create( # type: ignore
cls,
*children,
+ as_child: Optional[Union[Var[bool], bool]] = None,
loop: Optional[Union[Var[bool], bool]] = None,
+ force_mount: Optional[Union[Var[bool], bool]] = None,
+ side_offset: Optional[Union[Var[Union[float, int]], float, int]] = None,
+ align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None,
+ avoid_collisions: Optional[Union[Var[bool], bool]] = None,
+ collision_padding: Optional[
+ Union[
+ Dict[str, Union[float, int]],
+ Var[Union[Dict[str, Union[float, int]], float, int]],
+ float,
+ int,
+ ]
+ ] = None,
+ sticky: Optional[
+ Union[Literal["always", "partial"], Var[Literal["always", "partial"]]]
+ ] = None,
+ hide_when_detached: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_escape_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_interact_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_pointer_down_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_interact_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ContextMenuSubContent":
"""Create a new component instance.
@@ -592,7 +476,19 @@ class ContextMenuSubContent(RadixThemesComponent):
Args:
*children: Child components.
- loop: When true, keyboard navigation will loop from last item to first, and vice versa.
+ as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
+ loop: When True, keyboard navigation will loop from last item to first, and vice versa. Defaults to False.
+ force_mount: Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
+ side_offset: The distance in pixels from the trigger. Defaults to 0.
+ align_offset: An offset in pixels from the "start" or "end" alignment options.
+ avoid_collisions: When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True.
+ collision_padding: The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
+ sticky: The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
+ hide_when_detached: Whether to hide the content when the trigger becomes fully occluded. Defaults to False.
+ on_escape_key_down: Fired when the escape key is pressed.
+ on_pointer_down_outside: Fired when a pointer down event happens outside the context menu.
+ on_focus_outside: Fired when focus moves outside the context menu.
+ on_interact_outside: Fired when interacting outside the context menu.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -614,118 +510,92 @@ class ContextMenuItem(RadixThemesComponent):
*children,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
shortcut: Optional[Union[Var[str], str]] = None,
+ as_child: Optional[Union[Var[bool], bool]] = None,
+ disabled: Optional[Union[Var[bool], bool]] = None,
+ text_value: Optional[Union[Var[str], str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_select: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ContextMenuItem":
"""Create a new component instance.
@@ -737,6 +607,10 @@ class ContextMenuItem(RadixThemesComponent):
*children: Child components.
color_scheme: Override theme color for button
shortcut: Shortcut to render a menu item as a link
+ as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
+ disabled: When true, prevents the user from interacting with the item.
+ text_value: Optional text used for typeahead purposes. By default the typeahead behavior will use the content of the item. Use this when the content is complex, or you have non-textual content inside.
+ on_select: Fired when the item is selected.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -761,52 +635,22 @@ class ContextMenuSeparator(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ContextMenuSeparator":
"""Create a new component instance.
@@ -829,6 +673,159 @@ class ContextMenuSeparator(RadixThemesComponent):
"""
...
+class ContextMenuCheckbox(Checkbox):
+ @overload
+ @classmethod
+ def create( # type: ignore
+ cls,
+ *children,
+ shortcut: Optional[Union[Var[str], str]] = None,
+ as_child: Optional[Union[Var[bool], bool]] = None,
+ size: Optional[
+ Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
+ Var[
+ Union[
+ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
+ ]
+ ],
+ ]
+ ] = None,
+ variant: Optional[
+ Union[
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
+ ]
+ ] = None,
+ color_scheme: Optional[
+ Union[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
+ ],
+ ]
+ ] = None,
+ high_contrast: Optional[Union[Var[bool], bool]] = None,
+ default_checked: Optional[Union[Var[bool], bool]] = None,
+ checked: Optional[Union[Var[bool], bool]] = None,
+ disabled: Optional[Union[Var[bool], bool]] = None,
+ required: Optional[Union[Var[bool], bool]] = None,
+ name: Optional[Union[Var[str], str]] = None,
+ value: Optional[Union[Var[str], str]] = None,
+ style: Optional[Style] = None,
+ key: Optional[Any] = None,
+ id: Optional[Any] = None,
+ class_name: Optional[Any] = None,
+ autofocus: Optional[bool] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_change: Optional[
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
+ ] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
+ **props,
+ ) -> "ContextMenuCheckbox":
+ """Create a new component instance.
+
+ Will prepend "RadixThemes" to the component tag to avoid conflicts with
+ other UI libraries for common names, like Text and Button.
+
+ Args:
+ *children: Child components.
+ shortcut: Text to render as shortcut.
+ as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
+ size: Checkbox size "1" - "3"
+ variant: Variant of checkbox: "classic" | "surface" | "soft"
+ color_scheme: Override theme color for checkbox
+ high_contrast: Whether to render the checkbox with higher contrast color against background
+ default_checked: Whether the checkbox is checked by default
+ checked: Whether the checkbox is checked
+ disabled: Whether the checkbox is disabled
+ required: Whether the checkbox is required
+ name: The name of the checkbox control when submitting the form.
+ value: The value of the checkbox control when submitting the form.
+ on_change: Fired when the checkbox is checked or unchecked.
+ style: The style of the component.
+ key: A unique key for the component.
+ id: The id for the component.
+ class_name: The class name for the component.
+ autofocus: Whether the component should take the focus once the page is loaded
+ custom_attrs: custom attribute
+ **props: Component properties.
+
+ Returns:
+ A new component instance.
+ """
+ ...
+
class ContextMenu(ComponentNamespace):
root = staticmethod(ContextMenuRoot.create)
trigger = staticmethod(ContextMenuTrigger.create)
@@ -838,5 +835,6 @@ class ContextMenu(ComponentNamespace):
sub_content = staticmethod(ContextMenuSubContent.create)
item = staticmethod(ContextMenuItem.create)
separator = staticmethod(ContextMenuSeparator.create)
+ checkbox = staticmethod(ContextMenuCheckbox.create)
context_menu = ContextMenu()
diff --git a/reflex/components/radix/themes/components/data_list.py b/reflex/components/radix/themes/components/data_list.py
index e5ce75464..05d4af074 100644
--- a/reflex/components/radix/themes/components/data_list.py
+++ b/reflex/components/radix/themes/components/data_list.py
@@ -4,7 +4,7 @@ from types import SimpleNamespace
from typing import Literal
from reflex.components.core.breakpoints import Responsive
-from reflex.vars import Var
+from reflex.vars.base import Var
from ..base import LiteralAccentColor, RadixThemesComponent
@@ -29,6 +29,7 @@ class DataListItem(RadixThemesComponent):
tag = "DataList.Item"
+ # The alignment of the data list item within its container.
align: Var[Responsive[Literal["start", "center", "end", "baseline", "stretch"]]]
@@ -37,12 +38,16 @@ class DataListLabel(RadixThemesComponent):
tag = "DataList.Label"
+ # The width of the component
width: Var[Responsive[str]]
+ # The minimum width of the component
min_width: Var[Responsive[str]]
+ # The maximum width of the component
max_width: Var[Responsive[str]]
+ # The color scheme for the DataList component.
color_scheme: Var[LiteralAccentColor]
diff --git a/reflex/components/radix/themes/components/data_list.pyi b/reflex/components/radix/themes/components/data_list.pyi
index 4fe0541a2..3b409363b 100644
--- a/reflex/components/radix/themes/components/data_list.pyi
+++ b/reflex/components/radix/themes/components/data_list.pyi
@@ -4,12 +4,12 @@
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
from types import SimpleNamespace
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -21,37 +21,37 @@ class DataListRoot(RadixThemesComponent):
*children,
orientation: Optional[
Union[
+ Breakpoints[str, Literal["horizontal", "vertical"]],
+ Literal["horizontal", "vertical"],
Var[
Union[
Breakpoints[str, Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
]
],
- Literal["horizontal", "vertical"],
- Breakpoints[str, Literal["horizontal", "vertical"]],
]
] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
trim: Optional[
Union[
+ Breakpoints[str, Literal["both", "end", "normal", "start"]],
+ Literal["both", "end", "normal", "start"],
Var[
Union[
- Breakpoints[str, Literal["normal", "start", "end", "both"]],
- Literal["normal", "start", "end", "both"],
+ Breakpoints[str, Literal["both", "end", "normal", "start"]],
+ Literal["both", "end", "normal", "start"],
]
],
- Literal["normal", "start", "end", "both"],
- Breakpoints[str, Literal["normal", "start", "end", "both"]],
]
] = None,
style: Optional[Style] = None,
@@ -59,52 +59,22 @@ class DataListRoot(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DataListRoot":
"""Create a new component instance.
@@ -138,19 +108,19 @@ class DataListItem(RadixThemesComponent):
*children,
align: Optional[
Union[
+ Breakpoints[
+ str, Literal["baseline", "center", "end", "start", "stretch"]
+ ],
+ Literal["baseline", "center", "end", "start", "stretch"],
Var[
Union[
Breakpoints[
str,
- Literal["start", "center", "end", "baseline", "stretch"],
+ Literal["baseline", "center", "end", "start", "stretch"],
],
- Literal["start", "center", "end", "baseline", "stretch"],
+ Literal["baseline", "center", "end", "start", "stretch"],
]
],
- Literal["start", "center", "end", "baseline", "stretch"],
- Breakpoints[
- str, Literal["start", "center", "end", "baseline", "stretch"]
- ],
]
] = None,
style: Optional[Style] = None,
@@ -158,52 +128,22 @@ class DataListItem(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DataListItem":
"""Create a new component instance.
@@ -213,6 +153,7 @@ class DataListItem(RadixThemesComponent):
Args:
*children: Child components.
+ align: The alignment of the data list item within its container.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -233,73 +174,73 @@ class DataListLabel(RadixThemesComponent):
cls,
*children,
width: Optional[
- Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]]
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
] = None,
min_width: Optional[
- Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]]
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
] = None,
max_width: Optional[
- Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]]
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -308,52 +249,22 @@ class DataListLabel(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DataListLabel":
"""Create a new component instance.
@@ -363,6 +274,10 @@ class DataListLabel(RadixThemesComponent):
Args:
*children: Child components.
+ width: The width of the component
+ min_width: The minimum width of the component
+ max_width: The maximum width of the component
+ color_scheme: The color scheme for the DataList component.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -387,52 +302,22 @@ class DataListValue(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DataListValue":
"""Create a new component instance.
diff --git a/reflex/components/radix/themes/components/dialog.py b/reflex/components/radix/themes/components/dialog.py
index e0d7fae12..1b7c3b532 100644
--- a/reflex/components/radix/themes/components/dialog.py
+++ b/reflex/components/radix/themes/components/dialog.py
@@ -5,13 +5,10 @@ from typing import Literal
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec
+from reflex.vars.base import Var
-from ..base import (
- RadixThemesComponent,
- RadixThemesTriggerComponent,
-)
+from ..base import RadixThemesComponent, RadixThemesTriggerComponent
class DialogRoot(RadixThemesComponent):
@@ -23,7 +20,10 @@ class DialogRoot(RadixThemesComponent):
open: Var[bool]
# Fired when the open state changes.
- on_open_change: EventHandler[lambda e0: [e0]]
+ on_open_change: EventHandler[passthrough_event_spec(bool)]
+
+ # The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.
+ default_open: Var[bool]
class DialogTrigger(RadixThemesTriggerComponent):
@@ -47,19 +47,19 @@ class DialogContent(elements.Div, RadixThemesComponent):
size: Var[Responsive[Literal["1", "2", "3", "4"]]]
# Fired when the dialog is opened.
- on_open_auto_focus: EventHandler[lambda e0: [e0]]
+ on_open_auto_focus: EventHandler[no_args_event_spec]
# Fired when the dialog is closed.
- on_close_auto_focus: EventHandler[lambda e0: [e0]]
+ on_close_auto_focus: EventHandler[no_args_event_spec]
# Fired when the escape key is pressed.
- on_escape_key_down: EventHandler[lambda e0: [e0]]
+ on_escape_key_down: EventHandler[no_args_event_spec]
# Fired when the pointer is down outside the dialog.
- on_pointer_down_outside: EventHandler[lambda e0: [e0]]
+ on_pointer_down_outside: EventHandler[no_args_event_spec]
# Fired when the pointer interacts outside the dialog.
- on_interact_outside: EventHandler[lambda e0: [e0]]
+ on_interact_outside: EventHandler[no_args_event_spec]
class DialogDescription(RadixThemesComponent):
diff --git a/reflex/components/radix/themes/components/dialog.pyi b/reflex/components/radix/themes/components/dialog.pyi
index 0f05ca406..b1dfc1b54 100644
--- a/reflex/components/radix/themes/components/dialog.pyi
+++ b/reflex/components/radix/themes/components/dialog.pyi
@@ -3,14 +3,14 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent, RadixThemesTriggerComponent
@@ -21,60 +21,31 @@ class DialogRoot(RadixThemesComponent):
cls,
*children,
open: Optional[Union[Var[bool], bool]] = None,
+ default_open: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DialogRoot":
"""Create a new component instance.
@@ -85,6 +56,8 @@ class DialogRoot(RadixThemesComponent):
Args:
*children: Child components.
open: The controlled open state of the dialog.
+ on_open_change: Fired when the open state changes.
+ default_open: The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -109,52 +82,22 @@ class DialogTrigger(RadixThemesTriggerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DialogTrigger":
"""Create a new RadixThemesTriggerComponent instance.
@@ -179,52 +122,22 @@ class DialogTitle(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DialogTitle":
"""Create a new component instance.
@@ -255,106 +168,66 @@ class DialogContent(elements.Div, RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4"]],
+ Literal["1", "2", "3", "4"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3", "4"]],
Literal["1", "2", "3", "4"],
]
],
- Literal["1", "2", "3", "4"],
- Breakpoints[str, Literal["1", "2", "3", "4"]],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close_auto_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_escape_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_interact_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_open_auto_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_pointer_down_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_interact_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_open_auto_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DialogContent":
"""Create a new component instance.
@@ -365,7 +238,12 @@ class DialogContent(elements.Div, RadixThemesComponent):
Args:
*children: Child components.
size: DialogContent size "1" - "4"
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ on_open_auto_focus: Fired when the dialog is opened.
+ on_close_auto_focus: Fired when the dialog is closed.
+ on_escape_key_down: Fired when the escape key is pressed.
+ on_pointer_down_outside: Fired when the pointer is down outside the dialog.
+ on_interact_outside: Fired when the pointer interacts outside the dialog.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -405,52 +283,22 @@ class DialogDescription(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DialogDescription":
"""Create a new component instance.
@@ -484,52 +332,22 @@ class DialogClose(RadixThemesTriggerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DialogClose":
"""Create a new RadixThemesTriggerComponent instance.
@@ -555,60 +373,31 @@ class Dialog(ComponentNamespace):
def __call__(
*children,
open: Optional[Union[Var[bool], bool]] = None,
+ default_open: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DialogRoot":
"""Create a new component instance.
@@ -619,6 +408,8 @@ class Dialog(ComponentNamespace):
Args:
*children: Child components.
open: The controlled open state of the dialog.
+ on_open_change: Fired when the open state changes.
+ default_open: The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/radix/themes/components/dropdown_menu.py b/reflex/components/radix/themes/components/dropdown_menu.py
index b425ef609..abce3e3bb 100644
--- a/reflex/components/radix/themes/components/dropdown_menu.py
+++ b/reflex/components/radix/themes/components/dropdown_menu.py
@@ -4,14 +4,10 @@ from typing import Dict, List, Literal, Union
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- RadixThemesComponent,
- RadixThemesTriggerComponent,
-)
+from ..base import LiteralAccentColor, RadixThemesComponent, RadixThemesTriggerComponent
LiteralDirType = Literal["ltr", "rtl"]
@@ -23,7 +19,6 @@ LiteralSideType = Literal["top", "right", "bottom", "left"]
LiteralAlignType = Literal["start", "center", "end"]
-
LiteralStickyType = Literal[
"partial",
"always",
@@ -50,7 +45,7 @@ class DropdownMenuRoot(RadixThemesComponent):
_invalid_children: List[str] = ["DropdownMenuItem"]
# Fired when the open state changes.
- on_open_change: EventHandler[lambda e0: [e0]]
+ on_open_change: EventHandler[passthrough_event_spec(bool)]
class DropdownMenuTrigger(RadixThemesTriggerComponent):
@@ -110,9 +105,6 @@ class DropdownMenuContent(RadixThemesComponent):
# The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]]
- # The padding between the arrow and the edges of the content. If your content has border-radius, this will prevent it from overflowing the corners. Defaults to 0.
- arrow_padding: Var[Union[float, int]]
-
# The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
sticky: Var[LiteralStickyType]
@@ -120,19 +112,19 @@ class DropdownMenuContent(RadixThemesComponent):
hide_when_detached: Var[bool]
# Fired when the dialog is closed.
- on_close_auto_focus: EventHandler[lambda e0: [e0]]
+ on_close_auto_focus: EventHandler[no_args_event_spec]
# Fired when the escape key is pressed.
- on_escape_key_down: EventHandler[lambda e0: [e0]]
+ on_escape_key_down: EventHandler[no_args_event_spec]
# Fired when the pointer is down outside the dialog.
- on_pointer_down_outside: EventHandler[lambda e0: [e0]]
+ on_pointer_down_outside: EventHandler[no_args_event_spec]
# Fired when focus moves outside the dialog.
- on_focus_outside: EventHandler[lambda e0: [e0]]
+ on_focus_outside: EventHandler[no_args_event_spec]
# Fired when the pointer interacts outside the dialog.
- on_interact_outside: EventHandler[lambda e0: [e0]]
+ on_interact_outside: EventHandler[no_args_event_spec]
class DropdownMenuSubTrigger(RadixThemesTriggerComponent):
@@ -164,7 +156,7 @@ class DropdownMenuSub(RadixThemesComponent):
default_open: Var[bool]
# Fired when the open state changes.
- on_open_change: EventHandler[lambda e0: [e0.target.value]]
+ on_open_change: EventHandler[passthrough_event_spec(bool)]
class DropdownMenuSubContent(RadixThemesComponent):
@@ -193,9 +185,6 @@ class DropdownMenuSubContent(RadixThemesComponent):
# The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]]
- # The padding between the arrow and the edges of the content. If your content has border-radius, this will prevent it from overflowing the corners. Defaults to 0.
- arrow_padding: Var[Union[float, int]]
-
# The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
sticky: Var[LiteralStickyType]
@@ -205,16 +194,16 @@ class DropdownMenuSubContent(RadixThemesComponent):
_valid_parents: List[str] = ["DropdownMenuSub"]
# Fired when the escape key is pressed.
- on_escape_key_down: EventHandler[lambda e0: [e0]]
+ on_escape_key_down: EventHandler[no_args_event_spec]
# Fired when the pointer is down outside the dialog.
- on_pointer_down_outside: EventHandler[lambda e0: [e0]]
+ on_pointer_down_outside: EventHandler[no_args_event_spec]
# Fired when focus moves outside the dialog.
- on_focus_outside: EventHandler[lambda e0: [e0]]
+ on_focus_outside: EventHandler[no_args_event_spec]
# Fired when the pointer interacts outside the dialog.
- on_interact_outside: EventHandler[lambda e0: [e0]]
+ on_interact_outside: EventHandler[no_args_event_spec]
class DropdownMenuItem(RadixThemesComponent):
@@ -240,7 +229,7 @@ class DropdownMenuItem(RadixThemesComponent):
_valid_parents: List[str] = ["DropdownMenuContent", "DropdownMenuSubContent"]
# Fired when the item is selected.
- on_select: EventHandler[lambda e0: [e0.target.value]]
+ on_select: EventHandler[no_args_event_spec]
class DropdownMenuSeparator(RadixThemesComponent):
diff --git a/reflex/components/radix/themes/components/dropdown_menu.pyi b/reflex/components/radix/themes/components/dropdown_menu.pyi
index d2b9216e1..96c624f89 100644
--- a/reflex/components/radix/themes/components/dropdown_menu.pyi
+++ b/reflex/components/radix/themes/components/dropdown_menu.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent, RadixThemesTriggerComponent
@@ -29,61 +29,31 @@ class DropdownMenuRoot(RadixThemesComponent):
default_open: Optional[Union[Var[bool], bool]] = None,
open: Optional[Union[Var[bool], bool]] = None,
modal: Optional[Union[Var[bool], bool]] = None,
- dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None,
+ dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DropdownMenuRoot":
"""Create a new component instance.
@@ -97,6 +67,7 @@ class DropdownMenuRoot(RadixThemesComponent):
open: The controlled open state of the dropdown menu. Must be used in conjunction with onOpenChange.
modal: The modality of the dropdown menu. When set to true, interaction with outside elements will be disabled and only menu content will be visible to screen readers. Defaults to True.
dir: The reading direction of submenus when applicable. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode.
+ on_open_change: Fired when the open state changes.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -122,52 +93,22 @@ class DropdownMenuTrigger(RadixThemesTriggerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DropdownMenuTrigger":
"""Create a new RadixThemesTriggerComponent instance.
@@ -189,73 +130,73 @@ class DropdownMenuContent(RadixThemesComponent):
*children,
size: Optional[
Union[
- Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]],
- Literal["1", "2"],
Breakpoints[str, Literal["1", "2"]],
+ Literal["1", "2"],
+ Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]],
]
] = None,
variant: Optional[
- Union[Var[Literal["solid", "soft"]], Literal["solid", "soft"]]
+ Union[Literal["soft", "solid"], Var[Literal["soft", "solid"]]]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -265,30 +206,29 @@ class DropdownMenuContent(RadixThemesComponent):
force_mount: Optional[Union[Var[bool], bool]] = None,
side: Optional[
Union[
- Var[Literal["top", "right", "bottom", "left"]],
- Literal["top", "right", "bottom", "left"],
+ Literal["bottom", "left", "right", "top"],
+ Var[Literal["bottom", "left", "right", "top"]],
]
] = None,
side_offset: Optional[Union[Var[Union[float, int]], float, int]] = None,
align: Optional[
Union[
- Var[Literal["start", "center", "end"]],
- Literal["start", "center", "end"],
+ Literal["center", "end", "start"],
+ Var[Literal["center", "end", "start"]],
]
] = None,
align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None,
avoid_collisions: Optional[Union[Var[bool], bool]] = None,
collision_padding: Optional[
Union[
+ Dict[str, Union[float, int]],
Var[Union[Dict[str, Union[float, int]], float, int]],
float,
int,
- Dict[str, Union[float, int]],
]
] = None,
- arrow_padding: Optional[Union[Var[Union[float, int]], float, int]] = None,
sticky: Optional[
- Union[Var[Literal["partial", "always"]], Literal["partial", "always"]]
+ Union[Literal["always", "partial"], Var[Literal["always", "partial"]]]
] = None,
hide_when_detached: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
@@ -296,67 +236,27 @@ class DropdownMenuContent(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close_auto_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_escape_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_interact_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_pointer_down_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_interact_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DropdownMenuContent":
"""Create a new component instance.
@@ -379,9 +279,13 @@ class DropdownMenuContent(RadixThemesComponent):
align_offset: An offset in pixels from the "start" or "end" alignment options.
avoid_collisions: When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True.
collision_padding: The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
- arrow_padding: The padding between the arrow and the edges of the content. If your content has border-radius, this will prevent it from overflowing the corners. Defaults to 0.
sticky: The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
hide_when_detached: Whether to hide the content when the trigger becomes fully occluded. Defaults to False.
+ on_close_auto_focus: Fired when the dialog is closed.
+ on_escape_key_down: Fired when the escape key is pressed.
+ on_pointer_down_outside: Fired when the pointer is down outside the dialog.
+ on_focus_outside: Fired when focus moves outside the dialog.
+ on_interact_outside: Fired when the pointer interacts outside the dialog.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -409,52 +313,22 @@ class DropdownMenuSubTrigger(RadixThemesTriggerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DropdownMenuSubTrigger":
"""Create a new RadixThemesTriggerComponent instance.
@@ -481,55 +355,25 @@ class DropdownMenuSub(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DropdownMenuSub":
"""Create a new component instance.
@@ -541,6 +385,7 @@ class DropdownMenuSub(RadixThemesComponent):
*children: Child components.
open: The controlled open state of the submenu. Must be used in conjunction with `on_open_change`.
default_open: The open state of the submenu when it is initially rendered. Use when you do not need to control its open state.
+ on_open_change: Fired when the open state changes.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -568,15 +413,14 @@ class DropdownMenuSubContent(RadixThemesComponent):
avoid_collisions: Optional[Union[Var[bool], bool]] = None,
collision_padding: Optional[
Union[
+ Dict[str, Union[float, int]],
Var[Union[Dict[str, Union[float, int]], float, int]],
float,
int,
- Dict[str, Union[float, int]],
]
] = None,
- arrow_padding: Optional[Union[Var[Union[float, int]], float, int]] = None,
sticky: Optional[
- Union[Var[Literal["partial", "always"]], Literal["partial", "always"]]
+ Union[Literal["always", "partial"], Var[Literal["always", "partial"]]]
] = None,
hide_when_detached: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
@@ -584,64 +428,26 @@ class DropdownMenuSubContent(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_escape_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_interact_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_pointer_down_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_interact_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DropdownMenuSubContent":
"""Create a new component instance.
@@ -658,9 +464,12 @@ class DropdownMenuSubContent(RadixThemesComponent):
align_offset: An offset in pixels from the "start" or "end" alignment options.
avoid_collisions: When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True.
collision_padding: The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
- arrow_padding: The padding between the arrow and the edges of the content. If your content has border-radius, this will prevent it from overflowing the corners. Defaults to 0.
sticky: The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
hide_when_detached: Whether to hide the content when the trigger becomes fully occluded. Defaults to False.
+ on_escape_key_down: Fired when the escape key is pressed.
+ on_pointer_down_outside: Fired when the pointer is down outside the dialog.
+ on_focus_outside: Fired when focus moves outside the dialog.
+ on_interact_outside: Fired when the pointer interacts outside the dialog.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -682,63 +491,63 @@ class DropdownMenuItem(RadixThemesComponent):
*children,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -751,55 +560,23 @@ class DropdownMenuItem(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_select: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_select: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DropdownMenuItem":
"""Create a new component instance.
@@ -814,6 +591,7 @@ class DropdownMenuItem(RadixThemesComponent):
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
disabled: When true, prevents the user from interacting with the item.
text_value: Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item. Use this when the content is complex, or you have non-textual content inside.
+ on_select: Fired when the item is selected.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -838,52 +616,22 @@ class DropdownMenuSeparator(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DropdownMenuSeparator":
"""Create a new component instance.
diff --git a/reflex/components/radix/themes/components/hover_card.py b/reflex/components/radix/themes/components/hover_card.py
index a1c5c82d4..bd5489ce6 100644
--- a/reflex/components/radix/themes/components/hover_card.py
+++ b/reflex/components/radix/themes/components/hover_card.py
@@ -1,17 +1,14 @@
"""Interactive components provided by @radix-ui/themes."""
-from typing import Literal
+from typing import Dict, Literal, Union
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, passthrough_event_spec
+from reflex.vars.base import Var
-from ..base import (
- RadixThemesComponent,
- RadixThemesTriggerComponent,
-)
+from ..base import RadixThemesComponent, RadixThemesTriggerComponent
class HoverCardRoot(RadixThemesComponent):
@@ -32,7 +29,7 @@ class HoverCardRoot(RadixThemesComponent):
close_delay: Var[int]
# Fired when the open state changes.
- on_open_change: EventHandler[lambda e0: [e0]]
+ on_open_change: EventHandler[passthrough_event_spec(bool)]
class HoverCardTrigger(RadixThemesTriggerComponent):
@@ -55,9 +52,24 @@ class HoverCardContent(elements.Div, RadixThemesComponent):
# The preferred alignment against the trigger. May change when collisions occur.
align: Var[Literal["start", "center", "end"]]
+ # An offset in pixels from the "start" or "end" alignment options.
+ align_offset: Var[int]
+
# Whether or not the hover card should avoid collisions with its trigger.
avoid_collisions: Var[bool]
+ # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { top: 20, left: 20 }.
+ collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]]
+
+ # The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless
+ sticky: Var[Literal["partial", "always"]]
+
+ # Whether to hide the content when the trigger becomes fully occluded.
+ hide_when_detached: Var[bool]
+
+ # Hovercard size "1" - "3"
+ size: Var[Responsive[Literal["1", "2", "3"]]]
+
class HoverCard(ComponentNamespace):
"""For sighted users to preview content available behind a link."""
diff --git a/reflex/components/radix/themes/components/hover_card.pyi b/reflex/components/radix/themes/components/hover_card.pyi
index 0d43f387f..d43b583c2 100644
--- a/reflex/components/radix/themes/components/hover_card.pyi
+++ b/reflex/components/radix/themes/components/hover_card.pyi
@@ -3,14 +3,14 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent, RadixThemesTriggerComponent
@@ -29,55 +29,25 @@ class HoverCardRoot(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "HoverCardRoot":
"""Create a new component instance.
@@ -91,6 +61,7 @@ class HoverCardRoot(RadixThemesComponent):
open: The controlled open state of the hover card. Must be used in conjunction with onOpenChange.
open_delay: The duration from when the mouse enters the trigger until the hover card opens.
close_delay: The duration from when the mouse leaves the trigger until the hover card closes.
+ on_open_change: Fired when the open state changes.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -115,52 +86,22 @@ class HoverCardTrigger(RadixThemesTriggerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "HoverCardTrigger":
"""Create a new RadixThemesTriggerComponent instance.
@@ -182,99 +123,93 @@ class HoverCardContent(elements.Div, RadixThemesComponent):
*children,
side: Optional[
Union[
+ Breakpoints[str, Literal["bottom", "left", "right", "top"]],
+ Literal["bottom", "left", "right", "top"],
Var[
Union[
- Breakpoints[str, Literal["top", "right", "bottom", "left"]],
- Literal["top", "right", "bottom", "left"],
+ Breakpoints[str, Literal["bottom", "left", "right", "top"]],
+ Literal["bottom", "left", "right", "top"],
]
],
- Literal["top", "right", "bottom", "left"],
- Breakpoints[str, Literal["top", "right", "bottom", "left"]],
]
] = None,
side_offset: Optional[Union[Var[int], int]] = None,
align: Optional[
Union[
- Var[Literal["start", "center", "end"]],
- Literal["start", "center", "end"],
+ Literal["center", "end", "start"],
+ Var[Literal["center", "end", "start"]],
]
] = None,
+ align_offset: Optional[Union[Var[int], int]] = None,
avoid_collisions: Optional[Union[Var[bool], bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ collision_padding: Optional[
+ Union[
+ Dict[str, Union[float, int]],
+ Var[Union[Dict[str, Union[float, int]], float, int]],
+ float,
+ int,
+ ]
+ ] = None,
+ sticky: Optional[
+ Union[Literal["always", "partial"], Var[Literal["always", "partial"]]]
+ ] = None,
+ hide_when_detached: Optional[Union[Var[bool], bool]] = None,
+ size: Optional[
+ Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
+ Var[
+ Union[
+ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
+ ]
+ ],
+ ]
+ ] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "HoverCardContent":
"""Create a new component instance.
@@ -287,8 +222,13 @@ class HoverCardContent(elements.Div, RadixThemesComponent):
side: The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled.
side_offset: The distance in pixels from the trigger.
align: The preferred alignment against the trigger. May change when collisions occur.
+ align_offset: An offset in pixels from the "start" or "end" alignment options.
avoid_collisions: Whether or not the hover card should avoid collisions with its trigger.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ collision_padding: The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { top: 20, left: 20 }.
+ sticky: The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless
+ hide_when_detached: Whether to hide the content when the trigger becomes fully occluded.
+ size: Hovercard size "1" - "3"
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -334,55 +274,25 @@ class HoverCard(ComponentNamespace):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "HoverCardRoot":
"""Create a new component instance.
@@ -396,6 +306,7 @@ class HoverCard(ComponentNamespace):
open: The controlled open state of the hover card. Must be used in conjunction with onOpenChange.
open_delay: The duration from when the mouse enters the trigger until the hover card opens.
close_delay: The duration from when the mouse leaves the trigger until the hover card closes.
+ on_open_change: Fired when the open state changes.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/radix/themes/components/icon_button.py b/reflex/components/radix/themes/components/icon_button.py
index 76077057e..68c67485a 100644
--- a/reflex/components/radix/themes/components/icon_button.py
+++ b/reflex/components/radix/themes/components/icon_button.py
@@ -10,7 +10,7 @@ from reflex.components.core.match import Match
from reflex.components.el import elements
from reflex.components.lucide import Icon
from reflex.style import Style
-from reflex.vars import Var
+from reflex.vars.base import Var
from ..base import (
LiteralAccentColor,
@@ -79,7 +79,7 @@ class IconButton(elements.Button, RadixLoadingProp, RadixThemesComponent):
else:
size_map_var = Match.create(
props["size"],
- *[(size, px) for size, px in RADIX_TO_LUCIDE_SIZE.items()],
+ *list(RADIX_TO_LUCIDE_SIZE.items()),
12,
)
if not isinstance(size_map_var, Var):
diff --git a/reflex/components/radix/themes/components/icon_button.pyi b/reflex/components/radix/themes/components/icon_button.pyi
index 25de63938..abf77e07b 100644
--- a/reflex/components/radix/themes/components/icon_button.pyi
+++ b/reflex/components/radix/themes/components/icon_button.pyi
@@ -3,18 +3,15 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
-from ..base import (
- RadixLoadingProp,
- RadixThemesComponent,
-)
+from ..base import RadixLoadingProp, RadixThemesComponent
LiteralButtonSize = Literal["1", "2", "3", "4"]
@@ -27,182 +24,152 @@ class IconButton(elements.Button, RadixLoadingProp, RadixThemesComponent):
as_child: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4"]],
+ Literal["1", "2", "3", "4"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3", "4"]],
Literal["1", "2", "3", "4"],
]
],
- Literal["1", "2", "3", "4"],
- Breakpoints[str, Literal["1", "2", "3", "4"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]],
- Literal["classic", "solid", "soft", "surface", "outline", "ghost"],
+ Literal["classic", "ghost", "outline", "soft", "solid", "surface"],
+ Var[Literal["classic", "ghost", "outline", "soft", "solid", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
- auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
form_enc_type: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
form_no_validate: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
loading: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "IconButton":
"""Create a IconButton component.
@@ -226,7 +193,7 @@ class IconButton(elements.Button, RadixLoadingProp, RadixThemesComponent):
name: Name of the button, used when sending form data
type: Type of the button (submit, reset, or button)
value: Value of the button, used when sending form data
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/components/inset.py b/reflex/components/radix/themes/components/inset.py
index 96f1f61ce..059858272 100644
--- a/reflex/components/radix/themes/components/inset.py
+++ b/reflex/components/radix/themes/components/inset.py
@@ -4,11 +4,9 @@ from typing import Literal, Union
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- RadixThemesComponent,
-)
+from ..base import RadixThemesComponent
LiteralButtonSize = Literal["1", "2", "3", "4"]
diff --git a/reflex/components/radix/themes/components/inset.pyi b/reflex/components/radix/themes/components/inset.pyi
index 0106a23b2..f03275ec0 100644
--- a/reflex/components/radix/themes/components/inset.pyi
+++ b/reflex/components/radix/themes/components/inset.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -23,161 +23,131 @@ class Inset(elements.Div, RadixThemesComponent):
*children,
side: Optional[
Union[
+ Breakpoints[str, Literal["bottom", "left", "right", "top", "x", "y"]],
+ Literal["bottom", "left", "right", "top", "x", "y"],
Var[
Union[
Breakpoints[
- str, Literal["x", "y", "top", "bottom", "right", "left"]
+ str, Literal["bottom", "left", "right", "top", "x", "y"]
],
- Literal["x", "y", "top", "bottom", "right", "left"],
+ Literal["bottom", "left", "right", "top", "x", "y"],
]
],
- Literal["x", "y", "top", "bottom", "right", "left"],
- Breakpoints[str, Literal["x", "y", "top", "bottom", "right", "left"]],
]
] = None,
clip: Optional[
Union[
+ Breakpoints[str, Literal["border-box", "padding-box"]],
+ Literal["border-box", "padding-box"],
Var[
Union[
Breakpoints[str, Literal["border-box", "padding-box"]],
Literal["border-box", "padding-box"],
]
],
- Literal["border-box", "padding-box"],
- Breakpoints[str, Literal["border-box", "padding-box"]],
]
] = None,
p: Optional[
Union[
+ Breakpoints[str, Union[int, str]],
Var[Union[Breakpoints[str, Union[int, str]], int, str]],
int,
str,
- Breakpoints[str, Union[int, str]],
]
] = None,
px: Optional[
Union[
+ Breakpoints[str, Union[int, str]],
Var[Union[Breakpoints[str, Union[int, str]], int, str]],
int,
str,
- Breakpoints[str, Union[int, str]],
]
] = None,
py: Optional[
Union[
+ Breakpoints[str, Union[int, str]],
Var[Union[Breakpoints[str, Union[int, str]], int, str]],
int,
str,
- Breakpoints[str, Union[int, str]],
]
] = None,
pt: Optional[
Union[
+ Breakpoints[str, Union[int, str]],
Var[Union[Breakpoints[str, Union[int, str]], int, str]],
int,
str,
- Breakpoints[str, Union[int, str]],
]
] = None,
pr: Optional[
Union[
+ Breakpoints[str, Union[int, str]],
Var[Union[Breakpoints[str, Union[int, str]], int, str]],
int,
str,
- Breakpoints[str, Union[int, str]],
]
] = None,
pb: Optional[
Union[
+ Breakpoints[str, Union[int, str]],
Var[Union[Breakpoints[str, Union[int, str]], int, str]],
int,
str,
- Breakpoints[str, Union[int, str]],
]
] = None,
pl: Optional[
Union[
+ Breakpoints[str, Union[int, str]],
Var[Union[Breakpoints[str, Union[int, str]], int, str]],
int,
str,
- Breakpoints[str, Union[int, str]],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Inset":
"""Create a new component instance.
@@ -196,7 +166,7 @@ class Inset(elements.Div, RadixThemesComponent):
pr: Padding on the right
pb: Padding on the bottom
pl: Padding on the left
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/components/popover.py b/reflex/components/radix/themes/components/popover.py
index 7c51cb53b..bdf5f4af3 100644
--- a/reflex/components/radix/themes/components/popover.py
+++ b/reflex/components/radix/themes/components/popover.py
@@ -1,17 +1,14 @@
"""Interactive components provided by @radix-ui/themes."""
-from typing import Literal
+from typing import Dict, Literal, Union
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec
+from reflex.vars.base import Var
-from ..base import (
- RadixThemesComponent,
- RadixThemesTriggerComponent,
-)
+from ..base import RadixThemesComponent, RadixThemesTriggerComponent
class PopoverRoot(RadixThemesComponent):
@@ -26,7 +23,10 @@ class PopoverRoot(RadixThemesComponent):
modal: Var[bool]
# Fired when the open state changes.
- on_open_change: EventHandler[lambda e0: [e0]]
+ on_open_change: EventHandler[passthrough_event_spec(bool)]
+
+ # The open state of the popover when it is initially rendered. Use when you do not need to control its open state.
+ default_open: Var[bool]
class PopoverTrigger(RadixThemesTriggerComponent):
@@ -58,23 +58,32 @@ class PopoverContent(elements.Div, RadixThemesComponent):
# When true, overrides the side andalign preferences to prevent collisions with boundary edges.
avoid_collisions: Var[bool]
+ # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
+ collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]]
+
+ # The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
+ sticky: Var[Literal["partial", "always"]]
+
+ # Whether to hide the content when the trigger becomes fully occluded. Defaults to False.
+ hide_when_detached: Var[bool]
+
# Fired when the dialog is opened.
- on_open_auto_focus: EventHandler[lambda e0: [e0]]
+ on_open_auto_focus: EventHandler[no_args_event_spec]
# Fired when the dialog is closed.
- on_close_auto_focus: EventHandler[lambda e0: [e0]]
+ on_close_auto_focus: EventHandler[no_args_event_spec]
# Fired when the escape key is pressed.
- on_escape_key_down: EventHandler[lambda e0: [e0]]
+ on_escape_key_down: EventHandler[no_args_event_spec]
# Fired when the pointer is down outside the dialog.
- on_pointer_down_outside: EventHandler[lambda e0: [e0]]
+ on_pointer_down_outside: EventHandler[no_args_event_spec]
# Fired when focus moves outside the dialog.
- on_focus_outside: EventHandler[lambda e0: [e0]]
+ on_focus_outside: EventHandler[no_args_event_spec]
# Fired when the pointer interacts outside the dialog.
- on_interact_outside: EventHandler[lambda e0: [e0]]
+ on_interact_outside: EventHandler[no_args_event_spec]
class PopoverClose(RadixThemesTriggerComponent):
diff --git a/reflex/components/radix/themes/components/popover.pyi b/reflex/components/radix/themes/components/popover.pyi
index 82bec124b..51f114dd2 100644
--- a/reflex/components/radix/themes/components/popover.pyi
+++ b/reflex/components/radix/themes/components/popover.pyi
@@ -3,14 +3,14 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent, RadixThemesTriggerComponent
@@ -22,60 +22,31 @@ class PopoverRoot(RadixThemesComponent):
*children,
open: Optional[Union[Var[bool], bool]] = None,
modal: Optional[Union[Var[bool], bool]] = None,
+ default_open: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "PopoverRoot":
"""Create a new component instance.
@@ -87,6 +58,8 @@ class PopoverRoot(RadixThemesComponent):
*children: Child components.
open: The controlled open state of the popover.
modal: The modality of the popover. When set to true, interaction with outside elements will be disabled and only popover content will be visible to screen readers.
+ on_open_change: Fired when the open state changes.
+ default_open: The open state of the popover when it is initially rendered. Use when you do not need to control its open state.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -111,52 +84,22 @@ class PopoverTrigger(RadixThemesTriggerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "PopoverTrigger":
"""Create a new RadixThemesTriggerComponent instance.
@@ -178,124 +121,94 @@ class PopoverContent(elements.Div, RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4"]],
+ Literal["1", "2", "3", "4"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3", "4"]],
Literal["1", "2", "3", "4"],
]
],
- Literal["1", "2", "3", "4"],
- Breakpoints[str, Literal["1", "2", "3", "4"]],
]
] = None,
side: Optional[
Union[
- Var[Literal["top", "right", "bottom", "left"]],
- Literal["top", "right", "bottom", "left"],
+ Literal["bottom", "left", "right", "top"],
+ Var[Literal["bottom", "left", "right", "top"]],
]
] = None,
side_offset: Optional[Union[Var[int], int]] = None,
align: Optional[
Union[
- Var[Literal["start", "center", "end"]],
- Literal["start", "center", "end"],
+ Literal["center", "end", "start"],
+ Var[Literal["center", "end", "start"]],
]
] = None,
align_offset: Optional[Union[Var[int], int]] = None,
avoid_collisions: Optional[Union[Var[bool], bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ collision_padding: Optional[
+ Union[
+ Dict[str, Union[float, int]],
+ Var[Union[Dict[str, Union[float, int]], float, int]],
+ float,
+ int,
+ ]
+ ] = None,
+ sticky: Optional[
+ Union[Literal["always", "partial"], Var[Literal["always", "partial"]]]
+ ] = None,
+ hide_when_detached: Optional[Union[Var[bool], bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close_auto_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_escape_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_interact_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_open_auto_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_pointer_down_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_interact_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_open_auto_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "PopoverContent":
"""Create a new component instance.
@@ -311,7 +224,16 @@ class PopoverContent(elements.Div, RadixThemesComponent):
align: The preferred alignment against the anchor. May change when collisions occur.
align_offset: The vertical distance in pixels from the anchor.
avoid_collisions: When true, overrides the side andalign preferences to prevent collisions with boundary edges.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ collision_padding: The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
+ sticky: The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
+ hide_when_detached: Whether to hide the content when the trigger becomes fully occluded. Defaults to False.
+ on_open_auto_focus: Fired when the dialog is opened.
+ on_close_auto_focus: Fired when the dialog is closed.
+ on_escape_key_down: Fired when the escape key is pressed.
+ on_pointer_down_outside: Fired when the pointer is down outside the dialog.
+ on_focus_outside: Fired when focus moves outside the dialog.
+ on_interact_outside: Fired when the pointer interacts outside the dialog.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -351,52 +273,22 @@ class PopoverClose(RadixThemesTriggerComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "PopoverClose":
"""Create a new RadixThemesTriggerComponent instance.
diff --git a/reflex/components/radix/themes/components/progress.py b/reflex/components/radix/themes/components/progress.py
index a122130c8..e9fe168c6 100644
--- a/reflex/components/radix/themes/components/progress.py
+++ b/reflex/components/radix/themes/components/progress.py
@@ -4,7 +4,8 @@ from typing import Literal
from reflex.components.component import Component
from reflex.components.core.breakpoints import Responsive
-from reflex.vars import Var
+from reflex.style import Style
+from reflex.vars.base import Var
from ..base import LiteralAccentColor, RadixThemesComponent
@@ -38,6 +39,21 @@ class Progress(RadixThemesComponent):
# The duration of the progress bar animation. Once the duration times out, the progress bar will start an indeterminate animation.
duration: Var[str]
+ # The color of the progress bar fill animation.
+ fill_color: Var[str]
+
+ @staticmethod
+ def _color_selector(color: str) -> Style:
+ """Return a style object with the correct color and css selector.
+
+ Args:
+ color: Color of the fill part.
+
+ Returns:
+ Style: Style object with the correct css selector and color.
+ """
+ return Style({".rt-ProgressIndicator": {"background_color": color}})
+
@classmethod
def create(cls, *children, **props) -> Component:
"""Create a Progress component.
@@ -50,6 +66,12 @@ class Progress(RadixThemesComponent):
The Progress Component.
"""
props.setdefault("width", "100%")
+ if "fill_color" in props:
+ color = props.get("fill_color", "")
+ style = props.get("style", {})
+ style = style | cls._color_selector(color)
+ props["style"] = style
+
return super().create(*children, **props)
diff --git a/reflex/components/radix/themes/components/progress.pyi b/reflex/components/radix/themes/components/progress.pyi
index 514061ba7..5b3f8ba51 100644
--- a/reflex/components/radix/themes/components/progress.pyi
+++ b/reflex/components/radix/themes/components/progress.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -22,142 +22,113 @@ class Progress(RadixThemesComponent):
max: Optional[Union[Var[int], int]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
duration: Optional[Union[Var[str], str]] = None,
+ fill_color: Optional[Union[Var[str], str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Progress":
"""Create a Progress component.
@@ -172,6 +143,7 @@ class Progress(RadixThemesComponent):
high_contrast: Whether to render the progress bar with higher contrast color against background
radius: Override theme radius for progress bar: "none" | "small" | "medium" | "large" | "full"
duration: The duration of the progress bar animation. Once the duration times out, the progress bar will start an indeterminate animation.
+ fill_color: The color of the progress bar fill animation.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/radix/themes/components/radio.py b/reflex/components/radix/themes/components/radio.py
index 53cb35f32..fd24bb6b5 100644
--- a/reflex/components/radix/themes/components/radio.py
+++ b/reflex/components/radix/themes/components/radio.py
@@ -3,7 +3,7 @@
from typing import Literal
from reflex.components.core.breakpoints import Responsive
-from reflex.vars import Var
+from reflex.vars.base import Var
from ..base import LiteralAccentColor, RadixThemesComponent
diff --git a/reflex/components/radix/themes/components/radio.pyi b/reflex/components/radix/themes/components/radio.pyi
index e00a6db58..49490286f 100644
--- a/reflex/components/radix/themes/components/radio.pyi
+++ b/reflex/components/radix/themes/components/radio.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -20,80 +20,80 @@ class Radio(RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -103,52 +103,22 @@ class Radio(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Radio":
"""Create a new component instance.
diff --git a/reflex/components/radix/themes/components/radio_cards.py b/reflex/components/radix/themes/components/radio_cards.py
index 88688521f..e075a1ba2 100644
--- a/reflex/components/radix/themes/components/radio_cards.py
+++ b/reflex/components/radix/themes/components/radio_cards.py
@@ -4,8 +4,8 @@ from types import SimpleNamespace
from typing import Literal, Union
from reflex.components.core.breakpoints import Responsive
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, passthrough_event_spec
+from reflex.vars.base import Var
from ..base import LiteralAccentColor, RadixThemesComponent
@@ -65,7 +65,7 @@ class RadioCardsRoot(RadixThemesComponent):
loop: Var[bool]
# Event handler called when the value changes.
- on_value_change: EventHandler[lambda e0: [e0]]
+ on_value_change: EventHandler[passthrough_event_spec(str)]
class RadioCardsItem(RadixThemesComponent):
diff --git a/reflex/components/radix/themes/components/radio_cards.pyi b/reflex/components/radix/themes/components/radio_cards.pyi
index 4feb78d20..5ba01d0a0 100644
--- a/reflex/components/radix/themes/components/radio_cards.pyi
+++ b/reflex/components/radix/themes/components/radio_cards.pyi
@@ -4,12 +4,12 @@
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
from types import SimpleNamespace
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -22,83 +22,88 @@ class RadioCardsRoot(RadixThemesComponent):
as_child: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
- Union[Var[Literal["classic", "surface"]], Literal["classic", "surface"]]
+ Union[Literal["classic", "surface"], Var[Literal["classic", "surface"]]]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
columns: Optional[
Union[
+ Breakpoints[
+ str,
+ Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str],
+ ],
+ Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -113,15 +118,15 @@ class RadioCardsRoot(RadixThemesComponent):
]
],
str,
- Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str,
- Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str],
- ],
]
] = None,
gap: Optional[
Union[
+ Breakpoints[
+ str,
+ Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str],
+ ],
+ Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -136,11 +141,6 @@ class RadioCardsRoot(RadixThemesComponent):
]
],
str,
- Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str,
- Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str],
- ],
]
] = None,
default_value: Optional[Union[Var[str], str]] = None,
@@ -150,65 +150,35 @@ class RadioCardsRoot(RadixThemesComponent):
required: Optional[Union[Var[bool], bool]] = None,
orientation: Optional[
Union[
- Var[Literal["horizontal", "vertical", "undefined"]],
- Literal["horizontal", "vertical", "undefined"],
+ Literal["horizontal", "undefined", "vertical"],
+ Var[Literal["horizontal", "undefined", "vertical"]],
]
] = None,
- dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None,
+ dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None,
loop: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
on_value_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
**props,
) -> "RadioCardsRoot":
@@ -233,6 +203,7 @@ class RadioCardsRoot(RadixThemesComponent):
orientation: The orientation of the component.
dir: The reading direction of the radio group. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode.
loop: When true, keyboard navigation will loop from last item to first, and vice versa.
+ on_value_change: Event handler called when the value changes.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -261,52 +232,22 @@ class RadioCardsItem(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "RadioCardsItem":
"""Create a new component instance.
diff --git a/reflex/components/radix/themes/components/radio_group.py b/reflex/components/radix/themes/components/radio_group.py
index 20ccbd5b5..80b3ee10c 100644
--- a/reflex/components/radix/themes/components/radio_group.py
+++ b/reflex/components/radix/themes/components/radio_group.py
@@ -9,14 +9,12 @@ from reflex.components.component import Component, ComponentNamespace
from reflex.components.core.breakpoints import Responsive
from reflex.components.radix.themes.layout.flex import Flex
from reflex.components.radix.themes.typography.text import Text
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, passthrough_event_spec
+from reflex.utils import types
+from reflex.vars.base import LiteralVar, Var
+from reflex.vars.sequence import StringVar
-from ..base import (
- LiteralAccentColor,
- LiteralSpacing,
- RadixThemesComponent,
-)
+from ..base import LiteralAccentColor, LiteralSpacing, RadixThemesComponent
LiteralFlexDirection = Literal["row", "column", "row-reverse", "column-reverse"]
@@ -27,14 +25,10 @@ class RadioGroupRoot(RadixThemesComponent):
tag = "RadioGroup.Root"
# The size of the radio group: "1" | "2" | "3"
- size: Var[Responsive[Literal["1", "2", "3"]]] = Var.create_safe(
- "2", _var_is_string=True
- )
+ size: Var[Responsive[Literal["1", "2", "3"]]] = LiteralVar.create("2")
# The variant of the radio group
- variant: Var[Literal["classic", "surface", "soft"]] = Var.create_safe(
- "classic", _var_is_string=True
- )
+ variant: Var[Literal["classic", "surface", "soft"]] = LiteralVar.create("classic")
# The color of the radio group
color_scheme: Var[LiteralAccentColor]
@@ -61,7 +55,7 @@ class RadioGroupRoot(RadixThemesComponent):
_rename_props = {"onChange": "onValueChange"}
# Fired when the value of the radio group changes.
- on_change: EventHandler[lambda e0: [e0]]
+ on_change: EventHandler[passthrough_event_spec(str)]
class RadioGroupItem(RadixThemesComponent):
@@ -86,20 +80,16 @@ class HighLevelRadioGroup(RadixThemesComponent):
items: Var[List[str]]
# The direction of the radio group.
- direction: Var[LiteralFlexDirection] = Var.create_safe(
- "column", _var_is_string=True
- )
+ direction: Var[LiteralFlexDirection] = LiteralVar.create("row")
# The gap between the items of the radio group.
- spacing: Var[LiteralSpacing] = Var.create_safe("2", _var_is_string=True)
+ spacing: Var[LiteralSpacing] = LiteralVar.create("2")
# The size of the radio group.
- size: Var[Literal["1", "2", "3"]] = Var.create_safe("2", _var_is_string=True)
+ size: Var[Literal["1", "2", "3"]] = LiteralVar.create("2")
# The variant of the radio group
- variant: Var[Literal["classic", "surface", "soft"]] = Var.create_safe(
- "classic", _var_is_string=True
- )
+ variant: Var[Literal["classic", "surface", "soft"]] = LiteralVar.create("classic")
# The color of the radio group
color_scheme: Var[LiteralAccentColor]
@@ -139,42 +129,48 @@ class HighLevelRadioGroup(RadixThemesComponent):
Returns:
The created radio group component.
+
+ Raises:
+ TypeError: If the type of items is invalid.
"""
- direction = props.pop("direction", "column")
+ direction = props.pop("direction", "row")
spacing = props.pop("spacing", "2")
size = props.pop("size", "2")
variant = props.pop("variant", "classic")
color_scheme = props.pop("color_scheme", None)
default_value = props.pop("default_value", "")
- default_value = Var.create(default_value, _var_is_string=True)
+ if not isinstance(items, (list, Var)) or (
+ isinstance(items, Var) and not types._issubclass(items._var_type, list)
+ ):
+ items_type = type(items) if not isinstance(items, Var) else items._var_type
+ raise TypeError(
+ f"The radio group component takes in a list, got {items_type} instead"
+ )
+
+ default_value = LiteralVar.create(default_value)
# convert only non-strings to json(JSON.stringify) so quotes are not rendered
# for string literal types.
if isinstance(default_value, str) or (
isinstance(default_value, Var) and default_value._var_type is str
):
- default_value = Var.create(default_value, _var_is_string=True) # type: ignore
+ default_value = LiteralVar.create(default_value) # type: ignore
else:
- default_value = (
- Var.create(default_value, _var_is_string=False)
- .to_string() # type: ignore
- ._replace(_var_is_local=False)
- )
+ default_value = LiteralVar.create(default_value).to_string()
- def radio_group_item(value: str | Var) -> Component:
- item_value = Var.create(value, _var_is_string=False) # type: ignore
+ def radio_group_item(value: Var) -> Component:
item_value = rx.cond(
- item_value._type() == str, # type: ignore
- item_value,
- item_value.to_string()._replace(_var_is_local=False), # type: ignore
- )._replace(_var_type=str)
+ value.js_type() == "string",
+ value,
+ value.to_string(),
+ ).to(StringVar)
return Text.create(
Flex.create(
RadioGroupItem.create(
value=item_value,
- disabled=props.get("disabled", Var.create(False)),
+ disabled=props.get("disabled", LiteralVar.create(False)),
),
item_value,
spacing="2",
@@ -183,8 +179,7 @@ class HighLevelRadioGroup(RadixThemesComponent):
as_="label",
)
- items = Var.create(items) # type: ignore
- children = [rx.foreach(items, radio_group_item)]
+ children = [rx.foreach(LiteralVar.create(items), radio_group_item)]
return RadioGroupRoot.create(
Flex.create(
diff --git a/reflex/components/radix/themes/components/radio_group.pyi b/reflex/components/radix/themes/components/radio_group.pyi
index 0452450ff..e8e4e4254 100644
--- a/reflex/components/radix/themes/components/radio_group.pyi
+++ b/reflex/components/radix/themes/components/radio_group.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -23,80 +23,80 @@ class RadioGroupRoot(RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -111,55 +111,25 @@ class RadioGroupRoot(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "RadioGroupRoot":
"""Create a new component instance.
@@ -178,6 +148,7 @@ class RadioGroupRoot(RadixThemesComponent):
disabled: Whether the radio group is disabled
name: The name of the group. Submitted with its owning form as part of a name/value pair.
required: Whether the radio group is required
+ on_change: Fired when the value of the radio group changes.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -205,52 +176,22 @@ class RadioGroupItem(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "RadioGroupItem":
"""Create a new component instance.
@@ -282,87 +223,87 @@ class HighLevelRadioGroup(RadixThemesComponent):
def create( # type: ignore
cls,
*children,
- items: Optional[Union[Var[List[str]], List[str]]] = None,
+ items: Optional[Union[List[str], Var[List[str]]]] = None,
direction: Optional[
Union[
- Var[Literal["row", "column", "row-reverse", "column-reverse"]],
- Literal["row", "column", "row-reverse", "column-reverse"],
+ Literal["column", "column-reverse", "row", "row-reverse"],
+ Var[Literal["column", "column-reverse", "row", "row-reverse"]],
]
] = None,
spacing: Optional[
Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
size: Optional[
- Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]]
+ Union[Literal["1", "2", "3"], Var[Literal["1", "2", "3"]]]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -377,52 +318,22 @@ class HighLevelRadioGroup(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "HighLevelRadioGroup":
"""Create a radio group component.
@@ -451,6 +362,9 @@ class HighLevelRadioGroup(RadixThemesComponent):
Returns:
The created radio group component.
+
+ Raises:
+ TypeError: If the type of items is invalid.
"""
...
@@ -461,87 +375,87 @@ class RadioGroup(ComponentNamespace):
@staticmethod
def __call__(
*children,
- items: Optional[Union[Var[List[str]], List[str]]] = None,
+ items: Optional[Union[List[str], Var[List[str]]]] = None,
direction: Optional[
Union[
- Var[Literal["row", "column", "row-reverse", "column-reverse"]],
- Literal["row", "column", "row-reverse", "column-reverse"],
+ Literal["column", "column-reverse", "row", "row-reverse"],
+ Var[Literal["column", "column-reverse", "row", "row-reverse"]],
]
] = None,
spacing: Optional[
Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
size: Optional[
- Union[Var[Literal["1", "2", "3"]], Literal["1", "2", "3"]]
+ Union[Literal["1", "2", "3"], Var[Literal["1", "2", "3"]]]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -556,52 +470,22 @@ class RadioGroup(ComponentNamespace):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "HighLevelRadioGroup":
"""Create a radio group component.
@@ -630,6 +514,9 @@ class RadioGroup(ComponentNamespace):
Returns:
The created radio group component.
+
+ Raises:
+ TypeError: If the type of items is invalid.
"""
...
diff --git a/reflex/components/radix/themes/components/scroll_area.py b/reflex/components/radix/themes/components/scroll_area.py
index 8920d81d6..516649e12 100644
--- a/reflex/components/radix/themes/components/scroll_area.py
+++ b/reflex/components/radix/themes/components/scroll_area.py
@@ -2,11 +2,9 @@
from typing import Literal
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- RadixThemesComponent,
-)
+from ..base import RadixThemesComponent
class ScrollArea(RadixThemesComponent):
diff --git a/reflex/components/radix/themes/components/scroll_area.pyi b/reflex/components/radix/themes/components/scroll_area.pyi
index e7d2018da..5945cc3af 100644
--- a/reflex/components/radix/themes/components/scroll_area.pyi
+++ b/reflex/components/radix/themes/components/scroll_area.pyi
@@ -3,11 +3,11 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -19,14 +19,14 @@ class ScrollArea(RadixThemesComponent):
*children,
scrollbars: Optional[
Union[
- Var[Literal["vertical", "horizontal", "both"]],
- Literal["vertical", "horizontal", "both"],
+ Literal["both", "horizontal", "vertical"],
+ Var[Literal["both", "horizontal", "vertical"]],
]
] = None,
type: Optional[
Union[
- Var[Literal["auto", "always", "scroll", "hover"]],
- Literal["auto", "always", "scroll", "hover"],
+ Literal["always", "auto", "hover", "scroll"],
+ Var[Literal["always", "auto", "hover", "scroll"]],
]
] = None,
scroll_hide_delay: Optional[Union[Var[int], int]] = None,
@@ -35,52 +35,22 @@ class ScrollArea(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ScrollArea":
"""Create a new component instance.
diff --git a/reflex/components/radix/themes/components/segmented_control.py b/reflex/components/radix/themes/components/segmented_control.py
index 40beb603a..f2dd9dc7c 100644
--- a/reflex/components/radix/themes/components/segmented_control.py
+++ b/reflex/components/radix/themes/components/segmented_control.py
@@ -3,15 +3,29 @@
from __future__ import annotations
from types import SimpleNamespace
-from typing import List, Literal, Union
+from typing import List, Literal, Tuple, Union
from reflex.components.core.breakpoints import Responsive
from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.vars.base import Var
from ..base import LiteralAccentColor, RadixThemesComponent
+def on_value_change(
+ value: Var[Union[str, List[str]]],
+) -> Tuple[Var[Union[str, List[str]]]]:
+ """Handle the on_value_change event.
+
+ Args:
+ value: The value of the event.
+
+ Returns:
+ The value of the event.
+ """
+ return (value,)
+
+
class SegmentedControlRoot(RadixThemesComponent):
"""Root element for a SegmentedControl component."""
@@ -23,6 +37,7 @@ class SegmentedControlRoot(RadixThemesComponent):
# Variant of button: "classic" | "surface"
variant: Var[Literal["classic", "surface"]]
+ # The type of the segmented control, either "single" for selecting one option or "multiple" for selecting multiple options.
type: Var[Literal["single", "multiple"]]
# Override theme color for button
@@ -34,9 +49,11 @@ class SegmentedControlRoot(RadixThemesComponent):
# The default value of the segmented control.
default_value: Var[Union[str, List[str]]]
+ # The current value of the segmented control.
value: Var[Union[str, List[str]]]
- on_change: EventHandler[lambda e0: [e0]]
+ # Handles the `onChange` event for the SegmentedControl component.
+ on_change: EventHandler[on_value_change]
_rename_props = {"onChange": "onValueChange"}
diff --git a/reflex/components/radix/themes/components/segmented_control.pyi b/reflex/components/radix/themes/components/segmented_control.pyi
index 4ac662e13..c7e87ca34 100644
--- a/reflex/components/radix/themes/components/segmented_control.pyi
+++ b/reflex/components/radix/themes/components/segmented_control.pyi
@@ -4,15 +4,19 @@
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
from types import SimpleNamespace
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
+def on_value_change(
+ value: Var[Union[str, List[str]]],
+) -> Tuple[Var[Union[str, List[str]]]]: ...
+
class SegmentedControlRoot(RadixThemesComponent):
@overload
@classmethod
@@ -21,147 +25,120 @@ class SegmentedControlRoot(RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
- Union[Var[Literal["classic", "surface"]], Literal["classic", "surface"]]
+ Union[Literal["classic", "surface"], Var[Literal["classic", "surface"]]]
] = None,
type: Optional[
- Union[Var[Literal["single", "multiple"]], Literal["single", "multiple"]]
+ Union[Literal["multiple", "single"], Var[Literal["multiple", "single"]]]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
default_value: Optional[
- Union[Var[Union[List[str], str]], str, List[str]]
+ Union[List[str], Var[Union[List[str], str]], str]
] = None,
- value: Optional[Union[Var[Union[List[str], str]], str, List[str]]] = None,
+ value: Optional[Union[List[str], Var[Union[List[str], str]], str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[Union[str, List[str]]], BASE_STATE],
+ ]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SegmentedControlRoot":
"""Create a new component instance.
@@ -173,9 +150,12 @@ class SegmentedControlRoot(RadixThemesComponent):
*children: Child components.
size: The size of the segmented control: "1" | "2" | "3"
variant: Variant of button: "classic" | "surface"
+ type: The type of the segmented control, either "single" for selecting one option or "multiple" for selecting multiple options.
color_scheme: Override theme color for button
radius: The radius of the segmented control: "none" | "small" | "medium" | "large" | "full"
default_value: The default value of the segmented control.
+ value: The current value of the segmented control.
+ on_change: Handles the `onChange` event for the SegmentedControl component.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -201,52 +181,22 @@ class SegmentedControlItem(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SegmentedControlItem":
"""Create a new component instance.
diff --git a/reflex/components/radix/themes/components/select.py b/reflex/components/radix/themes/components/select.py
index fc10d00de..45e5712bc 100644
--- a/reflex/components/radix/themes/components/select.py
+++ b/reflex/components/radix/themes/components/select.py
@@ -5,13 +5,10 @@ from typing import List, Literal, Union
import reflex as rx
from reflex.components.component import Component, ComponentNamespace
from reflex.components.core.breakpoints import Responsive
-from reflex.vars import Var
+from reflex.event import no_args_event_spec, passthrough_event_spec
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- LiteralRadius,
- RadixThemesComponent,
-)
+from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent
class SelectRoot(RadixThemesComponent):
@@ -47,10 +44,10 @@ class SelectRoot(RadixThemesComponent):
_rename_props = {"onChange": "onValueChange"}
# Fired when the value of the select changes.
- on_change: rx.EventHandler[lambda e0: [e0]]
+ on_change: rx.EventHandler[passthrough_event_spec(str)]
# Fired when the select is opened or closed.
- on_open_change: rx.EventHandler[lambda e0: [e0]]
+ on_open_change: rx.EventHandler[passthrough_event_spec(bool)]
class SelectTrigger(RadixThemesComponent):
@@ -103,13 +100,13 @@ class SelectContent(RadixThemesComponent):
align_offset: Var[int]
# Fired when the select content is closed.
- on_close_auto_focus: rx.EventHandler[lambda e0: [e0]]
+ on_close_auto_focus: rx.EventHandler[no_args_event_spec]
# Fired when the escape key is pressed.
- on_escape_key_down: rx.EventHandler[lambda e0: [e0]]
+ on_escape_key_down: rx.EventHandler[no_args_event_spec]
# Fired when a pointer down event happens outside the select content.
- on_pointer_down_outside: rx.EventHandler[lambda e0: [e0]]
+ on_pointer_down_outside: rx.EventHandler[no_args_event_spec]
class SelectGroup(RadixThemesComponent):
diff --git a/reflex/components/radix/themes/components/select.pyi b/reflex/components/radix/themes/components/select.pyi
index 125ced252..a6c1ff144 100644
--- a/reflex/components/radix/themes/components/select.pyi
+++ b/reflex/components/radix/themes/components/select.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -21,13 +21,13 @@ class SelectRoot(RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
default_value: Optional[Union[Var[str], str]] = None,
@@ -42,58 +42,28 @@ class SelectRoot(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SelectRoot":
"""Create a new component instance.
@@ -111,6 +81,8 @@ class SelectRoot(RadixThemesComponent):
name: The name of the select control when submitting the form.
disabled: When True, prevents the user from interacting with select.
required: When True, indicates that the user must select a value before the owning form can be submitted.
+ on_change: Fired when the value of the select changes.
+ on_open_change: Fired when the select is opened or closed.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -132,76 +104,76 @@ class SelectTrigger(RadixThemesComponent):
*children,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft", "ghost"]],
- Literal["classic", "surface", "soft", "ghost"],
+ Literal["classic", "ghost", "soft", "surface"],
+ Var[Literal["classic", "ghost", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
placeholder: Optional[Union[Var[str], str]] = None,
@@ -210,52 +182,22 @@ class SelectTrigger(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SelectTrigger":
"""Create a new component instance.
@@ -289,88 +231,88 @@ class SelectContent(RadixThemesComponent):
cls,
*children,
variant: Optional[
- Union[Var[Literal["solid", "soft"]], Literal["solid", "soft"]]
+ Union[Literal["soft", "solid"], Var[Literal["soft", "solid"]]]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
position: Optional[
Union[
- Var[Literal["item-aligned", "popper"]],
Literal["item-aligned", "popper"],
+ Var[Literal["item-aligned", "popper"]],
]
] = None,
side: Optional[
Union[
- Var[Literal["top", "right", "bottom", "left"]],
- Literal["top", "right", "bottom", "left"],
+ Literal["bottom", "left", "right", "top"],
+ Var[Literal["bottom", "left", "right", "top"]],
]
] = None,
side_offset: Optional[Union[Var[int], int]] = None,
align: Optional[
Union[
- Var[Literal["start", "center", "end"]],
- Literal["start", "center", "end"],
+ Literal["center", "end", "start"],
+ Var[Literal["center", "end", "start"]],
]
] = None,
align_offset: Optional[Union[Var[int], int]] = None,
@@ -379,61 +321,25 @@ class SelectContent(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_close_auto_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_escape_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_pointer_down_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SelectContent":
"""Create a new component instance.
@@ -451,6 +357,9 @@ class SelectContent(RadixThemesComponent):
side_offset: The distance in pixels from the anchor. Only available when position is set to popper.
align: The preferred alignment against the anchor. May change when collisions occur. Only available when position is set to popper.
align_offset: The vertical distance in pixels from the anchor. Only available when position is set to popper.
+ on_close_auto_focus: Fired when the select content is closed.
+ on_escape_key_down: Fired when the escape key is pressed.
+ on_pointer_down_outside: Fired when a pointer down event happens outside the select content.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -475,52 +384,22 @@ class SelectGroup(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SelectGroup":
"""Create a new component instance.
@@ -556,52 +435,22 @@ class SelectItem(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SelectItem":
"""Create a new component instance.
@@ -637,52 +486,22 @@ class SelectLabel(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SelectLabel":
"""Create a new component instance.
@@ -716,52 +535,22 @@ class SelectSeparator(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SelectSeparator":
"""Create a new component instance.
@@ -790,100 +579,100 @@ class HighLevelSelect(SelectRoot):
def create( # type: ignore
cls,
*children,
- items: Optional[Union[Var[List[str]], List[str]]] = None,
+ items: Optional[Union[List[str], Var[List[str]]]] = None,
placeholder: Optional[Union[Var[str], str]] = None,
label: Optional[Union[Var[str], str]] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft", "ghost"]],
- Literal["classic", "surface", "soft", "ghost"],
+ Literal["classic", "ghost", "soft", "surface"],
+ Var[Literal["classic", "ghost", "soft", "surface"]],
]
] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
width: Optional[Union[Var[str], str]] = None,
position: Optional[
Union[
- Var[Literal["item-aligned", "popper"]],
Literal["item-aligned", "popper"],
+ Var[Literal["item-aligned", "popper"]],
]
] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
default_value: Optional[Union[Var[str], str]] = None,
@@ -898,58 +687,28 @@ class HighLevelSelect(SelectRoot):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "HighLevelSelect":
"""Create a select component.
@@ -973,6 +732,8 @@ class HighLevelSelect(SelectRoot):
name: The name of the select control when submitting the form.
disabled: When True, prevents the user from interacting with select.
required: When True, indicates that the user must select a value before the owning form can be submitted.
+ on_change: Fired when the value of the select changes.
+ on_open_change: Fired when the select is opened or closed.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -998,100 +759,100 @@ class Select(ComponentNamespace):
@staticmethod
def __call__(
*children,
- items: Optional[Union[Var[List[str]], List[str]]] = None,
+ items: Optional[Union[List[str], Var[List[str]]]] = None,
placeholder: Optional[Union[Var[str], str]] = None,
label: Optional[Union[Var[str], str]] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft", "ghost"]],
- Literal["classic", "surface", "soft", "ghost"],
+ Literal["classic", "ghost", "soft", "surface"],
+ Var[Literal["classic", "ghost", "soft", "surface"]],
]
] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
width: Optional[Union[Var[str], str]] = None,
position: Optional[
Union[
- Var[Literal["item-aligned", "popper"]],
Literal["item-aligned", "popper"],
+ Var[Literal["item-aligned", "popper"]],
]
] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
default_value: Optional[Union[Var[str], str]] = None,
@@ -1106,58 +867,28 @@ class Select(ComponentNamespace):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "HighLevelSelect":
"""Create a select component.
@@ -1181,6 +912,8 @@ class Select(ComponentNamespace):
name: The name of the select control when submitting the form.
disabled: When True, prevents the user from interacting with select.
required: When True, indicates that the user must select a value before the owning form can be submitted.
+ on_change: Fired when the value of the select changes.
+ on_open_change: Fired when the select is opened or closed.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/radix/themes/components/separator.py b/reflex/components/radix/themes/components/separator.py
index fbc445878..9fc06807a 100644
--- a/reflex/components/radix/themes/components/separator.py
+++ b/reflex/components/radix/themes/components/separator.py
@@ -3,12 +3,9 @@
from typing import Literal
from reflex.components.core.breakpoints import Responsive
-from reflex.vars import Var
+from reflex.vars.base import LiteralVar, Var
-from ..base import (
- LiteralAccentColor,
- RadixThemesComponent,
-)
+from ..base import LiteralAccentColor, RadixThemesComponent
LiteralSeperatorSize = Literal["1", "2", "3", "4"]
@@ -19,9 +16,7 @@ class Separator(RadixThemesComponent):
tag = "Separator"
# The size of the select: "1" | "2" | "3" | "4"
- size: Var[Responsive[LiteralSeperatorSize]] = Var.create_safe(
- "4", _var_is_string=True
- )
+ size: Var[Responsive[LiteralSeperatorSize]] = LiteralVar.create("4")
# The color of the select
color_scheme: Var[LiteralAccentColor]
diff --git a/reflex/components/radix/themes/components/separator.pyi b/reflex/components/radix/themes/components/separator.pyi
index 0c5dc64ec..7c4bcd55f 100644
--- a/reflex/components/radix/themes/components/separator.pyi
+++ b/reflex/components/radix/themes/components/separator.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -22,88 +22,88 @@ class Separator(RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4"]],
+ Literal["1", "2", "3", "4"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3", "4"]],
Literal["1", "2", "3", "4"],
]
],
- Literal["1", "2", "3", "4"],
- Breakpoints[str, Literal["1", "2", "3", "4"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
orientation: Optional[
Union[
+ Breakpoints[str, Literal["horizontal", "vertical"]],
+ Literal["horizontal", "vertical"],
Var[
Union[
Breakpoints[str, Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
]
],
- Literal["horizontal", "vertical"],
- Breakpoints[str, Literal["horizontal", "vertical"]],
]
] = None,
decorative: Optional[Union[Var[bool], bool]] = None,
@@ -112,52 +112,22 @@ class Separator(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Separator":
"""Create a new component instance.
diff --git a/reflex/components/radix/themes/components/skeleton.py b/reflex/components/radix/themes/components/skeleton.py
index 0738512aa..1fb6390a1 100644
--- a/reflex/components/radix/themes/components/skeleton.py
+++ b/reflex/components/radix/themes/components/skeleton.py
@@ -1,7 +1,7 @@
"""Skeleton theme from Radix components."""
from reflex.components.core.breakpoints import Responsive
-from reflex.vars import Var
+from reflex.vars.base import Var
from ..base import RadixLoadingProp, RadixThemesComponent
diff --git a/reflex/components/radix/themes/components/skeleton.pyi b/reflex/components/radix/themes/components/skeleton.pyi
index 3f2c048f6..859954ccc 100644
--- a/reflex/components/radix/themes/components/skeleton.pyi
+++ b/reflex/components/radix/themes/components/skeleton.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixLoadingProp, RadixThemesComponent
@@ -19,22 +19,22 @@ class Skeleton(RadixLoadingProp, RadixThemesComponent):
cls,
*children,
width: Optional[
- Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]]
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
] = None,
min_width: Optional[
- Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]]
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
] = None,
max_width: Optional[
- Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]]
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
] = None,
height: Optional[
- Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]]
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
] = None,
min_height: Optional[
- Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]]
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
] = None,
max_height: Optional[
- Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]]
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
] = None,
loading: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
@@ -42,52 +42,22 @@ class Skeleton(RadixLoadingProp, RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Skeleton":
"""Create a new component instance.
diff --git a/reflex/components/radix/themes/components/slider.py b/reflex/components/radix/themes/components/slider.py
index c03fffe7b..6acc21497 100644
--- a/reflex/components/radix/themes/components/slider.py
+++ b/reflex/components/radix/themes/components/slider.py
@@ -1,15 +1,20 @@
"""Interactive components provided by @radix-ui/themes."""
+from __future__ import annotations
+
from typing import List, Literal, Optional, Union
from reflex.components.component import Component
from reflex.components.core.breakpoints import Responsive
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, passthrough_event_spec
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- RadixThemesComponent,
+from ..base import LiteralAccentColor, RadixThemesComponent
+
+on_value_event_spec = (
+ passthrough_event_spec(list[Union[int, float]]),
+ passthrough_event_spec(list[int]),
+ passthrough_event_spec(list[float]),
)
@@ -45,6 +50,9 @@ class Slider(RadixThemesComponent):
# The name of the slider. Submitted with its owning form as part of a name/value pair.
name: Var[str]
+ # The width of the slider.
+ width: Var[Optional[str]] = Var.create("100%")
+
# The minimum value of the slider.
min: Var[Union[float, int]]
@@ -64,29 +72,28 @@ class Slider(RadixThemesComponent):
_rename_props = {"onChange": "onValueChange"}
# Fired when the value of the slider changes.
- on_change: EventHandler[lambda e0: [e0]]
+ on_change: EventHandler[on_value_event_spec]
# Fired when a thumb is released after being dragged.
- on_value_commit: EventHandler[lambda e0: [e0]]
+ on_value_commit: EventHandler[on_value_event_spec]
@classmethod
def create(
cls,
*children,
- width: Optional[str] = "100%",
**props,
) -> Component:
"""Create a Slider component.
Args:
*children: The children of the component.
- width: The width of the slider.
**props: The properties of the component.
Returns:
The component.
"""
default_value = props.pop("default_value", [50])
+ width = props.pop("width", "100%")
if isinstance(default_value, Var):
if issubclass(default_value._var_type, (int, float)):
diff --git a/reflex/components/radix/themes/components/slider.pyi b/reflex/components/radix/themes/components/slider.pyi
index 57fda44d2..f2552fbc6 100644
--- a/reflex/components/radix/themes/components/slider.pyi
+++ b/reflex/components/radix/themes/components/slider.pyi
@@ -3,128 +3,134 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType, passthrough_event_spec
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
+on_value_event_spec = (
+ passthrough_event_spec(list[Union[int, float]]),
+ passthrough_event_spec(list[int]),
+ passthrough_event_spec(list[float]),
+)
+
class Slider(RadixThemesComponent):
@overload
@classmethod
def create( # type: ignore
cls,
*children,
- width: Optional[str] = "100%",
as_child: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "full"]], Literal["none", "small", "full"]
+ Literal["full", "none", "small"], Var[Literal["full", "none", "small"]]
]
] = None,
default_value: Optional[
Union[
- Var[Union[List[Union[float, int]], float, int]],
List[Union[float, int]],
+ Var[Union[List[Union[float, int]], float, int]],
float,
int,
]
] = None,
value: Optional[
- Union[Var[List[Union[float, int]]], List[Union[float, int]]]
+ Union[List[Union[float, int]], Var[List[Union[float, int]]]]
] = None,
name: Optional[Union[Var[str], str]] = None,
+ width: Optional[Union[Var[Optional[str]], str]] = None,
min: Optional[Union[Var[Union[float, int]], float, int]] = None,
max: Optional[Union[Var[Union[float, int]], float, int]] = None,
step: Optional[Union[Var[Union[float, int]], float, int]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
orientation: Optional[
Union[
- Var[Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
style: Optional[Style] = None,
@@ -132,57 +138,41 @@ class Slider(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[list[Union[int, float]]], BASE_STATE],
+ ],
+ Union[EventType[[], BASE_STATE], EventType[[list[int]], BASE_STATE]],
+ Union[EventType[[], BASE_STATE], EventType[[list[float]], BASE_STATE]],
+ ]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
on_value_commit: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[list[Union[int, float]]], BASE_STATE],
+ ],
+ Union[EventType[[], BASE_STATE], EventType[[list[int]], BASE_STATE]],
+ Union[EventType[[], BASE_STATE], EventType[[list[float]], BASE_STATE]],
+ ]
] = None,
**props,
) -> "Slider":
@@ -190,7 +180,6 @@ class Slider(RadixThemesComponent):
Args:
*children: The children of the component.
- width: The width of the slider.
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
size: Button size "1" - "3"
variant: Variant of button
@@ -200,11 +189,14 @@ class Slider(RadixThemesComponent):
default_value: The value of the slider when initially rendered. Use when you do not need to control the state of the slider.
value: The controlled value of the slider. Must be used in conjunction with onValueChange.
name: The name of the slider. Submitted with its owning form as part of a name/value pair.
+ width: The width of the slider.
min: The minimum value of the slider.
max: The maximum value of the slider.
step: The step value of the slider.
disabled: Whether the slider is disabled
orientation: The orientation of the slider.
+ on_change: Fired when the value of the slider changes.
+ on_value_commit: Fired when a thumb is released after being dragged.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/radix/themes/components/spinner.py b/reflex/components/radix/themes/components/spinner.py
index 22f5bba0b..620d248c4 100644
--- a/reflex/components/radix/themes/components/spinner.py
+++ b/reflex/components/radix/themes/components/spinner.py
@@ -3,12 +3,9 @@
from typing import Literal
from reflex.components.core.breakpoints import Responsive
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- RadixLoadingProp,
- RadixThemesComponent,
-)
+from ..base import RadixLoadingProp, RadixThemesComponent
LiteralSpinnerSize = Literal["1", "2", "3"]
diff --git a/reflex/components/radix/themes/components/spinner.pyi b/reflex/components/radix/themes/components/spinner.pyi
index f061e5813..1c2b9c65e 100644
--- a/reflex/components/radix/themes/components/spinner.pyi
+++ b/reflex/components/radix/themes/components/spinner.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixLoadingProp, RadixThemesComponent
@@ -22,13 +22,13 @@ class Spinner(RadixLoadingProp, RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
loading: Optional[Union[Var[bool], bool]] = None,
@@ -37,52 +37,22 @@ class Spinner(RadixLoadingProp, RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Spinner":
"""Create a new component instance.
diff --git a/reflex/components/radix/themes/components/switch.py b/reflex/components/radix/themes/components/switch.py
index f5109faf5..2af4f55bb 100644
--- a/reflex/components/radix/themes/components/switch.py
+++ b/reflex/components/radix/themes/components/switch.py
@@ -3,13 +3,10 @@
from typing import Literal
from reflex.components.core.breakpoints import Responsive
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, passthrough_event_spec
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- RadixThemesComponent,
-)
+from ..base import LiteralAccentColor, RadixThemesComponent
LiteralSwitchSize = Literal["1", "2", "3"]
@@ -59,7 +56,7 @@ class Switch(RadixThemesComponent):
_rename_props = {"onChange": "onCheckedChange"}
# Fired when the value of the switch changes
- on_change: EventHandler[lambda checked: [checked]]
+ on_change: EventHandler[passthrough_event_spec(bool)]
switch = Switch.create
diff --git a/reflex/components/radix/themes/components/switch.pyi b/reflex/components/radix/themes/components/switch.pyi
index cd01cc604..4aabd7da2 100644
--- a/reflex/components/radix/themes/components/switch.pyi
+++ b/reflex/components/radix/themes/components/switch.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -29,87 +29,87 @@ class Switch(RadixThemesComponent):
value: Optional[Union[Var[str], str]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "full"]], Literal["none", "small", "full"]
+ Literal["full", "none", "small"], Var[Literal["full", "none", "small"]]
]
] = None,
style: Optional[Style] = None,
@@ -117,55 +117,25 @@ class Switch(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Switch":
"""Create a new component instance.
@@ -187,6 +157,7 @@ class Switch(RadixThemesComponent):
color_scheme: Override theme color for switch
high_contrast: Whether to render the switch with higher contrast color against background
radius: Override theme radius for switch: "none" | "small" | "full"
+ on_change: Fired when the value of the switch changes
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/radix/themes/components/table.py b/reflex/components/radix/themes/components/table.py
index 27b0e3563..a16002f58 100644
--- a/reflex/components/radix/themes/components/table.py
+++ b/reflex/components/radix/themes/components/table.py
@@ -5,11 +5,9 @@ from typing import List, Literal
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- RadixThemesComponent,
-)
+from ..base import CommonPaddingProps, RadixThemesComponent
class TableRoot(elements.Table, RadixThemesComponent):
@@ -53,6 +51,12 @@ class TableColumnHeaderCell(elements.Th, RadixThemesComponent):
# The justification of the column
justify: Var[Literal["start", "center", "end"]]
+ # The minimum width of the cell
+ min_width: Var[Responsive[str]]
+
+ # The maximum width of the cell
+ max_width: Var[Responsive[str]]
+
_invalid_children: List[str] = [
"TableBody",
"TableHeader",
@@ -78,7 +82,7 @@ class TableBody(elements.Tbody, RadixThemesComponent):
_valid_parents: List[str] = ["TableRoot"]
-class TableCell(elements.Td, RadixThemesComponent):
+class TableCell(elements.Td, CommonPaddingProps, RadixThemesComponent):
"""A cell containing data."""
tag = "Table.Cell"
@@ -86,6 +90,12 @@ class TableCell(elements.Td, RadixThemesComponent):
# The justification of the column
justify: Var[Literal["start", "center", "end"]]
+ # The minimum width of the cell
+ min_width: Var[Responsive[str]]
+
+ # The maximum width of the cell
+ max_width: Var[Responsive[str]]
+
_invalid_children: List[str] = [
"TableBody",
"TableHeader",
@@ -95,7 +105,7 @@ class TableCell(elements.Td, RadixThemesComponent):
]
-class TableRowHeaderCell(elements.Th, RadixThemesComponent):
+class TableRowHeaderCell(elements.Th, CommonPaddingProps, RadixThemesComponent):
"""A table cell that is semantically treated as a row header."""
tag = "Table.RowHeaderCell"
@@ -103,6 +113,12 @@ class TableRowHeaderCell(elements.Th, RadixThemesComponent):
# The justification of the column
justify: Var[Literal["start", "center", "end"]]
+ # The minimum width of the cell
+ min_width: Var[Responsive[str]]
+
+ # The maximum width of the cell
+ max_width: Var[Responsive[str]]
+
_invalid_children: List[str] = [
"TableBody",
"TableHeader",
diff --git a/reflex/components/radix/themes/components/table.pyi b/reflex/components/radix/themes/components/table.pyi
index 01b4e61c4..99a0ba96d 100644
--- a/reflex/components/radix/themes/components/table.pyi
+++ b/reflex/components/radix/themes/components/table.pyi
@@ -3,16 +3,16 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
-from ..base import RadixThemesComponent
+from ..base import CommonPaddingProps, RadixThemesComponent
class TableRoot(elements.Table, RadixThemesComponent):
@overload
@@ -22,95 +22,65 @@ class TableRoot(elements.Table, RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
- Union[Var[Literal["surface", "ghost"]], Literal["surface", "ghost"]]
+ Union[Literal["ghost", "surface"], Var[Literal["ghost", "surface"]]]
] = None,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- summary: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ summary: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TableRoot":
"""Create a new component instance.
@@ -124,7 +94,7 @@ class TableRoot(elements.Table, RadixThemesComponent):
variant: The variant of the table
align: Alignment of the table
summary: Provides a summary of the table's purpose and structure
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -159,82 +129,52 @@ class TableHeader(elements.Thead, RadixThemesComponent):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TableHeader":
"""Create a new component instance.
@@ -245,7 +185,7 @@ class TableHeader(elements.Thead, RadixThemesComponent):
Args:
*children: Child components.
align: Alignment of the content within the table header
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -282,85 +222,55 @@ class TableRow(elements.Tr, RadixThemesComponent):
*children,
align: Optional[
Union[
- Var[Literal["start", "center", "end", "baseline"]],
- Literal["start", "center", "end", "baseline"],
+ Literal["baseline", "center", "end", "start"],
+ Var[Literal["baseline", "center", "end", "start"]],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TableRow":
"""Create a new component instance.
@@ -371,7 +281,7 @@ class TableRow(elements.Tr, RadixThemesComponent):
Args:
*children: Child components.
align: Alignment of the content within the table row
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -408,90 +318,66 @@ class TableColumnHeaderCell(elements.Th, RadixThemesComponent):
*children,
justify: Optional[
Union[
- Var[Literal["start", "center", "end"]],
- Literal["start", "center", "end"],
+ Literal["center", "end", "start"],
+ Var[Literal["center", "end", "start"]],
]
] = None,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- scope: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ min_width: Optional[
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
+ ] = None,
+ max_width: Optional[
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
+ ] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ scope: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TableColumnHeaderCell":
"""Create a new component instance.
@@ -502,12 +388,14 @@ class TableColumnHeaderCell(elements.Th, RadixThemesComponent):
Args:
*children: Child components.
justify: The justification of the column
+ min_width: The minimum width of the cell
+ max_width: The maximum width of the cell
align: Alignment of the content within the table header cell
col_span: Number of columns a header cell should span
headers: IDs of the headers associated with this header cell
row_span: Number of rows a header cell should span
scope: Scope of the header cell (row, col, rowgroup, colgroup)
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -542,82 +430,52 @@ class TableBody(elements.Tbody, RadixThemesComponent):
def create( # type: ignore
cls,
*children,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TableBody":
"""Create a new component instance.
@@ -628,7 +486,7 @@ class TableBody(elements.Tbody, RadixThemesComponent):
Args:
*children: Child components.
align: Alignment of the content within the table body
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -657,7 +515,7 @@ class TableBody(elements.Tbody, RadixThemesComponent):
"""
...
-class TableCell(elements.Td, RadixThemesComponent):
+class TableCell(elements.Td, CommonPaddingProps, RadixThemesComponent):
@overload
@classmethod
def create( # type: ignore
@@ -665,89 +523,184 @@ class TableCell(elements.Td, RadixThemesComponent):
*children,
justify: Optional[
Union[
- Var[Literal["start", "center", "end"]],
- Literal["start", "center", "end"],
+ Literal["center", "end", "start"],
+ Var[Literal["center", "end", "start"]],
]
] = None,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ min_width: Optional[
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
+ ] = None,
+ max_width: Optional[
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
+ ] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ p: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ px: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ py: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ pt: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ pr: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ pb: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ pl: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TableCell":
"""Create a new component instance.
@@ -758,11 +711,13 @@ class TableCell(elements.Td, RadixThemesComponent):
Args:
*children: Child components.
justify: The justification of the column
+ min_width: The minimum width of the cell
+ max_width: The maximum width of the cell
align: Alignment of the content within the table cell
col_span: Number of columns a cell should span
headers: IDs of the headers associated with this cell
row_span: Number of rows a cell should span
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -778,6 +733,13 @@ class TableCell(elements.Td, RadixThemesComponent):
spell_check: Defines whether the element may be checked for spelling errors.
tab_index: Defines the position of the current element in the tabbing order.
title: Defines a tooltip for the element.
+ p: Padding: "0" - "9"
+ px: Padding horizontal: "0" - "9"
+ py: Padding vertical: "0" - "9"
+ pt: Padding top: "0" - "9"
+ pr: Padding right: "0" - "9"
+ pb: Padding bottom: "0" - "9"
+ pl: Padding left: "0" - "9"
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -791,7 +753,7 @@ class TableCell(elements.Td, RadixThemesComponent):
"""
...
-class TableRowHeaderCell(elements.Th, RadixThemesComponent):
+class TableRowHeaderCell(elements.Th, CommonPaddingProps, RadixThemesComponent):
@overload
@classmethod
def create( # type: ignore
@@ -799,90 +761,185 @@ class TableRowHeaderCell(elements.Th, RadixThemesComponent):
*children,
justify: Optional[
Union[
- Var[Literal["start", "center", "end"]],
- Literal["start", "center", "end"],
+ Literal["center", "end", "start"],
+ Var[Literal["center", "end", "start"]],
]
] = None,
- align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- scope: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ min_width: Optional[
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
+ ] = None,
+ max_width: Optional[
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
+ ] = None,
+ align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ scope: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ p: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ px: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ py: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ pt: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ pr: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ pb: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
+ ] = None,
+ pl: Optional[
+ Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[
+ Union[
+ Breakpoints[
+ str,
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ ]
+ ],
+ ]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TableRowHeaderCell":
"""Create a new component instance.
@@ -893,12 +950,14 @@ class TableRowHeaderCell(elements.Th, RadixThemesComponent):
Args:
*children: Child components.
justify: The justification of the column
+ min_width: The minimum width of the cell
+ max_width: The maximum width of the cell
align: Alignment of the content within the table header cell
col_span: Number of columns a header cell should span
headers: IDs of the headers associated with this header cell
row_span: Number of rows a header cell should span
scope: Scope of the header cell (row, col, rowgroup, colgroup)
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -914,6 +973,13 @@ class TableRowHeaderCell(elements.Th, RadixThemesComponent):
spell_check: Defines whether the element may be checked for spelling errors.
tab_index: Defines the position of the current element in the tabbing order.
title: Defines a tooltip for the element.
+ p: Padding: "0" - "9"
+ px: Padding horizontal: "0" - "9"
+ py: Padding vertical: "0" - "9"
+ pt: Padding top: "0" - "9"
+ pr: Padding right: "0" - "9"
+ pb: Padding bottom: "0" - "9"
+ pl: Padding left: "0" - "9"
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/radix/themes/components/tabs.py b/reflex/components/radix/themes/components/tabs.py
index 08e09262b..adfb32fab 100644
--- a/reflex/components/radix/themes/components/tabs.py
+++ b/reflex/components/radix/themes/components/tabs.py
@@ -7,13 +7,10 @@ from typing import Any, Dict, List, Literal
from reflex.components.component import Component, ComponentNamespace
from reflex.components.core.breakpoints import Responsive
from reflex.components.core.colors import color
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, passthrough_event_spec
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- RadixThemesComponent,
-)
+from ..base import LiteralAccentColor, RadixThemesComponent
vertical_orientation_css = "&[data-orientation='vertical']"
@@ -42,7 +39,7 @@ class TabsRoot(RadixThemesComponent):
_rename_props = {"onChange": "onValueChange"}
# Fired when the value of the tabs changes.
- on_change: EventHandler[lambda e0: [e0]]
+ on_change: EventHandler[passthrough_event_spec(str)]
def add_style(self) -> Dict[str, Any] | None:
"""Add style for the component.
diff --git a/reflex/components/radix/themes/components/tabs.pyi b/reflex/components/radix/themes/components/tabs.pyi
index 7d324e96d..8830c8e21 100644
--- a/reflex/components/radix/themes/components/tabs.pyi
+++ b/reflex/components/radix/themes/components/tabs.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -26,68 +26,38 @@ class TabsRoot(RadixThemesComponent):
value: Optional[Union[Var[str], str]] = None,
orientation: Optional[
Union[
- Var[Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
- dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None,
+ dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None,
activation_mode: Optional[
- Union[Var[Literal["automatic", "manual"]], Literal["automatic", "manual"]]
+ Union[Literal["automatic", "manual"], Var[Literal["automatic", "manual"]]]
] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TabsRoot":
"""Create a new component instance.
@@ -102,6 +72,7 @@ class TabsRoot(RadixThemesComponent):
orientation: The orientation of the tabs.
dir: Reading direction of the tabs.
activation_mode: The mode of activation for the tabs. "automatic" will activate the tab when focused. "manual" will activate the tab when clicked.
+ on_change: Fired when the value of the tabs changes.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -124,9 +95,9 @@ class TabsList(RadixThemesComponent):
*children,
size: Optional[
Union[
- Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]],
- Literal["1", "2"],
Breakpoints[str, Literal["1", "2"]],
+ Literal["1", "2"],
+ Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]],
]
] = None,
loop: Optional[Union[Var[bool], bool]] = None,
@@ -135,52 +106,22 @@ class TabsList(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TabsList":
"""Create a new component instance.
@@ -215,63 +156,63 @@ class TabsTrigger(RadixThemesComponent):
disabled: Optional[Union[Var[bool], bool]] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -280,52 +221,22 @@ class TabsTrigger(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TabsTrigger":
"""Create a TabsTrigger component.
@@ -364,52 +275,22 @@ class TabsContent(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TabsContent":
"""Create a new component instance.
@@ -447,68 +328,38 @@ class Tabs(ComponentNamespace):
value: Optional[Union[Var[str], str]] = None,
orientation: Optional[
Union[
- Var[Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
- dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None,
+ dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None,
activation_mode: Optional[
- Union[Var[Literal["automatic", "manual"]], Literal["automatic", "manual"]]
+ Union[Literal["automatic", "manual"], Var[Literal["automatic", "manual"]]]
] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TabsRoot":
"""Create a new component instance.
@@ -523,6 +374,7 @@ class Tabs(ComponentNamespace):
orientation: The orientation of the tabs.
dir: Reading direction of the tabs.
activation_mode: The mode of activation for the tabs. "automatic" will activate the tab when focused. "manual" will activate the tab when clicked.
+ on_change: Fired when the value of the tabs changes.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/radix/themes/components/text_area.py b/reflex/components/radix/themes/components/text_area.py
index 5218f1d7b..83fa8a593 100644
--- a/reflex/components/radix/themes/components/text_area.py
+++ b/reflex/components/radix/themes/components/text_area.py
@@ -6,14 +6,9 @@ from reflex.components.component import Component
from reflex.components.core.breakpoints import Responsive
from reflex.components.core.debounce import DebounceInput
from reflex.components.el import elements
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- LiteralRadius,
- RadixThemesComponent,
-)
+from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent
LiteralTextAreaSize = Literal["1", "2", "3"]
@@ -46,6 +41,9 @@ class TextArea(RadixThemesComponent, elements.Textarea):
# Automatically focuses the textarea when the page loads
auto_focus: Var[bool]
+ # The default value of the textarea when initially rendered
+ default_value: Var[str]
+
# Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
dirname: Var[str]
@@ -82,21 +80,6 @@ class TextArea(RadixThemesComponent, elements.Textarea):
# How the text in the textarea is to be wrapped when submitting the form
wrap: Var[str]
- # Fired when the value of the textarea changes.
- on_change: EventHandler[lambda e0: [e0.target.value]]
-
- # Fired when the textarea is focused.
- on_focus: EventHandler[lambda e0: [e0.target.value]]
-
- # Fired when the textarea is blurred.
- on_blur: EventHandler[lambda e0: [e0.target.value]]
-
- # Fired when a key is pressed down.
- on_key_down: EventHandler[lambda e0: [e0.key]]
-
- # Fired when a key is released.
- on_key_up: EventHandler[lambda e0: [e0.key]]
-
@classmethod
def create(cls, *children, **props) -> Component:
"""Create an Input component.
diff --git a/reflex/components/radix/themes/components/text_area.pyi b/reflex/components/radix/themes/components/text_area.pyi
index 231158c84..f0903ba98 100644
--- a/reflex/components/radix/themes/components/text_area.pyi
+++ b/reflex/components/radix/themes/components/text_area.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType, KeyInputInfo
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -24,108 +24,109 @@ class TextArea(RadixThemesComponent, elements.Textarea):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
resize: Optional[
Union[
+ Breakpoints[str, Literal["both", "horizontal", "none", "vertical"]],
+ Literal["both", "horizontal", "none", "vertical"],
Var[
Union[
Breakpoints[
- str, Literal["none", "vertical", "horizontal", "both"]
+ str, Literal["both", "horizontal", "none", "vertical"]
],
- Literal["none", "vertical", "horizontal", "both"],
+ Literal["both", "horizontal", "none", "vertical"],
]
],
- Literal["none", "vertical", "horizontal", "both"],
- Breakpoints[str, Literal["none", "vertical", "horizontal", "both"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
auto_complete: Optional[Union[Var[bool], bool]] = None,
auto_focus: Optional[Union[Var[bool], bool]] = None,
+ default_value: Optional[Union[Var[str], str]] = None,
dirname: Optional[Union[Var[str], str]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
- form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
max_length: Optional[Union[Var[int], int]] = None,
min_length: Optional[Union[Var[int], int]] = None,
name: Optional[Union[Var[str], str]] = None,
@@ -136,92 +137,74 @@ class TextArea(RadixThemesComponent, elements.Textarea):
value: Optional[Union[Var[str], str]] = None,
wrap: Optional[Union[Var[str], str]] = None,
auto_height: Optional[Union[Var[bool], bool]] = None,
- cols: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ cols: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_submit: Optional[Union[Var[bool], bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
on_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[str], BASE_STATE],
+ EventType[[str, KeyInputInfo], BASE_STATE],
+ ]
] = None,
on_key_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[str], BASE_STATE],
+ EventType[[str, KeyInputInfo], BASE_STATE],
+ ]
] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TextArea":
"""Create an Input component.
@@ -235,6 +218,7 @@ class TextArea(RadixThemesComponent, elements.Textarea):
radius: The radius of the text area: "none" | "small" | "medium" | "large" | "full"
auto_complete: Whether the form control should have autocomplete enabled
auto_focus: Automatically focuses the textarea when the page loads
+ default_value: The default value of the textarea when initially rendered
dirname: Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
disabled: Disables the textarea
form: Associates the textarea with a form (by id)
@@ -250,7 +234,12 @@ class TextArea(RadixThemesComponent, elements.Textarea):
auto_height: Automatically fit the content height to the text (use min-height with this prop)
cols: Visible width of the text control, in average character widths
enter_key_submit: Enter key submits form (shift-enter adds new line)
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ on_change: Fired when the input value changes
+ on_focus: Fired when the input gains focus
+ on_blur: Fired when the input loses focus
+ on_key_down: Fired when a key is pressed down
+ on_key_up: Fired when a key is released
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/components/text_field.py b/reflex/components/radix/themes/components/text_field.py
index c6d7ddf48..c8bdab443 100644
--- a/reflex/components/radix/themes/components/text_field.py
+++ b/reflex/components/radix/themes/components/text_field.py
@@ -4,27 +4,22 @@ from __future__ import annotations
from typing import Literal, Union
-from reflex.components.base.fragment import Fragment
from reflex.components.component import Component, ComponentNamespace
from reflex.components.core.breakpoints import Responsive
from reflex.components.core.debounce import DebounceInput
from reflex.components.el import elements
-from reflex.event import EventHandler
-from reflex.style import Style, format_as_emotion
-from reflex.utils import console
-from reflex.vars import Var
+from reflex.event import EventHandler, input_event, key_event
+from reflex.utils.types import is_optional
+from reflex.vars.base import Var
+from reflex.vars.number import ternary_operation
-from ..base import (
- LiteralAccentColor,
- LiteralRadius,
- RadixThemesComponent,
-)
+from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent
LiteralTextFieldSize = Literal["1", "2", "3"]
LiteralTextFieldVariant = Literal["classic", "surface", "soft"]
-class TextFieldRoot(elements.Div, RadixThemesComponent):
+class TextFieldRoot(elements.Input, RadixThemesComponent):
"""Captures user input with an optional slot for buttons and icons."""
tag = "TextField.Root"
@@ -74,20 +69,23 @@ class TextFieldRoot(elements.Div, RadixThemesComponent):
# Value of the input
value: Var[Union[str, int, float]]
+ # References a datalist for suggested options
+ list: Var[Union[str, int, bool]]
+
# Fired when the value of the textarea changes.
- on_change: EventHandler[lambda e0: [e0.target.value]]
+ on_change: EventHandler[input_event]
# Fired when the textarea is focused.
- on_focus: EventHandler[lambda e0: [e0.target.value]]
+ on_focus: EventHandler[input_event]
# Fired when the textarea is blurred.
- on_blur: EventHandler[lambda e0: [e0.target.value]]
+ on_blur: EventHandler[input_event]
# Fired when a key is pressed down.
- on_key_down: EventHandler[lambda e0: [e0.key]]
+ on_key_down: EventHandler[key_event]
# Fired when a key is released.
- on_key_up: EventHandler[lambda e0: [e0.key]]
+ on_key_up: EventHandler[key_event]
@classmethod
def create(cls, *children, **props) -> Component:
@@ -100,86 +98,25 @@ class TextFieldRoot(elements.Div, RadixThemesComponent):
Returns:
The component.
"""
+ value = props.get("value")
+
+ # React expects an empty string(instead of null) for controlled inputs.
+ if value is not None and is_optional(
+ (value_var := Var.create(value))._var_type
+ ):
+ props["value"] = ternary_operation(
+ (value_var != Var.create(None)) # pyright: ignore [reportGeneralTypeIssues]
+ & (value_var != Var(_js_expr="undefined")),
+ value,
+ Var.create(""),
+ )
+
component = super().create(*children, **props)
if props.get("value") is not None and props.get("on_change") is not None:
# create a debounced input if the user requests full control to avoid typing jank
return DebounceInput.create(component)
return component
- @classmethod
- def create_root_deprecated(cls, *children, **props) -> Component:
- """Create a Fragment component (wrapper for deprecated name).
-
- Copy the attributes that were previously defined on TextFieldRoot in 0.4.9 to
- any child input elements (via custom_attrs).
-
- Args:
- *children: The children of the component.
- **props: The properties of the component.
-
- Returns:
- The component.
- """
- console.deprecate(
- feature_name="rx.input.root",
- reason="use rx.input without the .root suffix",
- deprecation_version="0.5.0",
- removal_version="0.6.0",
- )
- inputs = [
- child
- for child in children
- if isinstance(child, (TextFieldRoot, DebounceInput))
- ]
- if not inputs:
- # Old-style where no explicit child input was provided
- return cls.create(*children, **props)
- slots = [child for child in children if isinstance(child, TextFieldSlot)]
- carry_props = {
- prop: props.pop(prop)
- for prop in ["size", "variant", "color_scheme", "radius"]
- if prop in props
- }
- template = cls.create(**props)
- for child in inputs:
- child.children.extend(slots)
- custom_attrs = child.custom_attrs
- custom_attrs.update(
- {
- prop: value
- for prop, value in carry_props.items()
- if prop not in custom_attrs and getattr(child, prop) is None
- }
- )
- style = Style(template.style)
- style.update(child.style)
- child._get_style = lambda style=style: {
- "css": Var.create(format_as_emotion(style))
- }
- for trigger in template.event_triggers:
- if trigger not in child.event_triggers:
- child.event_triggers[trigger] = template.event_triggers[trigger]
- return Fragment.create(*inputs)
-
- @classmethod
- def create_input_deprecated(cls, *children, **props) -> Component:
- """Create a TextFieldRoot component (wrapper for deprecated name).
-
- Args:
- *children: The children of the component.
- **props: The properties of the component.
-
- Returns:
- The component.
- """
- console.deprecate(
- feature_name="rx.input.input",
- reason="use rx.input without the .input suffix",
- deprecation_version="0.5.0",
- removal_version="0.6.0",
- )
- return cls.create(*children, **props)
-
class TextFieldSlot(RadixThemesComponent):
"""Contains icons or buttons associated with an Input."""
@@ -193,8 +130,6 @@ class TextFieldSlot(RadixThemesComponent):
class TextField(ComponentNamespace):
"""TextField components namespace."""
- root = staticmethod(TextFieldRoot.create_root_deprecated)
- input = staticmethod(TextFieldRoot.create_input_deprecated)
slot = staticmethod(TextFieldSlot.create)
__call__ = staticmethod(TextFieldRoot.create)
diff --git a/reflex/components/radix/themes/components/text_field.pyi b/reflex/components/radix/themes/components/text_field.pyi
index 86ba7e70f..81c991899 100644
--- a/reflex/components/radix/themes/components/text_field.pyi
+++ b/reflex/components/radix/themes/components/text_field.pyi
@@ -3,21 +3,21 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
-from reflex.components.component import Component, ComponentNamespace
+from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType, KeyInputInfo
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
LiteralTextFieldSize = Literal["1", "2", "3"]
LiteralTextFieldVariant = Literal["classic", "surface", "soft"]
-class TextFieldRoot(elements.Div, RadixThemesComponent):
+class TextFieldRoot(elements.Input, RadixThemesComponent):
@overload
@classmethod
def create( # type: ignore
@@ -25,87 +25,87 @@ class TextFieldRoot(elements.Div, RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
auto_complete: Optional[Union[Var[bool], bool]] = None,
@@ -118,103 +118,110 @@ class TextFieldRoot(elements.Div, RadixThemesComponent):
read_only: Optional[Union[Var[bool], bool]] = None,
required: Optional[Union[Var[bool], bool]] = None,
type: Optional[Union[Var[str], str]] = None,
- value: Optional[Union[Var[Union[float, int, str]], str, int, float]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None,
+ list: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ capture: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ checked: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ default_checked: Optional[Union[Var[bool], bool]] = None,
+ dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form_enc_type: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form_no_validate: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ max: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ min: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ pattern: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ step: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
on_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[str], BASE_STATE],
+ EventType[[str, KeyInputInfo], BASE_STATE],
+ ]
] = None,
on_key_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[str], BASE_STATE],
+ EventType[[str, KeyInputInfo], BASE_STATE],
+ ]
] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TextFieldRoot":
"""Create an Input component.
Args:
*children: The children of the component.
- size: Text field size "1" - "3"
+ size: Specifies the visible width of a text control
variant: Variant of text field: "classic" | "surface" | "soft"
color_scheme: Override theme color for text field
radius: Override theme radius for text field: "none" | "small" | "medium" | "large" | "full"
auto_complete: Whether the input should have autocomplete enabled
- default_value: The value of the input when initially rendered.
+ default_value: The initial value for a text field
disabled: Disables the input
max_length: Specifies the maximum number of characters allowed in the input
min_length: Specifies the minimum number of characters required in the input
@@ -224,7 +231,33 @@ class TextFieldRoot(elements.Div, RadixThemesComponent):
required: Indicates that the input is required
type: Specifies the type of input
value: Value of the input
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ list: References a datalist for suggested options
+ on_change: Fired when the input value changes
+ on_focus: Fired when the input gains focus
+ on_blur: Fired when the input loses focus
+ on_key_down: Fired when a key is pressed down
+ on_key_up: Fired when a key is released
+ accept: Accepted types of files when the input is file type
+ alt: Alternate text for input type="image"
+ auto_focus: Automatically focuses the input when the page loads
+ capture: Captures media from the user (camera or microphone)
+ checked: Indicates whether the input is checked (for checkboxes and radio buttons)
+ default_checked: The initial value (for checkboxes and radio buttons)
+ dirname: Name part of the input to submit in 'dir' and 'name' pair when form is submitted
+ form: Associates the input with a form (by id)
+ form_action: URL to send the form data to (for type="submit" buttons)
+ form_enc_type: How the form data should be encoded when submitting to the server (for type="submit" buttons)
+ form_method: HTTP method to use for sending form data (for type="submit" buttons)
+ form_no_validate: Bypasses form validation when submitting (for type="submit" buttons)
+ form_target: Specifies where to display the response after submitting the form (for type="submit" buttons)
+ max: Specifies the maximum value for the input
+ min: Specifies the minimum value for the input
+ multiple: Indicates whether multiple values can be entered in an input of the type email or file
+ pattern: Regex pattern the input's value must match to be valid
+ src: URL for image inputs
+ step: Specifies the legal number intervals for an input
+ use_map: Name of the image map used with the input
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -253,11 +286,6 @@ class TextFieldRoot(elements.Div, RadixThemesComponent):
"""
...
- @classmethod
- def create_root_deprecated(cls, *children, **props) -> Component: ...
- @classmethod
- def create_input_deprecated(cls, *children, **props) -> Component: ...
-
class TextFieldSlot(RadixThemesComponent):
@overload
@classmethod
@@ -266,63 +294,63 @@ class TextFieldSlot(RadixThemesComponent):
*children,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
@@ -331,52 +359,22 @@ class TextFieldSlot(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TextFieldSlot":
"""Create a new component instance.
@@ -401,8 +399,6 @@ class TextFieldSlot(RadixThemesComponent):
...
class TextField(ComponentNamespace):
- root = staticmethod(TextFieldRoot.create_root_deprecated)
- input = staticmethod(TextFieldRoot.create_input_deprecated)
slot = staticmethod(TextFieldSlot.create)
@staticmethod
@@ -410,87 +406,87 @@ class TextField(ComponentNamespace):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
variant: Optional[
Union[
- Var[Literal["classic", "surface", "soft"]],
- Literal["classic", "surface", "soft"],
+ Literal["classic", "soft", "surface"],
+ Var[Literal["classic", "soft", "surface"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
radius: Optional[
Union[
- Var[Literal["none", "small", "medium", "large", "full"]],
- Literal["none", "small", "medium", "large", "full"],
+ Literal["full", "large", "medium", "none", "small"],
+ Var[Literal["full", "large", "medium", "none", "small"]],
]
] = None,
auto_complete: Optional[Union[Var[bool], bool]] = None,
@@ -503,103 +499,110 @@ class TextField(ComponentNamespace):
read_only: Optional[Union[Var[bool], bool]] = None,
required: Optional[Union[Var[bool], bool]] = None,
type: Optional[Union[Var[str], str]] = None,
- value: Optional[Union[Var[Union[float, int, str]], str, int, float]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None,
+ list: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ capture: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ checked: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ default_checked: Optional[Union[Var[bool], bool]] = None,
+ dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form_enc_type: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ form_no_validate: Optional[
+ Union[Var[Union[bool, int, str]], bool, int, str]
+ ] = None,
+ form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ max: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ min: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ pattern: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ step: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
on_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[str], BASE_STATE],
+ EventType[[str, KeyInputInfo], BASE_STATE],
+ ]
] = None,
on_key_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[str], BASE_STATE],
+ EventType[[str, KeyInputInfo], BASE_STATE],
+ ]
] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "TextFieldRoot":
"""Create an Input component.
Args:
*children: The children of the component.
- size: Text field size "1" - "3"
+ size: Specifies the visible width of a text control
variant: Variant of text field: "classic" | "surface" | "soft"
color_scheme: Override theme color for text field
radius: Override theme radius for text field: "none" | "small" | "medium" | "large" | "full"
auto_complete: Whether the input should have autocomplete enabled
- default_value: The value of the input when initially rendered.
+ default_value: The initial value for a text field
disabled: Disables the input
max_length: Specifies the maximum number of characters allowed in the input
min_length: Specifies the minimum number of characters required in the input
@@ -609,7 +612,33 @@ class TextField(ComponentNamespace):
required: Indicates that the input is required
type: Specifies the type of input
value: Value of the input
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ list: References a datalist for suggested options
+ on_change: Fired when the input value changes
+ on_focus: Fired when the input gains focus
+ on_blur: Fired when the input loses focus
+ on_key_down: Fired when a key is pressed down
+ on_key_up: Fired when a key is released
+ accept: Accepted types of files when the input is file type
+ alt: Alternate text for input type="image"
+ auto_focus: Automatically focuses the input when the page loads
+ capture: Captures media from the user (camera or microphone)
+ checked: Indicates whether the input is checked (for checkboxes and radio buttons)
+ default_checked: The initial value (for checkboxes and radio buttons)
+ dirname: Name part of the input to submit in 'dir' and 'name' pair when form is submitted
+ form: Associates the input with a form (by id)
+ form_action: URL to send the form data to (for type="submit" buttons)
+ form_enc_type: How the form data should be encoded when submitting to the server (for type="submit" buttons)
+ form_method: HTTP method to use for sending form data (for type="submit" buttons)
+ form_no_validate: Bypasses form validation when submitting (for type="submit" buttons)
+ form_target: Specifies where to display the response after submitting the form (for type="submit" buttons)
+ max: Specifies the maximum value for the input
+ min: Specifies the minimum value for the input
+ multiple: Indicates whether multiple values can be entered in an input of the type email or file
+ pattern: Regex pattern the input's value must match to be valid
+ src: URL for image inputs
+ step: Specifies the legal number intervals for an input
+ use_map: Name of the image map used with the input
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/components/tooltip.py b/reflex/components/radix/themes/components/tooltip.py
index 9a1355be5..07bab1a4a 100644
--- a/reflex/components/radix/themes/components/tooltip.py
+++ b/reflex/components/radix/themes/components/tooltip.py
@@ -3,13 +3,11 @@
from typing import Dict, Literal, Union
from reflex.components.component import Component
-from reflex.event import EventHandler
+from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec
from reflex.utils import format
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- RadixThemesComponent,
-)
+from ..base import RadixThemesComponent
LiteralSideType = Literal[
"top",
@@ -85,13 +83,13 @@ class Tooltip(RadixThemesComponent):
aria_label: Var[str]
# Fired when the open state changes.
- on_open_change: EventHandler[lambda e0: [e0.target.value]]
+ on_open_change: EventHandler[passthrough_event_spec(bool)]
# Fired when the escape key is pressed.
- on_escape_key_down: EventHandler[lambda e0: [e0.target.value]]
+ on_escape_key_down: EventHandler[no_args_event_spec]
# Fired when the pointer is down outside the tooltip.
- on_pointer_down_outside: EventHandler[lambda e0: [e0.target.value]]
+ on_pointer_down_outside: EventHandler[no_args_event_spec]
@classmethod
def create(cls, *children, **props) -> Component:
diff --git a/reflex/components/radix/themes/components/tooltip.pyi b/reflex/components/radix/themes/components/tooltip.pyi
index 0628acff1..fab1d0c12 100644
--- a/reflex/components/radix/themes/components/tooltip.pyi
+++ b/reflex/components/radix/themes/components/tooltip.pyi
@@ -3,11 +3,11 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -26,30 +26,30 @@ class Tooltip(RadixThemesComponent):
open: Optional[Union[Var[bool], bool]] = None,
side: Optional[
Union[
- Var[Literal["top", "right", "bottom", "left"]],
- Literal["top", "right", "bottom", "left"],
+ Literal["bottom", "left", "right", "top"],
+ Var[Literal["bottom", "left", "right", "top"]],
]
] = None,
side_offset: Optional[Union[Var[Union[float, int]], float, int]] = None,
align: Optional[
Union[
- Var[Literal["start", "center", "end"]],
- Literal["start", "center", "end"],
+ Literal["center", "end", "start"],
+ Var[Literal["center", "end", "start"]],
]
] = None,
align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None,
avoid_collisions: Optional[Union[Var[bool], bool]] = None,
collision_padding: Optional[
Union[
+ Dict[str, Union[float, int]],
Var[Union[Dict[str, Union[float, int]], float, int]],
float,
int,
- Dict[str, Union[float, int]],
]
] = None,
arrow_padding: Optional[Union[Var[Union[float, int]], float, int]] = None,
sticky: Optional[
- Union[Var[Literal["partial", "always"]], Literal["partial", "always"]]
+ Union[Literal["always", "partial"], Var[Literal["always", "partial"]]]
] = None,
hide_when_detached: Optional[Union[Var[bool], bool]] = None,
delay_duration: Optional[Union[Var[Union[float, int]], float, int]] = None,
@@ -61,61 +61,27 @@ class Tooltip(RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_escape_key_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_pointer_down_outside: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Tooltip":
"""Initialize the Tooltip component.
@@ -140,6 +106,9 @@ class Tooltip(RadixThemesComponent):
disable_hoverable_content: Prevents Tooltip content from remaining open when hovering.
force_mount: Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
aria_label: By default, screenreaders will announce the content inside the component. If this is not descriptive enough, or you have content that cannot be announced, use aria-label as a more descriptive label.
+ on_open_change: Fired when the open state changes.
+ on_escape_key_down: Fired when the escape key is pressed.
+ on_pointer_down_outside: Fired when the pointer is down outside the tooltip.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/radix/themes/layout/__init__.pyi b/reflex/components/radix/themes/layout/__init__.pyi
index 1420299e0..6712a3068 100644
--- a/reflex/components/radix/themes/layout/__init__.pyi
+++ b/reflex/components/radix/themes/layout/__init__.pyi
@@ -9,6 +9,7 @@ from .container import container as container
from .flex import flex as flex
from .grid import grid as grid
from .list import list_item as list_item
+from .list import list_ns as list # noqa
from .list import ordered_list as ordered_list
from .list import unordered_list as unordered_list
from .section import section as section
diff --git a/reflex/components/radix/themes/layout/base.py b/reflex/components/radix/themes/layout/base.py
index dd598538e..f31f6a72c 100644
--- a/reflex/components/radix/themes/layout/base.py
+++ b/reflex/components/radix/themes/layout/base.py
@@ -5,44 +5,19 @@ from __future__ import annotations
from typing import Literal
from reflex.components.core.breakpoints import Responsive
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- CommonMarginProps,
- LiteralSpacing,
- RadixThemesComponent,
-)
+from ..base import CommonMarginProps, CommonPaddingProps, RadixThemesComponent
LiteralBoolNumber = Literal["0", "1"]
-class LayoutComponent(CommonMarginProps, RadixThemesComponent):
+class LayoutComponent(CommonMarginProps, CommonPaddingProps, RadixThemesComponent):
"""Box, Flex and Grid are foundational elements you'll use to construct
layouts. Box provides block-level spacing and sizing, while Flex and Grid
let you create flexible columns, rows and grids.
"""
- # Padding: "0" - "9"
- p: Var[Responsive[LiteralSpacing]]
-
- # Padding horizontal: "0" - "9"
- px: Var[Responsive[LiteralSpacing]]
-
- # Padding vertical: "0" - "9"
- py: Var[Responsive[LiteralSpacing]]
-
- # Padding top: "0" - "9"
- pt: Var[Responsive[LiteralSpacing]]
-
- # Padding right: "0" - "9"
- pr: Var[Responsive[LiteralSpacing]]
-
- # Padding bottom: "0" - "9"
- pb: Var[Responsive[LiteralSpacing]]
-
- # Padding left: "0" - "9"
- pl: Var[Responsive[LiteralSpacing]]
-
# Whether the element will take up the smallest possible space: "0" | "1"
flex_shrink: Var[Responsive[LiteralBoolNumber]]
diff --git a/reflex/components/radix/themes/layout/base.pyi b/reflex/components/radix/themes/layout/base.pyi
index 83e0e018f..440ec882a 100644
--- a/reflex/components/radix/themes/layout/base.pyi
+++ b/reflex/components/radix/themes/layout/base.pyi
@@ -3,25 +3,85 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
-from ..base import CommonMarginProps, RadixThemesComponent
+from ..base import CommonMarginProps, CommonPaddingProps, RadixThemesComponent
LiteralBoolNumber = Literal["0", "1"]
-class LayoutComponent(CommonMarginProps, RadixThemesComponent):
+class LayoutComponent(CommonMarginProps, CommonPaddingProps, RadixThemesComponent):
@overload
@classmethod
def create( # type: ignore
cls,
*children,
+ flex_shrink: Optional[
+ Union[
+ Breakpoints[str, Literal["0", "1"]],
+ Literal["0", "1"],
+ Var[Union[Breakpoints[str, Literal["0", "1"]], Literal["0", "1"]]],
+ ]
+ ] = None,
+ flex_grow: Optional[
+ Union[
+ Breakpoints[str, Literal["0", "1"]],
+ Literal["0", "1"],
+ Var[Union[Breakpoints[str, Literal["0", "1"]], Literal["0", "1"]]],
+ ]
+ ] = None,
+ m: Optional[
+ Union[
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ ]
+ ] = None,
+ mx: Optional[
+ Union[
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ ]
+ ] = None,
+ my: Optional[
+ Union[
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ ]
+ ] = None,
+ mt: Optional[
+ Union[
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ ]
+ ] = None,
+ mr: Optional[
+ Union[
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ ]
+ ] = None,
+ mb: Optional[
+ Union[
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ ]
+ ] = None,
+ ml: Optional[
+ Union[
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ ]
+ ] = None,
p: Optional[
Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -31,14 +91,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent):
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
- ],
]
] = None,
px: Optional[
Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -48,14 +108,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent):
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
- ],
]
] = None,
py: Optional[
Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -65,14 +125,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent):
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
- ],
]
] = None,
pt: Optional[
Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -82,14 +142,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent):
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
- ],
]
] = None,
pr: Optional[
Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -99,14 +159,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent):
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
- ],
]
] = None,
pb: Optional[
Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -116,14 +176,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent):
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
- ],
]
] = None,
pl: Optional[
Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -133,66 +193,6 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent):
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
- ],
- ]
- ] = None,
- flex_shrink: Optional[
- Union[
- Var[Union[Breakpoints[str, Literal["0", "1"]], Literal["0", "1"]]],
- Literal["0", "1"],
- Breakpoints[str, Literal["0", "1"]],
- ]
- ] = None,
- flex_grow: Optional[
- Union[
- Var[Union[Breakpoints[str, Literal["0", "1"]], Literal["0", "1"]]],
- Literal["0", "1"],
- Breakpoints[str, Literal["0", "1"]],
- ]
- ] = None,
- m: Optional[
- Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- ]
- ] = None,
- mx: Optional[
- Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- ]
- ] = None,
- my: Optional[
- Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- ]
- ] = None,
- mt: Optional[
- Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- ]
- ] = None,
- mr: Optional[
- Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- ]
- ] = None,
- mb: Optional[
- Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- ]
- ] = None,
- ml: Optional[
- Union[
- Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
] = None,
style: Optional[Style] = None,
@@ -200,52 +200,22 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "LayoutComponent":
"""Create a new component instance.
@@ -255,13 +225,6 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent):
Args:
*children: Child components.
- p: Padding: "0" - "9"
- px: Padding horizontal: "0" - "9"
- py: Padding vertical: "0" - "9"
- pt: Padding top: "0" - "9"
- pr: Padding right: "0" - "9"
- pb: Padding bottom: "0" - "9"
- pl: Padding left: "0" - "9"
flex_shrink: Whether the element will take up the smallest possible space: "0" | "1"
flex_grow: Whether the element will take up the largest possible space: "0" | "1"
m: Margin: "0" - "9"
@@ -271,6 +234,13 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent):
mr: Margin right: "0" - "9"
mb: Margin bottom: "0" - "9"
ml: Margin left: "0" - "9"
+ p: Padding: "0" - "9"
+ px: Padding horizontal: "0" - "9"
+ py: Padding vertical: "0" - "9"
+ pt: Padding top: "0" - "9"
+ pr: Padding right: "0" - "9"
+ pb: Padding bottom: "0" - "9"
+ pl: Padding left: "0" - "9"
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/radix/themes/layout/box.pyi b/reflex/components/radix/themes/layout/box.pyi
index 9c4bd800d..416e45f3a 100644
--- a/reflex/components/radix/themes/layout/box.pyi
+++ b/reflex/components/radix/themes/layout/box.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -18,81 +18,51 @@ class Box(elements.Div, RadixThemesComponent):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Box":
"""Create a new component instance.
@@ -102,7 +72,7 @@ class Box(elements.Div, RadixThemesComponent):
Args:
*children: Child components.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/layout/center.pyi b/reflex/components/radix/themes/layout/center.pyi
index bbdf51d07..59062b293 100644
--- a/reflex/components/radix/themes/layout/center.pyi
+++ b/reflex/components/radix/themes/layout/center.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .flex import Flex
@@ -22,64 +22,68 @@ class Center(Flex):
as_child: Optional[Union[Var[bool], bool]] = None,
direction: Optional[
Union[
+ Breakpoints[
+ str, Literal["column", "column-reverse", "row", "row-reverse"]
+ ],
+ Literal["column", "column-reverse", "row", "row-reverse"],
Var[
Union[
Breakpoints[
str,
- Literal["row", "column", "row-reverse", "column-reverse"],
+ Literal["column", "column-reverse", "row", "row-reverse"],
],
- Literal["row", "column", "row-reverse", "column-reverse"],
+ Literal["column", "column-reverse", "row", "row-reverse"],
]
],
- Literal["row", "column", "row-reverse", "column-reverse"],
- Breakpoints[
- str, Literal["row", "column", "row-reverse", "column-reverse"]
- ],
]
] = None,
align: Optional[
Union[
+ Breakpoints[
+ str, Literal["baseline", "center", "end", "start", "stretch"]
+ ],
+ Literal["baseline", "center", "end", "start", "stretch"],
Var[
Union[
Breakpoints[
str,
- Literal["start", "center", "end", "baseline", "stretch"],
+ Literal["baseline", "center", "end", "start", "stretch"],
],
- Literal["start", "center", "end", "baseline", "stretch"],
+ Literal["baseline", "center", "end", "start", "stretch"],
]
],
- Literal["start", "center", "end", "baseline", "stretch"],
- Breakpoints[
- str, Literal["start", "center", "end", "baseline", "stretch"]
- ],
]
] = None,
justify: Optional[
Union[
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
Var[
Union[
- Breakpoints[str, Literal["start", "center", "end", "between"]],
- Literal["start", "center", "end", "between"],
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
]
],
- Literal["start", "center", "end", "between"],
- Breakpoints[str, Literal["start", "center", "end", "between"]],
]
] = None,
wrap: Optional[
Union[
+ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
+ Literal["nowrap", "wrap", "wrap-reverse"],
Var[
Union[
Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
Literal["nowrap", "wrap", "wrap-reverse"],
]
],
- Literal["nowrap", "wrap", "wrap-reverse"],
- Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
]
] = None,
spacing: Optional[
Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -89,87 +93,53 @@ class Center(Flex):
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
- ],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Center":
"""Create a new component instance.
@@ -180,12 +150,12 @@ class Center(Flex):
Args:
*children: Child components.
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
- direction: How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse"
+ direction: How child items are laid out: "row" | "column" | "row-reverse" | "column-reverse"
align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch"
justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between"
wrap: Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse"
spacing: Gap between children: "0" - "9"
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/layout/container.py b/reflex/components/radix/themes/layout/container.py
index c0f1c7dc8..b1d2fbed3 100644
--- a/reflex/components/radix/themes/layout/container.py
+++ b/reflex/components/radix/themes/layout/container.py
@@ -7,7 +7,7 @@ from typing import Literal
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
from reflex.style import STACK_CHILDREN_FULL_WIDTH
-from reflex.vars import Var
+from reflex.vars.base import LiteralVar, Var
from ..base import RadixThemesComponent
@@ -23,9 +23,7 @@ class Container(elements.Div, RadixThemesComponent):
tag = "Container"
# The size of the container: "1" - "4" (default "3")
- size: Var[Responsive[LiteralContainerSize]] = Var.create_safe(
- "3", _var_is_string=True
- )
+ size: Var[Responsive[LiteralContainerSize]] = LiteralVar.create("3")
@classmethod
def create(
diff --git a/reflex/components/radix/themes/layout/container.pyi b/reflex/components/radix/themes/layout/container.pyi
index 4e4c0bae3..36ea79457 100644
--- a/reflex/components/radix/themes/layout/container.pyi
+++ b/reflex/components/radix/themes/layout/container.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -25,91 +25,61 @@ class Container(elements.Div, RadixThemesComponent):
stack_children_full_width: Optional[bool] = False,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4"]],
+ Literal["1", "2", "3", "4"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3", "4"]],
Literal["1", "2", "3", "4"],
]
],
- Literal["1", "2", "3", "4"],
- Breakpoints[str, Literal["1", "2", "3", "4"]],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Container":
"""Create the container component.
diff --git a/reflex/components/radix/themes/layout/flex.py b/reflex/components/radix/themes/layout/flex.py
index 825c84f42..39982e4f4 100644
--- a/reflex/components/radix/themes/layout/flex.py
+++ b/reflex/components/radix/themes/layout/flex.py
@@ -6,14 +6,9 @@ from typing import Dict, Literal
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- LiteralAlign,
- LiteralJustify,
- LiteralSpacing,
- RadixThemesComponent,
-)
+from ..base import LiteralAlign, LiteralJustify, LiteralSpacing, RadixThemesComponent
LiteralFlexDirection = Literal["row", "column", "row-reverse", "column-reverse"]
LiteralFlexWrap = Literal["nowrap", "wrap", "wrap-reverse"]
@@ -27,7 +22,7 @@ class Flex(elements.Div, RadixThemesComponent):
# Change the default rendered element for the one passed as a child, merging their props and behavior.
as_child: Var[bool]
- # How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse"
+ # How child items are laid out: "row" | "column" | "row-reverse" | "column-reverse"
direction: Var[Responsive[LiteralFlexDirection]]
# Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch"
diff --git a/reflex/components/radix/themes/layout/flex.pyi b/reflex/components/radix/themes/layout/flex.pyi
index f4e851d09..dafa91c6c 100644
--- a/reflex/components/radix/themes/layout/flex.pyi
+++ b/reflex/components/radix/themes/layout/flex.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -25,64 +25,68 @@ class Flex(elements.Div, RadixThemesComponent):
as_child: Optional[Union[Var[bool], bool]] = None,
direction: Optional[
Union[
+ Breakpoints[
+ str, Literal["column", "column-reverse", "row", "row-reverse"]
+ ],
+ Literal["column", "column-reverse", "row", "row-reverse"],
Var[
Union[
Breakpoints[
str,
- Literal["row", "column", "row-reverse", "column-reverse"],
+ Literal["column", "column-reverse", "row", "row-reverse"],
],
- Literal["row", "column", "row-reverse", "column-reverse"],
+ Literal["column", "column-reverse", "row", "row-reverse"],
]
],
- Literal["row", "column", "row-reverse", "column-reverse"],
- Breakpoints[
- str, Literal["row", "column", "row-reverse", "column-reverse"]
- ],
]
] = None,
align: Optional[
Union[
+ Breakpoints[
+ str, Literal["baseline", "center", "end", "start", "stretch"]
+ ],
+ Literal["baseline", "center", "end", "start", "stretch"],
Var[
Union[
Breakpoints[
str,
- Literal["start", "center", "end", "baseline", "stretch"],
+ Literal["baseline", "center", "end", "start", "stretch"],
],
- Literal["start", "center", "end", "baseline", "stretch"],
+ Literal["baseline", "center", "end", "start", "stretch"],
]
],
- Literal["start", "center", "end", "baseline", "stretch"],
- Breakpoints[
- str, Literal["start", "center", "end", "baseline", "stretch"]
- ],
]
] = None,
justify: Optional[
Union[
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
Var[
Union[
- Breakpoints[str, Literal["start", "center", "end", "between"]],
- Literal["start", "center", "end", "between"],
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
]
],
- Literal["start", "center", "end", "between"],
- Breakpoints[str, Literal["start", "center", "end", "between"]],
]
] = None,
wrap: Optional[
Union[
+ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
+ Literal["nowrap", "wrap", "wrap-reverse"],
Var[
Union[
Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
Literal["nowrap", "wrap", "wrap-reverse"],
]
],
- Literal["nowrap", "wrap", "wrap-reverse"],
- Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
]
] = None,
spacing: Optional[
Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -92,87 +96,53 @@ class Flex(elements.Div, RadixThemesComponent):
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
- ],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Flex":
"""Create a new component instance.
@@ -183,12 +153,12 @@ class Flex(elements.Div, RadixThemesComponent):
Args:
*children: Child components.
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
- direction: How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse"
+ direction: How child items are laid out: "row" | "column" | "row-reverse" | "column-reverse"
align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch"
justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between"
wrap: Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse"
spacing: Gap between children: "0" - "9"
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/layout/grid.py b/reflex/components/radix/themes/layout/grid.py
index ab7fbdb3b..133e19d10 100644
--- a/reflex/components/radix/themes/layout/grid.py
+++ b/reflex/components/radix/themes/layout/grid.py
@@ -6,14 +6,9 @@ from typing import Dict, Literal
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- LiteralAlign,
- LiteralJustify,
- LiteralSpacing,
- RadixThemesComponent,
-)
+from ..base import LiteralAlign, LiteralJustify, LiteralSpacing, RadixThemesComponent
LiteralGridFlow = Literal["row", "column", "dense", "row-dense", "column-dense"]
@@ -32,7 +27,7 @@ class Grid(elements.Div, RadixThemesComponent):
# Number of rows
rows: Var[Responsive[str]]
- # How the grid items are layed out: "row" | "column" | "dense" | "row-dense" | "column-dense"
+ # How the grid items are laid out: "row" | "column" | "dense" | "row-dense" | "column-dense"
flow: Var[Responsive[LiteralGridFlow]]
# Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch"
diff --git a/reflex/components/radix/themes/layout/grid.pyi b/reflex/components/radix/themes/layout/grid.pyi
index 1acc6f9b1..55153fca3 100644
--- a/reflex/components/radix/themes/layout/grid.pyi
+++ b/reflex/components/radix/themes/layout/grid.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -23,61 +23,65 @@ class Grid(elements.Div, RadixThemesComponent):
*children,
as_child: Optional[Union[Var[bool], bool]] = None,
columns: Optional[
- Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]]
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
] = None,
rows: Optional[
- Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]]
+ Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str]
] = None,
flow: Optional[
Union[
+ Breakpoints[
+ str, Literal["column", "column-dense", "dense", "row", "row-dense"]
+ ],
+ Literal["column", "column-dense", "dense", "row", "row-dense"],
Var[
Union[
Breakpoints[
str,
Literal[
- "row", "column", "dense", "row-dense", "column-dense"
+ "column", "column-dense", "dense", "row", "row-dense"
],
],
- Literal["row", "column", "dense", "row-dense", "column-dense"],
+ Literal["column", "column-dense", "dense", "row", "row-dense"],
]
],
- Literal["row", "column", "dense", "row-dense", "column-dense"],
- Breakpoints[
- str, Literal["row", "column", "dense", "row-dense", "column-dense"]
- ],
]
] = None,
align: Optional[
Union[
+ Breakpoints[
+ str, Literal["baseline", "center", "end", "start", "stretch"]
+ ],
+ Literal["baseline", "center", "end", "start", "stretch"],
Var[
Union[
Breakpoints[
str,
- Literal["start", "center", "end", "baseline", "stretch"],
+ Literal["baseline", "center", "end", "start", "stretch"],
],
- Literal["start", "center", "end", "baseline", "stretch"],
+ Literal["baseline", "center", "end", "start", "stretch"],
]
],
- Literal["start", "center", "end", "baseline", "stretch"],
- Breakpoints[
- str, Literal["start", "center", "end", "baseline", "stretch"]
- ],
]
] = None,
justify: Optional[
Union[
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
Var[
Union[
- Breakpoints[str, Literal["start", "center", "end", "between"]],
- Literal["start", "center", "end", "between"],
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
]
],
- Literal["start", "center", "end", "between"],
- Breakpoints[str, Literal["start", "center", "end", "between"]],
]
] = None,
spacing: Optional[
Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -87,14 +91,14 @@ class Grid(elements.Div, RadixThemesComponent):
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
- ],
]
] = None,
spacing_x: Optional[
Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -104,14 +108,14 @@ class Grid(elements.Div, RadixThemesComponent):
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
- ],
]
] = None,
spacing_y: Optional[
Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -121,87 +125,53 @@ class Grid(elements.Div, RadixThemesComponent):
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
- ],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Grid":
"""Create a new component instance.
@@ -214,13 +184,13 @@ class Grid(elements.Div, RadixThemesComponent):
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
columns: Number of columns
rows: Number of rows
- flow: How the grid items are layed out: "row" | "column" | "dense" | "row-dense" | "column-dense"
+ flow: How the grid items are laid out: "row" | "column" | "dense" | "row-dense" | "column-dense"
align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch"
justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between"
spacing: Gap between children: "0" - "9"
spacing_x: Gap between children horizontal: "0" - "9"
spacing_y: Gap between children vertical: "0" - "9"
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/layout/list.py b/reflex/components/radix/themes/layout/list.py
index fb77b223d..a306e19a4 100644
--- a/reflex/components/radix/themes/layout/list.py
+++ b/reflex/components/radix/themes/layout/list.py
@@ -2,14 +2,15 @@
from __future__ import annotations
-from typing import Any, Iterable, Literal, Optional, Union
+from typing import Any, Iterable, Literal, Union
from reflex.components.component import Component, ComponentNamespace
from reflex.components.core.foreach import Foreach
from reflex.components.el.elements.typography import Li, Ol, Ul
from reflex.components.lucide.icon import Icon
+from reflex.components.markdown.markdown import MarkdownComponentMap
from reflex.components.radix.themes.typography.text import Text
-from reflex.vars import Var
+from reflex.vars.base import Var
LiteralListStyleTypeUnordered = Literal[
"none",
@@ -36,7 +37,7 @@ LiteralListStyleTypeOrdered = Literal[
]
-class BaseList(Component):
+class BaseList(Component, MarkdownComponentMap):
"""Base class for ordered and unordered lists."""
tag = "ul"
@@ -44,27 +45,29 @@ class BaseList(Component):
# The style of the list. Default to "none".
list_style_type: Var[
Union[LiteralListStyleTypeUnordered, LiteralListStyleTypeOrdered]
- ]
+ ] = Var.create("none")
+
+ # A list of items to add to the list.
+ items: Var[Iterable] = Var.create([])
@classmethod
def create(
cls,
*children,
- items: Optional[Var[Iterable]] = None,
**props,
):
"""Create a list component.
Args:
*children: The children of the component.
- items: A list of items to add to the list.
**props: The properties of the component.
Returns:
The list component.
-
"""
+ items = props.pop("items", None)
list_style_type = props.pop("list_style_type", "none")
+
if not children and items is not None:
if isinstance(items, Var):
children = [Foreach.create(items, ListItem.create)]
@@ -87,6 +90,9 @@ class BaseList(Component):
"direction": "column",
}
+ def _exclude_props(self) -> list[str]:
+ return ["items", "list_style_type"]
+
class UnorderedList(BaseList, Ul):
"""Display an unordered list."""
@@ -97,22 +103,20 @@ class UnorderedList(BaseList, Ul):
def create(
cls,
*children,
- items: Optional[Var[Iterable]] = None,
- list_style_type: LiteralListStyleTypeUnordered = "disc",
**props,
):
- """Create a unordered list component.
+ """Create an unordered list component.
Args:
*children: The children of the component.
- items: A list of items to add to the list.
- list_style_type: The style of the list.
**props: The properties of the component.
Returns:
The list component.
-
"""
+ items = props.pop("items", None)
+ list_style_type = props.pop("list_style_type", "disc")
+
props["margin_left"] = props.get("margin_left", "1.5rem")
return super().create(
*children, items=items, list_style_type=list_style_type, **props
@@ -128,29 +132,27 @@ class OrderedList(BaseList, Ol):
def create(
cls,
*children,
- items: Optional[Var[Iterable]] = None,
- list_style_type: LiteralListStyleTypeOrdered = "decimal",
**props,
):
"""Create an ordered list component.
Args:
*children: The children of the component.
- items: A list of items to add to the list.
- list_style_type: The style of the list.
**props: The properties of the component.
Returns:
The list component.
-
"""
+ items = props.pop("items", None)
+ list_style_type = props.pop("list_style_type", "decimal")
+
props["margin_left"] = props.get("margin_left", "1.5rem")
return super().create(
*children, items=items, list_style_type=list_style_type, **props
)
-class ListItem(Li):
+class ListItem(Li, MarkdownComponentMap):
"""Display an item of an ordered or unordered list."""
@classmethod
@@ -163,7 +165,6 @@ class ListItem(Li):
Returns:
The list item component.
-
"""
for child in children:
if isinstance(child, Text):
diff --git a/reflex/components/radix/themes/layout/list.pyi b/reflex/components/radix/themes/layout/list.pyi
index f6cc3141e..8517a6897 100644
--- a/reflex/components/radix/themes/layout/list.pyi
+++ b/reflex/components/radix/themes/layout/list.pyi
@@ -3,13 +3,14 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Iterable, Literal, Optional, Union, overload
+from typing import Any, Dict, Iterable, Literal, Optional, Union, overload
from reflex.components.component import Component, ComponentNamespace
from reflex.components.el.elements.typography import Li, Ol, Ul
-from reflex.event import EventHandler, EventSpec
+from reflex.components.markdown.markdown import MarkdownComponentMap
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
LiteralListStyleTypeUnordered = Literal["none", "disc", "circle", "square"]
LiteralListStyleTypeOrdered = Literal[
@@ -29,114 +30,84 @@ LiteralListStyleTypeOrdered = Literal[
"katakana",
]
-class BaseList(Component):
+class BaseList(Component, MarkdownComponentMap):
@overload
@classmethod
def create( # type: ignore
cls,
*children,
- items: Optional[Union[Var[Iterable], Iterable]] = None,
list_style_type: Optional[
Union[
+ Literal[
+ "armenian",
+ "decimal",
+ "decimal-leading-zero",
+ "georgian",
+ "hiragana",
+ "katakana",
+ "lower-alpha",
+ "lower-greek",
+ "lower-latin",
+ "lower-roman",
+ "none",
+ "upper-alpha",
+ "upper-latin",
+ "upper-roman",
+ ],
+ Literal["circle", "disc", "none", "square"],
Var[
Union[
Literal[
- "none",
+ "armenian",
"decimal",
"decimal-leading-zero",
- "lower-roman",
- "upper-roman",
- "lower-greek",
- "lower-latin",
- "upper-latin",
- "armenian",
"georgian",
- "lower-alpha",
- "upper-alpha",
"hiragana",
"katakana",
+ "lower-alpha",
+ "lower-greek",
+ "lower-latin",
+ "lower-roman",
+ "none",
+ "upper-alpha",
+ "upper-latin",
+ "upper-roman",
],
- Literal["none", "disc", "circle", "square"],
+ Literal["circle", "disc", "none", "square"],
]
],
- Literal["none", "disc", "circle", "square"],
- Literal[
- "none",
- "decimal",
- "decimal-leading-zero",
- "lower-roman",
- "upper-roman",
- "lower-greek",
- "lower-latin",
- "upper-latin",
- "armenian",
- "georgian",
- "lower-alpha",
- "upper-alpha",
- "hiragana",
- "katakana",
- ],
]
] = None,
+ items: Optional[Union[Iterable, Var[Iterable]]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "BaseList":
"""Create a list component.
Args:
*children: The children of the component.
- items: A list of items to add to the list.
list_style_type: The style of the list. Default to "none".
+ items: A list of items to add to the list.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -147,7 +118,6 @@ class BaseList(Component):
Returns:
The list component.
-
"""
...
@@ -159,92 +129,103 @@ class UnorderedList(BaseList, Ul):
def create( # type: ignore
cls,
*children,
- items: Optional[Union[Var[Iterable], Iterable]] = None,
- list_style_type: Optional[LiteralListStyleTypeUnordered] = "disc",
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ list_style_type: Optional[
+ Union[
+ Literal[
+ "armenian",
+ "decimal",
+ "decimal-leading-zero",
+ "georgian",
+ "hiragana",
+ "katakana",
+ "lower-alpha",
+ "lower-greek",
+ "lower-latin",
+ "lower-roman",
+ "none",
+ "upper-alpha",
+ "upper-latin",
+ "upper-roman",
+ ],
+ Literal["circle", "disc", "none", "square"],
+ Var[
+ Union[
+ Literal[
+ "armenian",
+ "decimal",
+ "decimal-leading-zero",
+ "georgian",
+ "hiragana",
+ "katakana",
+ "lower-alpha",
+ "lower-greek",
+ "lower-latin",
+ "lower-roman",
+ "none",
+ "upper-alpha",
+ "upper-latin",
+ "upper-roman",
+ ],
+ Literal["circle", "disc", "none", "square"],
+ ]
+ ],
+ ]
+ ] = None,
+ items: Optional[Union[Iterable, Var[Iterable]]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "UnorderedList":
- """Create a unordered list component.
+ """Create an unordered list component.
Args:
*children: The children of the component.
+ list_style_type: The style of the list. Default to "none".
items: A list of items to add to the list.
- list_style_type: The style of the list.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -270,7 +251,6 @@ class UnorderedList(BaseList, Ul):
Returns:
The list component.
-
"""
...
@@ -280,98 +260,109 @@ class OrderedList(BaseList, Ol):
def create( # type: ignore
cls,
*children,
- items: Optional[Union[Var[Iterable], Iterable]] = None,
- list_style_type: Optional[LiteralListStyleTypeOrdered] = "decimal",
- reversed: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- start: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ list_style_type: Optional[
+ Union[
+ Literal[
+ "armenian",
+ "decimal",
+ "decimal-leading-zero",
+ "georgian",
+ "hiragana",
+ "katakana",
+ "lower-alpha",
+ "lower-greek",
+ "lower-latin",
+ "lower-roman",
+ "none",
+ "upper-alpha",
+ "upper-latin",
+ "upper-roman",
+ ],
+ Literal["circle", "disc", "none", "square"],
+ Var[
+ Union[
+ Literal[
+ "armenian",
+ "decimal",
+ "decimal-leading-zero",
+ "georgian",
+ "hiragana",
+ "katakana",
+ "lower-alpha",
+ "lower-greek",
+ "lower-latin",
+ "lower-roman",
+ "none",
+ "upper-alpha",
+ "upper-latin",
+ "upper-roman",
+ ],
+ Literal["circle", "disc", "none", "square"],
+ ]
+ ],
+ ]
+ ] = None,
+ items: Optional[Union[Iterable, Var[Iterable]]] = None,
+ reversed: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ start: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "OrderedList":
"""Create an ordered list component.
Args:
*children: The children of the component.
+ list_style_type: The style of the list. Default to "none".
items: A list of items to add to the list.
- list_style_type: The style of the list.
reversed: Reverses the order of the list.
start: Specifies the start value of the first list item in an ordered list.
type: Specifies the kind of marker to use in the list (letters or numbers).
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -397,98 +388,67 @@ class OrderedList(BaseList, Ol):
Returns:
The list component.
-
"""
...
-class ListItem(Li):
+class ListItem(Li, MarkdownComponentMap):
@overload
@classmethod
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ListItem":
"""Create a list item component.
Args:
*children: The children of the component.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -514,7 +474,6 @@ class ListItem(Li):
Returns:
The list item component.
-
"""
...
@@ -526,108 +485,78 @@ class List(ComponentNamespace):
@staticmethod
def __call__(
*children,
- items: Optional[Union[Var[Iterable], Iterable]] = None,
list_style_type: Optional[
Union[
+ Literal[
+ "armenian",
+ "decimal",
+ "decimal-leading-zero",
+ "georgian",
+ "hiragana",
+ "katakana",
+ "lower-alpha",
+ "lower-greek",
+ "lower-latin",
+ "lower-roman",
+ "none",
+ "upper-alpha",
+ "upper-latin",
+ "upper-roman",
+ ],
+ Literal["circle", "disc", "none", "square"],
Var[
Union[
Literal[
- "none",
+ "armenian",
"decimal",
"decimal-leading-zero",
- "lower-roman",
- "upper-roman",
- "lower-greek",
- "lower-latin",
- "upper-latin",
- "armenian",
"georgian",
- "lower-alpha",
- "upper-alpha",
"hiragana",
"katakana",
+ "lower-alpha",
+ "lower-greek",
+ "lower-latin",
+ "lower-roman",
+ "none",
+ "upper-alpha",
+ "upper-latin",
+ "upper-roman",
],
- Literal["none", "disc", "circle", "square"],
+ Literal["circle", "disc", "none", "square"],
]
],
- Literal["none", "disc", "circle", "square"],
- Literal[
- "none",
- "decimal",
- "decimal-leading-zero",
- "lower-roman",
- "upper-roman",
- "lower-greek",
- "lower-latin",
- "upper-latin",
- "armenian",
- "georgian",
- "lower-alpha",
- "upper-alpha",
- "hiragana",
- "katakana",
- ],
]
] = None,
+ items: Optional[Union[Iterable, Var[Iterable]]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "BaseList":
"""Create a list component.
Args:
*children: The children of the component.
- items: A list of items to add to the list.
list_style_type: The style of the list. Default to "none".
+ items: A list of items to add to the list.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -638,7 +567,6 @@ class List(ComponentNamespace):
Returns:
The list component.
-
"""
...
diff --git a/reflex/components/radix/themes/layout/section.py b/reflex/components/radix/themes/layout/section.py
index d9b27bdf9..68a131751 100644
--- a/reflex/components/radix/themes/layout/section.py
+++ b/reflex/components/radix/themes/layout/section.py
@@ -6,7 +6,7 @@ from typing import Literal
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.vars import Var
+from reflex.vars.base import LiteralVar, Var
from ..base import RadixThemesComponent
@@ -19,9 +19,7 @@ class Section(elements.Section, RadixThemesComponent):
tag = "Section"
# The size of the section: "1" - "3" (default "2")
- size: Var[Responsive[LiteralSectionSize]] = Var.create_safe(
- "2", _var_is_string=True
- )
+ size: Var[Responsive[LiteralSectionSize]] = LiteralVar.create("2")
section = Section.create
diff --git a/reflex/components/radix/themes/layout/section.pyi b/reflex/components/radix/themes/layout/section.pyi
index 31cf355e8..c005f273f 100644
--- a/reflex/components/radix/themes/layout/section.pyi
+++ b/reflex/components/radix/themes/layout/section.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -23,90 +23,60 @@ class Section(elements.Section, RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3"]],
+ Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
- Literal["1", "2", "3"],
- Breakpoints[str, Literal["1", "2", "3"]],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Section":
"""Create a new component instance.
@@ -117,7 +87,7 @@ class Section(elements.Section, RadixThemesComponent):
Args:
*children: Child components.
size: The size of the section: "1" - "3" (default "2")
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/layout/spacer.pyi b/reflex/components/radix/themes/layout/spacer.pyi
index aedd9b041..9854aa1ba 100644
--- a/reflex/components/radix/themes/layout/spacer.pyi
+++ b/reflex/components/radix/themes/layout/spacer.pyi
@@ -3,12 +3,12 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from .flex import Flex
@@ -22,64 +22,68 @@ class Spacer(Flex):
as_child: Optional[Union[Var[bool], bool]] = None,
direction: Optional[
Union[
+ Breakpoints[
+ str, Literal["column", "column-reverse", "row", "row-reverse"]
+ ],
+ Literal["column", "column-reverse", "row", "row-reverse"],
Var[
Union[
Breakpoints[
str,
- Literal["row", "column", "row-reverse", "column-reverse"],
+ Literal["column", "column-reverse", "row", "row-reverse"],
],
- Literal["row", "column", "row-reverse", "column-reverse"],
+ Literal["column", "column-reverse", "row", "row-reverse"],
]
],
- Literal["row", "column", "row-reverse", "column-reverse"],
- Breakpoints[
- str, Literal["row", "column", "row-reverse", "column-reverse"]
- ],
]
] = None,
align: Optional[
Union[
+ Breakpoints[
+ str, Literal["baseline", "center", "end", "start", "stretch"]
+ ],
+ Literal["baseline", "center", "end", "start", "stretch"],
Var[
Union[
Breakpoints[
str,
- Literal["start", "center", "end", "baseline", "stretch"],
+ Literal["baseline", "center", "end", "start", "stretch"],
],
- Literal["start", "center", "end", "baseline", "stretch"],
+ Literal["baseline", "center", "end", "start", "stretch"],
]
],
- Literal["start", "center", "end", "baseline", "stretch"],
- Breakpoints[
- str, Literal["start", "center", "end", "baseline", "stretch"]
- ],
]
] = None,
justify: Optional[
Union[
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
Var[
Union[
- Breakpoints[str, Literal["start", "center", "end", "between"]],
- Literal["start", "center", "end", "between"],
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
]
],
- Literal["start", "center", "end", "between"],
- Breakpoints[str, Literal["start", "center", "end", "between"]],
]
] = None,
wrap: Optional[
Union[
+ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
+ Literal["nowrap", "wrap", "wrap-reverse"],
Var[
Union[
Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
Literal["nowrap", "wrap", "wrap-reverse"],
]
],
- Literal["nowrap", "wrap", "wrap-reverse"],
- Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
]
] = None,
spacing: Optional[
Union[
+ Breakpoints[
+ str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ ],
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -89,87 +93,53 @@ class Spacer(Flex):
Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[
- str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
- ],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Spacer":
"""Create a new component instance.
@@ -180,12 +150,12 @@ class Spacer(Flex):
Args:
*children: Child components.
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
- direction: How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse"
+ direction: How child items are laid out: "row" | "column" | "row-reverse" | "column-reverse"
align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch"
justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between"
wrap: Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse"
spacing: Gap between children: "0" - "9"
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/layout/stack.py b/reflex/components/radix/themes/layout/stack.py
index 13f80dc1e..d11c3488b 100644
--- a/reflex/components/radix/themes/layout/stack.py
+++ b/reflex/components/radix/themes/layout/stack.py
@@ -3,7 +3,7 @@
from __future__ import annotations
from reflex.components.component import Component
-from reflex.vars import Var
+from reflex.vars.base import Var
from ..base import LiteralAlign, LiteralSpacing
from .flex import Flex, LiteralFlexDirection
@@ -12,20 +12,22 @@ from .flex import Flex, LiteralFlexDirection
class Stack(Flex):
"""A stack component."""
+ # The spacing between each stack item.
+ spacing: Var[LiteralSpacing] = Var.create("3")
+
+ # The alignment of the stack items.
+ align: Var[LiteralAlign] = Var.create("start")
+
@classmethod
def create(
cls,
*children,
- spacing: LiteralSpacing = "3",
- align: LiteralAlign = "start",
**props,
) -> Component:
"""Create a new instance of the component.
Args:
*children: The children of the stack.
- spacing: The spacing between each stack item.
- align: The alignment of the stack items.
**props: The properties of the stack.
Returns:
@@ -33,14 +35,12 @@ class Stack(Flex):
"""
# Apply the default classname
given_class_name = props.pop("class_name", [])
- if isinstance(given_class_name, str):
+ if not isinstance(given_class_name, list):
given_class_name = [given_class_name]
props["class_name"] = ["rx-Stack", *given_class_name]
return super().create(
*children,
- spacing=spacing,
- align=align,
**props,
)
diff --git a/reflex/components/radix/themes/layout/stack.pyi b/reflex/components/radix/themes/layout/stack.pyi
index 0296f92ca..d96c72504 100644
--- a/reflex/components/radix/themes/layout/stack.pyi
+++ b/reflex/components/radix/themes/layout/stack.pyi
@@ -3,14 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
-from ..base import LiteralAlign, LiteralSpacing
from .flex import Flex
class Stack(Flex):
@@ -19,138 +18,118 @@ class Stack(Flex):
def create( # type: ignore
cls,
*children,
- spacing: Optional[LiteralSpacing] = "3",
- align: Optional[LiteralAlign] = "start",
+ spacing: Optional[
+ Union[
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ ]
+ ] = None,
+ align: Optional[
+ Union[
+ Literal["baseline", "center", "end", "start", "stretch"],
+ Var[Literal["baseline", "center", "end", "start", "stretch"]],
+ ]
+ ] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
direction: Optional[
Union[
+ Breakpoints[
+ str, Literal["column", "column-reverse", "row", "row-reverse"]
+ ],
+ Literal["column", "column-reverse", "row", "row-reverse"],
Var[
Union[
Breakpoints[
str,
- Literal["row", "column", "row-reverse", "column-reverse"],
+ Literal["column", "column-reverse", "row", "row-reverse"],
],
- Literal["row", "column", "row-reverse", "column-reverse"],
+ Literal["column", "column-reverse", "row", "row-reverse"],
]
],
- Literal["row", "column", "row-reverse", "column-reverse"],
- Breakpoints[
- str, Literal["row", "column", "row-reverse", "column-reverse"]
- ],
]
] = None,
justify: Optional[
Union[
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
Var[
Union[
- Breakpoints[str, Literal["start", "center", "end", "between"]],
- Literal["start", "center", "end", "between"],
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
]
],
- Literal["start", "center", "end", "between"],
- Breakpoints[str, Literal["start", "center", "end", "between"]],
]
] = None,
wrap: Optional[
Union[
+ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
+ Literal["nowrap", "wrap", "wrap-reverse"],
Var[
Union[
Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
Literal["nowrap", "wrap", "wrap-reverse"],
]
],
- Literal["nowrap", "wrap", "wrap-reverse"],
- Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Stack":
"""Create a new instance of the component.
Args:
*children: The children of the stack.
- spacing: The spacing between each stack item.
- align: The alignment of the stack items.
+ spacing: Gap between children: "0" - "9"
+ align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch"
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
- direction: How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse"
+ direction: How child items are laid out: "row" | "column" | "row-reverse" | "column-reverse"
justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between"
wrap: Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse"
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -185,127 +164,107 @@ class VStack(Stack):
def create( # type: ignore
cls,
*children,
- spacing: Optional[LiteralSpacing] = "3",
- align: Optional[LiteralAlign] = "start",
direction: Optional[
Union[
- Var[Literal["row", "column", "row-reverse", "column-reverse"]],
- Literal["row", "column", "row-reverse", "column-reverse"],
+ Literal["column", "column-reverse", "row", "row-reverse"],
+ Var[Literal["column", "column-reverse", "row", "row-reverse"]],
+ ]
+ ] = None,
+ spacing: Optional[
+ Union[
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ ]
+ ] = None,
+ align: Optional[
+ Union[
+ Literal["baseline", "center", "end", "start", "stretch"],
+ Var[Literal["baseline", "center", "end", "start", "stretch"]],
]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
justify: Optional[
Union[
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
Var[
Union[
- Breakpoints[str, Literal["start", "center", "end", "between"]],
- Literal["start", "center", "end", "between"],
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
]
],
- Literal["start", "center", "end", "between"],
- Breakpoints[str, Literal["start", "center", "end", "between"]],
]
] = None,
wrap: Optional[
Union[
+ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
+ Literal["nowrap", "wrap", "wrap-reverse"],
Var[
Union[
Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
Literal["nowrap", "wrap", "wrap-reverse"],
]
],
- Literal["nowrap", "wrap", "wrap-reverse"],
- Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "VStack":
"""Create a new instance of the component.
Args:
*children: The children of the stack.
- spacing: The spacing between each stack item.
- align: The alignment of the stack items.
- direction: How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse"
+ direction: How child items are laid out: "row" | "column" | "row-reverse" | "column-reverse"
+ spacing: Gap between children: "0" - "9"
+ align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch"
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between"
wrap: Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse"
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -340,127 +299,107 @@ class HStack(Stack):
def create( # type: ignore
cls,
*children,
- spacing: Optional[LiteralSpacing] = "3",
- align: Optional[LiteralAlign] = "start",
direction: Optional[
Union[
- Var[Literal["row", "column", "row-reverse", "column-reverse"]],
- Literal["row", "column", "row-reverse", "column-reverse"],
+ Literal["column", "column-reverse", "row", "row-reverse"],
+ Var[Literal["column", "column-reverse", "row", "row-reverse"]],
+ ]
+ ] = None,
+ spacing: Optional[
+ Union[
+ Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ ]
+ ] = None,
+ align: Optional[
+ Union[
+ Literal["baseline", "center", "end", "start", "stretch"],
+ Var[Literal["baseline", "center", "end", "start", "stretch"]],
]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
justify: Optional[
Union[
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
Var[
Union[
- Breakpoints[str, Literal["start", "center", "end", "between"]],
- Literal["start", "center", "end", "between"],
+ Breakpoints[str, Literal["between", "center", "end", "start"]],
+ Literal["between", "center", "end", "start"],
]
],
- Literal["start", "center", "end", "between"],
- Breakpoints[str, Literal["start", "center", "end", "between"]],
]
] = None,
wrap: Optional[
Union[
+ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
+ Literal["nowrap", "wrap", "wrap-reverse"],
Var[
Union[
Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
Literal["nowrap", "wrap", "wrap-reverse"],
]
],
- Literal["nowrap", "wrap", "wrap-reverse"],
- Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "HStack":
"""Create a new instance of the component.
Args:
*children: The children of the stack.
- spacing: The spacing between each stack item.
- align: The alignment of the stack items.
- direction: How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse"
+ direction: How child items are laid out: "row" | "column" | "row-reverse" | "column-reverse"
+ spacing: Gap between children: "0" - "9"
+ align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch"
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between"
wrap: Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse"
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/typography/blockquote.py b/reflex/components/radix/themes/typography/blockquote.py
index a4f3069b8..e32172e00 100644
--- a/reflex/components/radix/themes/typography/blockquote.py
+++ b/reflex/components/radix/themes/typography/blockquote.py
@@ -7,16 +7,10 @@ from __future__ import annotations
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- RadixThemesComponent,
-)
-from .base import (
- LiteralTextSize,
- LiteralTextWeight,
-)
+from ..base import LiteralAccentColor, RadixThemesComponent
+from .base import LiteralTextSize, LiteralTextWeight
class Blockquote(elements.Blockquote, RadixThemesComponent):
diff --git a/reflex/components/radix/themes/typography/blockquote.pyi b/reflex/components/radix/themes/typography/blockquote.pyi
index 5ffe71355..747724763 100644
--- a/reflex/components/radix/themes/typography/blockquote.pyi
+++ b/reflex/components/radix/themes/typography/blockquote.pyi
@@ -3,13 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -21,6 +21,8 @@ class Blockquote(elements.Blockquote, RadixThemesComponent):
*children,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -29,161 +31,129 @@ class Blockquote(elements.Blockquote, RadixThemesComponent):
Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
weight: Optional[
Union[
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
Var[
Union[
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
- Literal["light", "regular", "medium", "bold"],
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
]
],
- Literal["light", "regular", "medium", "bold"],
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
- cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Blockquote":
"""Create a new component instance.
@@ -198,7 +168,7 @@ class Blockquote(elements.Blockquote, RadixThemesComponent):
color_scheme: Overrides the accent color inherited from the Theme.
high_contrast: Whether to render the text with higher contrast color
cite: Define the title of a work.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/typography/code.py b/reflex/components/radix/themes/typography/code.py
index 2c0212b8b..ab610b505 100644
--- a/reflex/components/radix/themes/typography/code.py
+++ b/reflex/components/radix/themes/typography/code.py
@@ -7,20 +7,14 @@ from __future__ import annotations
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.vars import Var
+from reflex.components.markdown.markdown import MarkdownComponentMap
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- LiteralVariant,
- RadixThemesComponent,
-)
-from .base import (
- LiteralTextSize,
- LiteralTextWeight,
-)
+from ..base import LiteralAccentColor, LiteralVariant, RadixThemesComponent
+from .base import LiteralTextSize, LiteralTextWeight
-class Code(elements.Code, RadixThemesComponent):
+class Code(elements.Code, RadixThemesComponent, MarkdownComponentMap):
"""A block level extended quotation."""
tag = "Code"
diff --git a/reflex/components/radix/themes/typography/code.pyi b/reflex/components/radix/themes/typography/code.pyi
index f1fc274e1..847df267c 100644
--- a/reflex/components/radix/themes/typography/code.pyi
+++ b/reflex/components/radix/themes/typography/code.pyi
@@ -3,17 +3,18 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.components.markdown.markdown import MarkdownComponentMap
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
-class Code(elements.Code, RadixThemesComponent):
+class Code(elements.Code, RadixThemesComponent, MarkdownComponentMap):
@overload
@classmethod
def create( # type: ignore
@@ -21,12 +22,14 @@ class Code(elements.Code, RadixThemesComponent):
*children,
variant: Optional[
Union[
- Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]],
- Literal["classic", "solid", "soft", "surface", "outline", "ghost"],
+ Literal["classic", "ghost", "outline", "soft", "solid", "surface"],
+ Var[Literal["classic", "ghost", "outline", "soft", "solid", "surface"]],
]
] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -35,160 +38,128 @@ class Code(elements.Code, RadixThemesComponent):
Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
weight: Optional[
Union[
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
Var[
Union[
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
- Literal["light", "regular", "medium", "bold"],
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
]
],
- Literal["light", "regular", "medium", "bold"],
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Code":
"""Create a new component instance.
@@ -203,7 +174,7 @@ class Code(elements.Code, RadixThemesComponent):
weight: Thickness of text: "light" | "regular" | "medium" | "bold"
color_scheme: Overrides the accent color inherited from the Theme.
high_contrast: Whether to render the text with higher contrast color
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/typography/heading.py b/reflex/components/radix/themes/typography/heading.py
index 374fe8dcc..ce1eaa68f 100644
--- a/reflex/components/radix/themes/typography/heading.py
+++ b/reflex/components/radix/themes/typography/heading.py
@@ -7,21 +7,14 @@ from __future__ import annotations
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.vars import Var
+from reflex.components.markdown.markdown import MarkdownComponentMap
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- RadixThemesComponent,
-)
-from .base import (
- LiteralTextAlign,
- LiteralTextSize,
- LiteralTextTrim,
- LiteralTextWeight,
-)
+from ..base import LiteralAccentColor, RadixThemesComponent
+from .base import LiteralTextAlign, LiteralTextSize, LiteralTextTrim, LiteralTextWeight
-class Heading(elements.H1, RadixThemesComponent):
+class Heading(elements.H1, RadixThemesComponent, MarkdownComponentMap):
"""A foundational text primitive based on the element."""
tag = "Heading"
diff --git a/reflex/components/radix/themes/typography/heading.pyi b/reflex/components/radix/themes/typography/heading.pyi
index 1dad3b97f..4a1e30dbf 100644
--- a/reflex/components/radix/themes/typography/heading.pyi
+++ b/reflex/components/radix/themes/typography/heading.pyi
@@ -3,17 +3,18 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.components.markdown.markdown import MarkdownComponentMap
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
-class Heading(elements.H1, RadixThemesComponent):
+class Heading(elements.H1, RadixThemesComponent, MarkdownComponentMap):
@overload
@classmethod
def create( # type: ignore
@@ -23,6 +24,8 @@ class Heading(elements.H1, RadixThemesComponent):
as_: Optional[Union[Var[str], str]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -31,184 +34,152 @@ class Heading(elements.H1, RadixThemesComponent):
Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
weight: Optional[
Union[
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
Var[
Union[
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
- Literal["light", "regular", "medium", "bold"],
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
]
],
- Literal["light", "regular", "medium", "bold"],
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
]
] = None,
align: Optional[
Union[
+ Breakpoints[str, Literal["center", "left", "right"]],
+ Literal["center", "left", "right"],
Var[
Union[
- Breakpoints[str, Literal["left", "center", "right"]],
- Literal["left", "center", "right"],
+ Breakpoints[str, Literal["center", "left", "right"]],
+ Literal["center", "left", "right"],
]
],
- Literal["left", "center", "right"],
- Breakpoints[str, Literal["left", "center", "right"]],
]
] = None,
trim: Optional[
Union[
+ Breakpoints[str, Literal["both", "end", "normal", "start"]],
+ Literal["both", "end", "normal", "start"],
Var[
Union[
- Breakpoints[str, Literal["normal", "start", "end", "both"]],
- Literal["normal", "start", "end", "both"],
+ Breakpoints[str, Literal["both", "end", "normal", "start"]],
+ Literal["both", "end", "normal", "start"],
]
],
- Literal["normal", "start", "end", "both"],
- Breakpoints[str, Literal["normal", "start", "end", "both"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Heading":
"""Create a new component instance.
@@ -226,7 +197,7 @@ class Heading(elements.H1, RadixThemesComponent):
trim: Removes the leading trim space: "normal" | "start" | "end" | "both"
color_scheme: Overrides the accent color inherited from the Theme.
high_contrast: Whether to render the text with higher contrast color
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/typography/link.py b/reflex/components/radix/themes/typography/link.py
index 92fa47173..25a0902cc 100644
--- a/reflex/components/radix/themes/typography/link.py
+++ b/reflex/components/radix/themes/typography/link.py
@@ -12,26 +12,20 @@ from reflex.components.core.breakpoints import Responsive
from reflex.components.core.colors import color
from reflex.components.core.cond import cond
from reflex.components.el.elements.inline import A
+from reflex.components.markdown.markdown import MarkdownComponentMap
from reflex.components.next.link import NextLink
from reflex.utils.imports import ImportDict
-from reflex.vars import Var
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- RadixThemesComponent,
-)
-from .base import (
- LiteralTextSize,
- LiteralTextTrim,
- LiteralTextWeight,
-)
+from ..base import LiteralAccentColor, RadixThemesComponent
+from .base import LiteralTextSize, LiteralTextTrim, LiteralTextWeight
LiteralLinkUnderline = Literal["auto", "hover", "always", "none"]
next_link = NextLink.create()
-class Link(RadixThemesComponent, A, MemoizationLeaf):
+class Link(RadixThemesComponent, A, MemoizationLeaf, MarkdownComponentMap):
"""A semantic element for navigation between pages."""
tag = "Link"
@@ -83,13 +77,14 @@ class Link(RadixThemesComponent, A, MemoizationLeaf):
Component: The link component
"""
props.setdefault(":hover", {"color": color("accent", 8)})
+ href = props.get("href")
is_external = props.pop("is_external", None)
if is_external is not None:
props["target"] = cond(is_external, "_blank", "")
- if props.get("href") is not None:
+ if href is not None:
if not len(children):
raise ValueError("Link without a child will not display")
@@ -107,6 +102,9 @@ class Link(RadixThemesComponent, A, MemoizationLeaf):
as_child=True,
**props,
)
+ else:
+ props["href"] = "#"
+
return super().create(*children, **props)
diff --git a/reflex/components/radix/themes/typography/link.pyi b/reflex/components/radix/themes/typography/link.pyi
index ab29e8f59..807f8dda0 100644
--- a/reflex/components/radix/themes/typography/link.pyi
+++ b/reflex/components/radix/themes/typography/link.pyi
@@ -3,23 +3,24 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import MemoizationLeaf
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el.elements.inline import A
+from reflex.components.markdown.markdown import MarkdownComponentMap
from reflex.components.next.link import NextLink
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
from reflex.utils.imports import ImportDict
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
LiteralLinkUnderline = Literal["auto", "hover", "always", "none"]
next_link = NextLink.create()
-class Link(RadixThemesComponent, A, MemoizationLeaf):
+class Link(RadixThemesComponent, A, MemoizationLeaf, MarkdownComponentMap):
def add_imports(self) -> ImportDict: ...
@overload
@classmethod
@@ -29,6 +30,8 @@ class Link(RadixThemesComponent, A, MemoizationLeaf):
as_child: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -37,190 +40,158 @@ class Link(RadixThemesComponent, A, MemoizationLeaf):
Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
weight: Optional[
Union[
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
Var[
Union[
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
- Literal["light", "regular", "medium", "bold"],
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
]
],
- Literal["light", "regular", "medium", "bold"],
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
]
] = None,
trim: Optional[
Union[
+ Breakpoints[str, Literal["both", "end", "normal", "start"]],
+ Literal["both", "end", "normal", "start"],
Var[
Union[
- Breakpoints[str, Literal["normal", "start", "end", "both"]],
- Literal["normal", "start", "end", "both"],
+ Breakpoints[str, Literal["both", "end", "normal", "start"]],
+ Literal["both", "end", "normal", "start"],
]
],
- Literal["normal", "start", "end", "both"],
- Breakpoints[str, Literal["normal", "start", "end", "both"]],
]
] = None,
underline: Optional[
Union[
- Var[Literal["auto", "hover", "always", "none"]],
- Literal["auto", "hover", "always", "none"],
+ Literal["always", "auto", "hover", "none"],
+ Var[Literal["always", "auto", "hover", "none"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
is_external: Optional[Union[Var[bool], bool]] = None,
- download: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- href_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- ping: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ download: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ ping: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
referrer_policy: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- rel: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- shape: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ shape: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Link":
"""Create a Link component.
@@ -244,7 +215,7 @@ class Link(RadixThemesComponent, A, MemoizationLeaf):
rel: Specifies the relationship between the linked document and the current document
shape: Specifies the shape of the area
target: Specifies where to open the linked document
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/radix/themes/typography/text.py b/reflex/components/radix/themes/typography/text.py
index fe4b17afc..1663ddedf 100644
--- a/reflex/components/radix/themes/typography/text.py
+++ b/reflex/components/radix/themes/typography/text.py
@@ -10,18 +10,11 @@ from typing import Literal
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive
from reflex.components.el import elements
-from reflex.vars import Var
+from reflex.components.markdown.markdown import MarkdownComponentMap
+from reflex.vars.base import Var
-from ..base import (
- LiteralAccentColor,
- RadixThemesComponent,
-)
-from .base import (
- LiteralTextAlign,
- LiteralTextSize,
- LiteralTextTrim,
- LiteralTextWeight,
-)
+from ..base import LiteralAccentColor, RadixThemesComponent
+from .base import LiteralTextAlign, LiteralTextSize, LiteralTextTrim, LiteralTextWeight
LiteralType = Literal[
"p",
@@ -45,7 +38,7 @@ LiteralType = Literal[
]
-class Text(elements.Span, RadixThemesComponent):
+class Text(elements.Span, RadixThemesComponent, MarkdownComponentMap):
"""A foundational text primitive based on the element."""
tag = "Text"
diff --git a/reflex/components/radix/themes/typography/text.pyi b/reflex/components/radix/themes/typography/text.pyi
index 1d7857a5d..d96b5799b 100644
--- a/reflex/components/radix/themes/typography/text.pyi
+++ b/reflex/components/radix/themes/typography/text.pyi
@@ -3,14 +3,15 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Breakpoints
from reflex.components.el import elements
-from reflex.event import EventHandler, EventSpec
+from reflex.components.markdown.markdown import MarkdownComponentMap
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
from ..base import RadixThemesComponent
@@ -35,7 +36,7 @@ LiteralType = Literal[
"sup",
]
-class Text(elements.Span, RadixThemesComponent):
+class Text(elements.Span, RadixThemesComponent, MarkdownComponentMap):
@overload
@classmethod
def create( # type: ignore
@@ -44,52 +45,54 @@ class Text(elements.Span, RadixThemesComponent):
as_child: Optional[Union[Var[bool], bool]] = None,
as_: Optional[
Union[
- Var[
- Literal[
- "p",
- "label",
- "div",
- "span",
- "b",
- "i",
- "u",
- "abbr",
- "cite",
- "del",
- "em",
- "ins",
- "kbd",
- "mark",
- "s",
- "samp",
- "sub",
- "sup",
- ]
- ],
Literal[
- "p",
- "label",
- "div",
- "span",
- "b",
- "i",
- "u",
"abbr",
+ "b",
"cite",
"del",
+ "div",
"em",
+ "i",
"ins",
"kbd",
+ "label",
"mark",
+ "p",
"s",
"samp",
+ "span",
"sub",
"sup",
+ "u",
+ ],
+ Var[
+ Literal[
+ "abbr",
+ "b",
+ "cite",
+ "del",
+ "div",
+ "em",
+ "i",
+ "ins",
+ "kbd",
+ "label",
+ "mark",
+ "p",
+ "s",
+ "samp",
+ "span",
+ "sub",
+ "sup",
+ "u",
+ ]
],
]
] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -98,184 +101,152 @@ class Text(elements.Span, RadixThemesComponent):
Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
weight: Optional[
Union[
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
Var[
Union[
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
- Literal["light", "regular", "medium", "bold"],
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
]
],
- Literal["light", "regular", "medium", "bold"],
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
]
] = None,
align: Optional[
Union[
+ Breakpoints[str, Literal["center", "left", "right"]],
+ Literal["center", "left", "right"],
Var[
Union[
- Breakpoints[str, Literal["left", "center", "right"]],
- Literal["left", "center", "right"],
+ Breakpoints[str, Literal["center", "left", "right"]],
+ Literal["center", "left", "right"],
]
],
- Literal["left", "center", "right"],
- Breakpoints[str, Literal["left", "center", "right"]],
]
] = None,
trim: Optional[
Union[
+ Breakpoints[str, Literal["both", "end", "normal", "start"]],
+ Literal["both", "end", "normal", "start"],
Var[
Union[
- Breakpoints[str, Literal["normal", "start", "end", "both"]],
- Literal["normal", "start", "end", "both"],
+ Breakpoints[str, Literal["both", "end", "normal", "start"]],
+ Literal["both", "end", "normal", "start"],
]
],
- Literal["normal", "start", "end", "both"],
- Breakpoints[str, Literal["normal", "start", "end", "both"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Text":
"""Create a new component instance.
@@ -293,7 +264,7 @@ class Text(elements.Span, RadixThemesComponent):
trim: Removes the leading trim space: "normal" | "start" | "end" | "both"
color_scheme: Overrides the accent color inherited from the Theme.
high_contrast: Whether to render the text with higher contrast color
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -330,53 +301,55 @@ class Span(Text):
*children,
as_: Optional[
Union[
- Var[
- Literal[
- "p",
- "label",
- "div",
- "span",
- "b",
- "i",
- "u",
- "abbr",
- "cite",
- "del",
- "em",
- "ins",
- "kbd",
- "mark",
- "s",
- "samp",
- "sub",
- "sup",
- ]
- ],
Literal[
- "p",
- "label",
- "div",
- "span",
- "b",
- "i",
- "u",
"abbr",
+ "b",
"cite",
"del",
+ "div",
"em",
+ "i",
"ins",
"kbd",
+ "label",
"mark",
+ "p",
"s",
"samp",
+ "span",
"sub",
"sup",
+ "u",
+ ],
+ Var[
+ Literal[
+ "abbr",
+ "b",
+ "cite",
+ "del",
+ "div",
+ "em",
+ "i",
+ "ins",
+ "kbd",
+ "label",
+ "mark",
+ "p",
+ "s",
+ "samp",
+ "span",
+ "sub",
+ "sup",
+ "u",
+ ]
],
]
] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -385,184 +358,152 @@ class Span(Text):
Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
weight: Optional[
Union[
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
Var[
Union[
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
- Literal["light", "regular", "medium", "bold"],
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
]
],
- Literal["light", "regular", "medium", "bold"],
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
]
] = None,
align: Optional[
Union[
+ Breakpoints[str, Literal["center", "left", "right"]],
+ Literal["center", "left", "right"],
Var[
Union[
- Breakpoints[str, Literal["left", "center", "right"]],
- Literal["left", "center", "right"],
+ Breakpoints[str, Literal["center", "left", "right"]],
+ Literal["center", "left", "right"],
]
],
- Literal["left", "center", "right"],
- Breakpoints[str, Literal["left", "center", "right"]],
]
] = None,
trim: Optional[
Union[
+ Breakpoints[str, Literal["both", "end", "normal", "start"]],
+ Literal["both", "end", "normal", "start"],
Var[
Union[
- Breakpoints[str, Literal["normal", "start", "end", "both"]],
- Literal["normal", "start", "end", "both"],
+ Breakpoints[str, Literal["both", "end", "normal", "start"]],
+ Literal["both", "end", "normal", "start"],
]
],
- Literal["normal", "start", "end", "both"],
- Breakpoints[str, Literal["normal", "start", "end", "both"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Span":
"""Create a new component instance.
@@ -580,7 +521,7 @@ class Span(Text):
trim: Removes the leading trim space: "normal" | "start" | "end" | "both"
color_scheme: Overrides the accent color inherited from the Theme.
high_contrast: Whether to render the text with higher contrast color
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -615,81 +556,51 @@ class Em(elements.Em, RadixThemesComponent):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Em":
"""Create a new component instance.
@@ -699,7 +610,7 @@ class Em(elements.Em, RadixThemesComponent):
Args:
*children: Child components.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -736,85 +647,55 @@ class Kbd(elements.Kbd, RadixThemesComponent):
*children,
size: Optional[
Union[
- Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
+ Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Kbd":
"""Create a new component instance.
@@ -825,7 +706,7 @@ class Kbd(elements.Kbd, RadixThemesComponent):
Args:
*children: Child components.
size: Text size: "1" - "9"
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -860,82 +741,52 @@ class Quote(elements.Q, RadixThemesComponent):
def create( # type: ignore
cls,
*children,
- cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Quote":
"""Create a new component instance.
@@ -946,7 +797,7 @@ class Quote(elements.Q, RadixThemesComponent):
Args:
*children: Child components.
cite: Specifies the source URL of the quote.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -981,81 +832,51 @@ class Strong(elements.Strong, RadixThemesComponent):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Strong":
"""Create a new component instance.
@@ -1065,7 +886,7 @@ class Strong(elements.Strong, RadixThemesComponent):
Args:
*children: Child components.
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
@@ -1107,52 +928,54 @@ class TextNamespace(ComponentNamespace):
as_child: Optional[Union[Var[bool], bool]] = None,
as_: Optional[
Union[
- Var[
- Literal[
- "p",
- "label",
- "div",
- "span",
- "b",
- "i",
- "u",
- "abbr",
- "cite",
- "del",
- "em",
- "ins",
- "kbd",
- "mark",
- "s",
- "samp",
- "sub",
- "sup",
- ]
- ],
Literal[
- "p",
- "label",
- "div",
- "span",
- "b",
- "i",
- "u",
"abbr",
+ "b",
"cite",
"del",
+ "div",
"em",
+ "i",
"ins",
"kbd",
+ "label",
"mark",
+ "p",
"s",
"samp",
+ "span",
"sub",
"sup",
+ "u",
+ ],
+ Var[
+ Literal[
+ "abbr",
+ "b",
+ "cite",
+ "del",
+ "div",
+ "em",
+ "i",
+ "ins",
+ "kbd",
+ "label",
+ "mark",
+ "p",
+ "s",
+ "samp",
+ "span",
+ "sub",
+ "sup",
+ "u",
+ ]
],
]
] = None,
size: Optional[
Union[
+ Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
+ Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
Var[
Union[
Breakpoints[
@@ -1161,184 +984,152 @@ class TextNamespace(ComponentNamespace):
Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
]
],
- Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"],
- Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],
]
] = None,
weight: Optional[
Union[
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
Var[
Union[
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
- Literal["light", "regular", "medium", "bold"],
+ Breakpoints[str, Literal["bold", "light", "medium", "regular"]],
+ Literal["bold", "light", "medium", "regular"],
]
],
- Literal["light", "regular", "medium", "bold"],
- Breakpoints[str, Literal["light", "regular", "medium", "bold"]],
]
] = None,
align: Optional[
Union[
+ Breakpoints[str, Literal["center", "left", "right"]],
+ Literal["center", "left", "right"],
Var[
Union[
- Breakpoints[str, Literal["left", "center", "right"]],
- Literal["left", "center", "right"],
+ Breakpoints[str, Literal["center", "left", "right"]],
+ Literal["center", "left", "right"],
]
],
- Literal["left", "center", "right"],
- Breakpoints[str, Literal["left", "center", "right"]],
]
] = None,
trim: Optional[
Union[
+ Breakpoints[str, Literal["both", "end", "normal", "start"]],
+ Literal["both", "end", "normal", "start"],
Var[
Union[
- Breakpoints[str, Literal["normal", "start", "end", "both"]],
- Literal["normal", "start", "end", "both"],
+ Breakpoints[str, Literal["both", "end", "normal", "start"]],
+ Literal["both", "end", "normal", "start"],
]
],
- Literal["normal", "start", "end", "both"],
- Breakpoints[str, Literal["normal", "start", "end", "both"]],
]
] = None,
color_scheme: Optional[
Union[
- Var[
- Literal[
- "tomato",
- "red",
- "ruby",
- "crimson",
- "pink",
- "plum",
- "purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
- "sky",
- "mint",
- "lime",
- "yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
- ]
- ],
Literal[
- "tomato",
- "red",
- "ruby",
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
"crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
"pink",
"plum",
"purple",
- "violet",
- "iris",
- "indigo",
- "blue",
- "cyan",
- "teal",
- "jade",
- "green",
- "grass",
- "brown",
- "orange",
+ "red",
+ "ruby",
"sky",
- "mint",
- "lime",
+ "teal",
+ "tomato",
+ "violet",
"yellow",
- "amber",
- "gold",
- "bronze",
- "gray",
+ ],
+ Var[
+ Literal[
+ "amber",
+ "blue",
+ "bronze",
+ "brown",
+ "crimson",
+ "cyan",
+ "gold",
+ "grass",
+ "gray",
+ "green",
+ "indigo",
+ "iris",
+ "jade",
+ "lime",
+ "mint",
+ "orange",
+ "pink",
+ "plum",
+ "purple",
+ "red",
+ "ruby",
+ "sky",
+ "teal",
+ "tomato",
+ "violet",
+ "yellow",
+ ]
],
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Text":
"""Create a new component instance.
@@ -1356,7 +1147,7 @@ class TextNamespace(ComponentNamespace):
trim: Removes the leading trim space: "normal" | "start" | "end" | "both"
color_scheme: Overrides the accent color inherited from the Theme.
high_contrast: Whether to render the text with higher contrast color
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.
context_menu: Defines the ID of a element which will serve as the element's context menu.
diff --git a/reflex/components/react_player/__init__.py b/reflex/components/react_player/__init__.py
index 8c4a4486f..3f807b1a0 100644
--- a/reflex/components/react_player/__init__.py
+++ b/reflex/components/react_player/__init__.py
@@ -1,5 +1,6 @@
"""React Player component for audio and video."""
+from . import react_player
from .audio import Audio
from .video import Video
diff --git a/reflex/components/react_player/audio.pyi b/reflex/components/react_player/audio.pyi
index f138d3fd8..797d5ad8a 100644
--- a/reflex/components/react_player/audio.pyi
+++ b/reflex/components/react_player/audio.pyi
@@ -3,12 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
+import reflex
from reflex.components.react_player.react_player import ReactPlayer
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class Audio(ReactPlayer):
pass
@@ -32,100 +33,49 @@ class Audio(ReactPlayer):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_buffer: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_buffer_end: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click_preview: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_disable_pip: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_buffer: Optional[EventType[[], BASE_STATE]] = None,
+ on_buffer_end: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_click_preview: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_disable_pip: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
on_duration: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_enable_pip: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_ended: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_error: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_pause: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_play: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_playback_quality_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_playback_rate_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[float], BASE_STATE]]
] = None,
+ on_enable_pip: Optional[EventType[[], BASE_STATE]] = None,
+ on_ended: Optional[EventType[[], BASE_STATE]] = None,
+ on_error: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_pause: Optional[EventType[[], BASE_STATE]] = None,
+ on_play: Optional[EventType[[], BASE_STATE]] = None,
+ on_playback_quality_change: Optional[EventType[[], BASE_STATE]] = None,
+ on_playback_rate_change: Optional[EventType[[], BASE_STATE]] = None,
on_progress: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_ready: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[
+ [reflex.components.react_player.react_player.Progress], BASE_STATE
+ ],
+ ]
] = None,
+ on_ready: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
on_seek: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_start: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[float], BASE_STATE]]
] = None,
+ on_start: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Audio":
"""Create the component.
@@ -141,6 +91,22 @@ class Audio(ReactPlayer):
muted: Mutes the player
width: Set the width of the player: ex:640px
height: Set the height of the player: ex:640px
+ on_ready: Called when media is loaded and ready to play. If playing is set to true, media will play immediately.
+ on_start: Called when media starts playing.
+ on_play: Called when media starts or resumes playing after pausing or buffering.
+ on_progress: Callback containing played and loaded progress as a fraction, and playedSeconds and loadedSeconds in seconds. eg { played: 0.12, playedSeconds: 11.3, loaded: 0.34, loadedSeconds: 16.7 }
+ on_duration: Callback containing duration of the media, in seconds.
+ on_pause: Called when media is paused.
+ on_buffer: Called when media starts buffering.
+ on_buffer_end: Called when media has finished buffering. Works for files, YouTube and Facebook.
+ on_seek: Called when media seeks with seconds parameter.
+ on_playback_rate_change: Called when playback rate of the player changed. Only supported by YouTube, Vimeo (if enabled), Wistia, and file paths.
+ on_playback_quality_change: Called when playback quality of the player changed. Only supported by YouTube (if enabled).
+ on_ended: Called when media finishes playing. Does not fire when loop is set to true.
+ on_error: Called when an error occurs whilst attempting to play media.
+ on_click_preview: Called when user clicks the light mode preview.
+ on_enable_pip: Called when picture-in-picture mode is enabled.
+ on_disable_pip: Called when picture-in-picture mode is disabled.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/react_player/react_player.py b/reflex/components/react_player/react_player.py
index 1c9b20cea..fb0319ceb 100644
--- a/reflex/components/react_player/react_player.py
+++ b/reflex/components/react_player/react_player.py
@@ -2,9 +2,20 @@
from __future__ import annotations
+from typing_extensions import TypedDict
+
from reflex.components.component import NoSSRComponent
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec
+from reflex.vars.base import Var
+
+
+class Progress(TypedDict):
+ """Callback containing played and loaded progress as a fraction, and playedSeconds and loadedSeconds in seconds."""
+
+ played: float
+ playedSeconds: float
+ loaded: float
+ loadedSeconds: float
class ReactPlayer(NoSSRComponent):
@@ -12,7 +23,7 @@ class ReactPlayer(NoSSRComponent):
reference: https://github.com/cookpete/react-player.
"""
- library = "react-player@2.12.0"
+ library = "react-player@2.16.0"
tag = "ReactPlayer"
@@ -46,49 +57,49 @@ class ReactPlayer(NoSSRComponent):
height: Var[str]
# Called when media is loaded and ready to play. If playing is set to true, media will play immediately.
- on_ready: EventHandler[lambda: []]
+ on_ready: EventHandler[no_args_event_spec]
# Called when media starts playing.
- on_start: EventHandler[lambda: []]
+ on_start: EventHandler[no_args_event_spec]
# Called when media starts or resumes playing after pausing or buffering.
- on_play: EventHandler[lambda: []]
+ on_play: EventHandler[no_args_event_spec]
# Callback containing played and loaded progress as a fraction, and playedSeconds and loadedSeconds in seconds. eg { played: 0.12, playedSeconds: 11.3, loaded: 0.34, loadedSeconds: 16.7 }
- on_progress: EventHandler[lambda progress: [progress]]
+ on_progress: EventHandler[passthrough_event_spec(Progress)]
# Callback containing duration of the media, in seconds.
- on_duration: EventHandler[lambda seconds: [seconds]]
+ on_duration: EventHandler[passthrough_event_spec(float)]
# Called when media is paused.
- on_pause: EventHandler[lambda: []]
+ on_pause: EventHandler[no_args_event_spec]
# Called when media starts buffering.
- on_buffer: EventHandler[lambda: []]
+ on_buffer: EventHandler[no_args_event_spec]
# Called when media has finished buffering. Works for files, YouTube and Facebook.
- on_buffer_end: EventHandler[lambda: []]
+ on_buffer_end: EventHandler[no_args_event_spec]
# Called when media seeks with seconds parameter.
- on_seek: EventHandler[lambda seconds: [seconds]]
+ on_seek: EventHandler[passthrough_event_spec(float)]
# Called when playback rate of the player changed. Only supported by YouTube, Vimeo (if enabled), Wistia, and file paths.
- on_playback_rate_change: EventHandler[lambda e0: []]
+ on_playback_rate_change: EventHandler[no_args_event_spec]
# Called when playback quality of the player changed. Only supported by YouTube (if enabled).
- on_playback_quality_change: EventHandler[lambda e0: []]
+ on_playback_quality_change: EventHandler[no_args_event_spec]
# Called when media finishes playing. Does not fire when loop is set to true.
- on_ended: EventHandler[lambda: []]
+ on_ended: EventHandler[no_args_event_spec]
# Called when an error occurs whilst attempting to play media.
- on_error: EventHandler[lambda: []]
+ on_error: EventHandler[no_args_event_spec]
# Called when user clicks the light mode preview.
- on_click_preview: EventHandler[lambda: []]
+ on_click_preview: EventHandler[no_args_event_spec]
# Called when picture-in-picture mode is enabled.
- on_enable_pip: EventHandler[lambda: []]
+ on_enable_pip: EventHandler[no_args_event_spec]
# Called when picture-in-picture mode is disabled.
- on_disable_pip: EventHandler[lambda: []]
+ on_disable_pip: EventHandler[no_args_event_spec]
diff --git a/reflex/components/react_player/react_player.pyi b/reflex/components/react_player/react_player.pyi
index 79e38353a..4e2a8a821 100644
--- a/reflex/components/react_player/react_player.pyi
+++ b/reflex/components/react_player/react_player.pyi
@@ -3,12 +3,20 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
+
+from typing_extensions import TypedDict
from reflex.components.component import NoSSRComponent
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
+
+class Progress(TypedDict):
+ played: float
+ playedSeconds: float
+ loaded: float
+ loadedSeconds: float
class ReactPlayer(NoSSRComponent):
@overload
@@ -30,100 +38,44 @@ class ReactPlayer(NoSSRComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_buffer: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_buffer_end: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click_preview: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_disable_pip: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_buffer: Optional[EventType[[], BASE_STATE]] = None,
+ on_buffer_end: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_click_preview: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_disable_pip: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
on_duration: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_enable_pip: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_ended: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_error: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_pause: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_play: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_playback_quality_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_playback_rate_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[float], BASE_STATE]]
] = None,
+ on_enable_pip: Optional[EventType[[], BASE_STATE]] = None,
+ on_ended: Optional[EventType[[], BASE_STATE]] = None,
+ on_error: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_pause: Optional[EventType[[], BASE_STATE]] = None,
+ on_play: Optional[EventType[[], BASE_STATE]] = None,
+ on_playback_quality_change: Optional[EventType[[], BASE_STATE]] = None,
+ on_playback_rate_change: Optional[EventType[[], BASE_STATE]] = None,
on_progress: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_ready: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[Progress], BASE_STATE]]
] = None,
+ on_ready: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
on_seek: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_start: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[float], BASE_STATE]]
] = None,
+ on_start: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ReactPlayer":
"""Create the component.
@@ -139,6 +91,22 @@ class ReactPlayer(NoSSRComponent):
muted: Mutes the player
width: Set the width of the player: ex:640px
height: Set the height of the player: ex:640px
+ on_ready: Called when media is loaded and ready to play. If playing is set to true, media will play immediately.
+ on_start: Called when media starts playing.
+ on_play: Called when media starts or resumes playing after pausing or buffering.
+ on_progress: Callback containing played and loaded progress as a fraction, and playedSeconds and loadedSeconds in seconds. eg { played: 0.12, playedSeconds: 11.3, loaded: 0.34, loadedSeconds: 16.7 }
+ on_duration: Callback containing duration of the media, in seconds.
+ on_pause: Called when media is paused.
+ on_buffer: Called when media starts buffering.
+ on_buffer_end: Called when media has finished buffering. Works for files, YouTube and Facebook.
+ on_seek: Called when media seeks with seconds parameter.
+ on_playback_rate_change: Called when playback rate of the player changed. Only supported by YouTube, Vimeo (if enabled), Wistia, and file paths.
+ on_playback_quality_change: Called when playback quality of the player changed. Only supported by YouTube (if enabled).
+ on_ended: Called when media finishes playing. Does not fire when loop is set to true.
+ on_error: Called when an error occurs whilst attempting to play media.
+ on_click_preview: Called when user clicks the light mode preview.
+ on_enable_pip: Called when picture-in-picture mode is enabled.
+ on_disable_pip: Called when picture-in-picture mode is disabled.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/react_player/video.pyi b/reflex/components/react_player/video.pyi
index 4016c6f44..3739d45c0 100644
--- a/reflex/components/react_player/video.pyi
+++ b/reflex/components/react_player/video.pyi
@@ -3,12 +3,13 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Optional, Union, overload
+from typing import Any, Dict, Optional, Union, overload
+import reflex
from reflex.components.react_player.react_player import ReactPlayer
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class Video(ReactPlayer):
pass
@@ -32,100 +33,49 @@ class Video(ReactPlayer):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_buffer: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_buffer_end: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click_preview: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_disable_pip: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_buffer: Optional[EventType[[], BASE_STATE]] = None,
+ on_buffer_end: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_click_preview: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_disable_pip: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
on_duration: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_enable_pip: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_ended: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_error: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_pause: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_play: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_playback_quality_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_playback_rate_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[float], BASE_STATE]]
] = None,
+ on_enable_pip: Optional[EventType[[], BASE_STATE]] = None,
+ on_ended: Optional[EventType[[], BASE_STATE]] = None,
+ on_error: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_pause: Optional[EventType[[], BASE_STATE]] = None,
+ on_play: Optional[EventType[[], BASE_STATE]] = None,
+ on_playback_quality_change: Optional[EventType[[], BASE_STATE]] = None,
+ on_playback_rate_change: Optional[EventType[[], BASE_STATE]] = None,
on_progress: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_ready: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[
+ [reflex.components.react_player.react_player.Progress], BASE_STATE
+ ],
+ ]
] = None,
+ on_ready: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
on_seek: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_start: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[float], BASE_STATE]]
] = None,
+ on_start: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Video":
"""Create the component.
@@ -141,6 +91,22 @@ class Video(ReactPlayer):
muted: Mutes the player
width: Set the width of the player: ex:640px
height: Set the height of the player: ex:640px
+ on_ready: Called when media is loaded and ready to play. If playing is set to true, media will play immediately.
+ on_start: Called when media starts playing.
+ on_play: Called when media starts or resumes playing after pausing or buffering.
+ on_progress: Callback containing played and loaded progress as a fraction, and playedSeconds and loadedSeconds in seconds. eg { played: 0.12, playedSeconds: 11.3, loaded: 0.34, loadedSeconds: 16.7 }
+ on_duration: Callback containing duration of the media, in seconds.
+ on_pause: Called when media is paused.
+ on_buffer: Called when media starts buffering.
+ on_buffer_end: Called when media has finished buffering. Works for files, YouTube and Facebook.
+ on_seek: Called when media seeks with seconds parameter.
+ on_playback_rate_change: Called when playback rate of the player changed. Only supported by YouTube, Vimeo (if enabled), Wistia, and file paths.
+ on_playback_quality_change: Called when playback quality of the player changed. Only supported by YouTube (if enabled).
+ on_ended: Called when media finishes playing. Does not fire when loop is set to true.
+ on_error: Called when an error occurs whilst attempting to play media.
+ on_click_preview: Called when user clicks the light mode preview.
+ on_enable_pip: Called when picture-in-picture mode is enabled.
+ on_disable_pip: Called when picture-in-picture mode is disabled.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/recharts/cartesian.py b/reflex/components/recharts/cartesian.py
index 0f2ec2f32..9f6bf672b 100644
--- a/reflex/components/recharts/cartesian.py
+++ b/reflex/components/recharts/cartesian.py
@@ -6,8 +6,8 @@ from typing import Any, Dict, List, Union
from reflex.constants import EventTriggers
from reflex.constants.colors import Color
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, no_args_event_spec
+from reflex.vars.base import LiteralVar, Var
from .recharts import (
LiteralAnimationEasing,
@@ -15,6 +15,7 @@ from .recharts import (
LiteralDirection,
LiteralIfOverflow,
LiteralInterval,
+ LiteralIntervalAxis,
LiteralLayout,
LiteralLegendType,
LiteralLineType,
@@ -24,6 +25,7 @@ from .recharts import (
LiteralPolarRadiusType,
LiteralScale,
LiteralShape,
+ LiteralTextAnchor,
Recharts,
)
@@ -34,40 +36,46 @@ class Axis(Recharts):
# The key of data displayed in the axis.
data_key: Var[Union[str, int]]
- # If set true, the axis do not display in the chart.
+ # If set true, the axis do not display in the chart. Default: False
hide: Var[bool]
# The width of axis which is usually calculated internally.
width: Var[Union[str, int]]
- # The height of axis, which can be setted by user.
+ # The height of axis, which can be set by user.
height: Var[Union[str, int]]
# The type of axis 'number' | 'category'
type_: Var[LiteralPolarRadiusType]
- # Allow the ticks of XAxis to be decimals or not.
+ # If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd"
+ interval: Var[Union[LiteralIntervalAxis, int]]
+
+ # Allow the ticks of Axis to be decimals or not. Default: True
allow_decimals: Var[bool]
- # When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain.
+ # When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. Default: False
allow_data_overflow: Var[bool]
- # Allow the axis has duplicated categorys or not when the type of axis is "category".
+ # Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True
allow_duplicated_category: Var[bool]
- # If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line.
+ # The range of the axis. Work best in conjunction with allow_data_overflow. Default: [0, "auto"]
+ domain: Var[List]
+
+ # If set false, no axis line will be drawn. Default: True
axis_line: Var[bool]
- # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside.
+ # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False
mirror: Var[bool]
- # Reverse the ticks or not.
+ # Reverse the ticks or not. Default: False
reversed: Var[bool]
# The label of axis, which appears next to the axis.
label: Var[Union[str, int, Dict[str, Any]]]
- # If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold' | Function
+ # If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto"
scale: Var[LiteralScale]
# The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart.
@@ -82,44 +90,44 @@ class Axis(Recharts):
# If set false, no ticks will be drawn.
tick: Var[bool]
- # The count of axis ticks.
+ # The count of axis ticks. Not used if 'type' is 'category'. Default: 5
tick_count: Var[int]
- # If set false, no axis tick lines will be drawn.
- tick_line: Var[bool] = Var.create_safe(False)
+ # If set false, no axis tick lines will be drawn. Default: True
+ tick_line: Var[bool]
- # The length of tick line.
+ # The length of tick line. Default: 6
tick_size: Var[int]
- # The minimum gap between two adjacent labels
+ # The minimum gap between two adjacent labels. Default: 5
min_tick_gap: Var[int]
- # The stroke color of axis
- stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 9))
+ # The stroke color of axis. Default: rx.color("gray", 9)
+ stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 9))
- # The text anchor of axis
- text_anchor: Var[str] # 'start', 'middle', 'end'
+ # The text anchor of axis. Default: "middle"
+ text_anchor: Var[LiteralTextAnchor]
# The customized event handler of click on the ticks of this axis
- on_click: EventHandler[lambda: []]
+ on_click: EventHandler[no_args_event_spec]
# The customized event handler of mousedown on the ticks of this axis
- on_mouse_down: EventHandler[lambda: []]
+ on_mouse_down: EventHandler[no_args_event_spec]
# The customized event handler of mouseup on the ticks of this axis
- on_mouse_up: EventHandler[lambda: []]
+ on_mouse_up: EventHandler[no_args_event_spec]
# The customized event handler of mousemove on the ticks of this axis
- on_mouse_move: EventHandler[lambda: []]
+ on_mouse_move: EventHandler[no_args_event_spec]
# The customized event handler of mouseout on the ticks of this axis
- on_mouse_out: EventHandler[lambda: []]
+ on_mouse_out: EventHandler[no_args_event_spec]
# The customized event handler of mouseenter on the ticks of this axis
- on_mouse_enter: EventHandler[lambda: []]
+ on_mouse_enter: EventHandler[no_args_event_spec]
# The customized event handler of mouseleave on the ticks of this axis
- on_mouse_leave: EventHandler[lambda: []]
+ on_mouse_leave: EventHandler[no_args_event_spec]
class XAxis(Axis):
@@ -129,17 +137,20 @@ class XAxis(Axis):
alias = "RechartsXAxis"
- # The orientation of axis 'top' | 'bottom'
+ # The orientation of axis 'top' | 'bottom'. Default: "bottom"
orientation: Var[LiteralOrientationTopBottom]
- # The id of x-axis which is corresponding to the data.
+ # The id of x-axis which is corresponding to the data. Default: 0
x_axis_id: Var[Union[str, int]]
- # Ensures that all datapoints within a chart contribute to its domain calculation, even when they are hidden
- include_hidden: Var[bool] = Var.create_safe(False)
+ # Ensures that all datapoints within a chart contribute to its domain calculation, even when they are hidden. Default: False
+ include_hidden: Var[bool]
- # The range of the axis. Work best in conjuction with allow_data_overflow.
- domain: Var[List]
+ # The angle of axis ticks. Default: 0
+ angle: Var[int]
+
+ # Specify the padding of x-axis. Default: {"left": 0, "right": 0}
+ padding: Var[Dict[str, int]]
class YAxis(Axis):
@@ -149,14 +160,14 @@ class YAxis(Axis):
alias = "RechartsYAxis"
- # The orientation of axis 'left' | 'right'
+ # The orientation of axis 'left' | 'right'. Default: "left"
orientation: Var[LiteralOrientationLeftRight]
- # The id of y-axis which is corresponding to the data.
+ # The id of y-axis which is corresponding to the data. Default: 0
y_axis_id: Var[Union[str, int]]
- # The range of the axis. Work best in conjuction with allow_data_overflow.
- domain: Var[List]
+ # Specify the padding of y-axis. Default: {"top": 0, "bottom": 0}
+ padding: Var[Dict[str, int]]
class ZAxis(Recharts):
@@ -164,12 +175,15 @@ class ZAxis(Recharts):
tag = "ZAxis"
- alias = "RechartszAxis"
+ alias = "RechartsZAxis"
# The key of data displayed in the axis.
data_key: Var[Union[str, int]]
- # The range of axis.
+ # The unique id of z-axis. Default: 0
+ z_axis_id: Var[Union[str, int]]
+
+ # The range of axis. Default: [10, 10]
range: Var[List[int]]
# The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart.
@@ -178,7 +192,7 @@ class ZAxis(Recharts):
# The name of data displayed in the axis. This option will be used to represent an index in a scatter chart.
name: Var[Union[str, int]]
- # If 'auto' set, the scale function is decided by the type of chart, and the props type.
+ # If 'auto' set, the scale function is decided by the type of chart, and the props type. Default: "auto"
scale: Var[LiteralScale]
@@ -189,40 +203,40 @@ class Brush(Recharts):
alias = "RechartsBrush"
- # Stroke color
- stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 9))
+ # Stroke color. Default: rx.color("gray", 9)
+ stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 9))
- # The fill color of brush.
- fill: Var[Union[str, Color]] = Var.create_safe(Color("gray", 2))
+ # The fill color of brush. Default: rx.color("gray", 2)
+ fill: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 2))
# The key of data displayed in the axis.
data_key: Var[Union[str, int]]
- # The x-coordinate of brush.
+ # The x-coordinate of brush. Default: 0
x: Var[int]
- # The y-coordinate of brush.
+ # The y-coordinate of brush. Default: 0
y: Var[int]
- # The width of brush.
+ # The width of brush. Default: 0
width: Var[int]
- # The height of brush.
+ # The height of brush. Default: 40
height: Var[int]
- # The data domain of brush, [min, max].
+ # The original data of a LineChart, a BarChart or an AreaChart.
data: Var[List[Any]]
- # The width of each traveller.
+ # The width of each traveller. Default: 5
traveller_width: Var[int]
- # The data with gap of refreshing chart. If the option is not set, the chart will be refreshed every time
+ # The data with gap of refreshing chart. If the option is not set, the chart will be refreshed every time. Default: 1
gap: Var[int]
- # The default start index of brush. If the option is not set, the start index will be 0.
+ # The default start index of brush. If the option is not set, the start index will be 0. Default: 0
start_index: Var[int]
- # The default end index of brush. If the option is not set, the end index will be 1.
+ # The default end index of brush. If the option is not set, the end index will be calculated by the length of data.
end_index: Var[int]
# The fill color of brush
@@ -238,7 +252,7 @@ class Brush(Recharts):
A dict mapping the event trigger to the var that is passed to the handler.
"""
return {
- EventTriggers.ON_CHANGE: lambda: [],
+ EventTriggers.ON_CHANGE: no_args_event_spec,
}
@@ -251,38 +265,62 @@ class Cartesian(Recharts):
# The key of a group of data which should be unique in an area chart.
data_key: Var[Union[str, int]]
- # The id of x-axis which is corresponding to the data.
+ # The id of x-axis which is corresponding to the data. Default: 0
x_axis_id: Var[Union[str, int]]
- # The id of y-axis which is corresponding to the data.
+ # The id of y-axis which is corresponding to the data. Default: 0
y_axis_id: Var[Union[str, int]]
- # The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none'optional
+ # The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none' optional
legend_type: Var[LiteralLegendType]
+ # If set false, animation of bar will be disabled. Default: True
+ is_animation_active: Var[bool]
+
+ # Specifies when the animation should begin, the unit of this option is ms. Default: 0
+ animation_begin: Var[int]
+
+ # Specifies the duration of animation, the unit of this option is ms. Default: 1500
+ animation_duration: Var[int]
+
+ # The type of easing function. Default: "ease"
+ animation_easing: Var[LiteralAnimationEasing]
+
+ # The unit of data. This option will be used in tooltip.
+ unit: Var[Union[str, int]]
+
+ # The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively.
+ name: Var[Union[str, int]]
+
+ # The customized event handler of animation start
+ on_animation_start: EventHandler[no_args_event_spec]
+
+ # The customized event handler of animation end
+ on_animation_end: EventHandler[no_args_event_spec]
+
# The customized event handler of click on the component in this group
- on_click: EventHandler[lambda: []]
+ on_click: EventHandler[no_args_event_spec]
# The customized event handler of mousedown on the component in this group
- on_mouse_down: EventHandler[lambda: []]
+ on_mouse_down: EventHandler[no_args_event_spec]
# The customized event handler of mouseup on the component in this group
- on_mouse_up: EventHandler[lambda: []]
+ on_mouse_up: EventHandler[no_args_event_spec]
# The customized event handler of mousemove on the component in this group
- on_mouse_move: EventHandler[lambda: []]
+ on_mouse_move: EventHandler[no_args_event_spec]
# The customized event handler of mouseover on the component in this group
- on_mouse_over: EventHandler[lambda: []]
+ on_mouse_over: EventHandler[no_args_event_spec]
# The customized event handler of mouseout on the component in this group
- on_mouse_out: EventHandler[lambda: []]
+ on_mouse_out: EventHandler[no_args_event_spec]
# The customized event handler of mouseenter on the component in this group
- on_mouse_enter: EventHandler[lambda: []]
+ on_mouse_enter: EventHandler[no_args_event_spec]
# The customized event handler of mouseleave on the component in this group
- on_mouse_leave: EventHandler[lambda: []]
+ on_mouse_leave: EventHandler[no_args_event_spec]
class Area(Cartesian):
@@ -292,40 +330,43 @@ class Area(Cartesian):
alias = "RechartsArea"
- # The color of the line stroke.
- stroke: Var[Union[str, Color]] = Var.create_safe(Color("accent", 9))
+ # The color of the line stroke. Default: rx.color("accent", 9)
+ stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9))
- # The width of the line stroke.
- stroke_width: Var[int] = Var.create_safe(1)
+ # The width of the line stroke. Default: 1
+ stroke_width: Var[int]
- # The color of the area fill.
- fill: Var[Union[str, Color]] = Var.create_safe(Color("accent", 5))
+ # The color of the area fill. Default: rx.color("accent", 5)
+ fill: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 5))
- # The interpolation type of area. And customized interpolation function can be set to type. 'basis' | 'basisClosed' | 'basisOpen' | 'bumpX' | 'bumpY' | 'bump' | 'linear' | 'linearClosed' | 'natural' | 'monotoneX' | 'monotoneY' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter' |
- type_: Var[LiteralAreaType] = Var.create_safe("monotone", _var_is_string=True)
+ # The interpolation type of area. And customized interpolation function can be set to type. 'basis' | 'basisClosed' | 'basisOpen' | 'bumpX' | 'bumpY' | 'bump' | 'linear' | 'linearClosed' | 'natural' | 'monotoneX' | 'monotoneY' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter'. Default: "monotone"
+ type_: Var[LiteralAreaType] = LiteralVar.create("monotone")
- # If false set, dots will not be drawn. If true set, dots will be drawn which have the props calculated internally.
+ # If false set, dots will not be drawn. If true set, dots will be drawn which have the props calculated internally. Default: False
dot: Var[Union[bool, Dict[str, Any]]]
- # The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally.
- active_dot: Var[Union[bool, Dict[str, Any]]] = Var.create_safe(
+ # The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {stroke: rx.color("accent", 2), fill: rx.color("accent", 10)}
+ active_dot: Var[Union[bool, Dict[str, Any]]] = LiteralVar.create(
{
"stroke": Color("accent", 2),
"fill": Color("accent", 10),
}
)
- # If set false, labels will not be drawn. If set true, labels will be drawn which have the props calculated internally.
+ # If set false, labels will not be drawn. If set true, labels will be drawn which have the props calculated internally. Default: False
label: Var[bool]
+ # The value which can describle the line, usually calculated internally.
+ base_line: Var[Union[str, List[Dict[str, Any]]]]
+
+ # The coordinates of all the points in the area, usually calculated internally.
+ points: Var[List[Dict[str, Any]]]
+
# The stack id of area, when two areas have the same value axis and same stack_id, then the two areas are stacked in order.
stack_id: Var[Union[str, int]]
- # The unit of data. This option will be used in tooltip.
- unit: Var[Union[str, int]]
-
- # The name of data. This option will be used in tooltip and legend to represent a bar. If no value was set to this option, the value of dataKey will be used alternatively.
- name: Var[Union[str, int]]
+ # Whether to connect a graph area across null points. Default: False
+ connect_nulls: Var[bool]
# Valid children components
_valid_children: List[str] = ["LabelList"]
@@ -344,12 +385,13 @@ class Bar(Cartesian):
# The width of the line stroke.
stroke_width: Var[int]
- # The width of the line stroke.
- fill: Var[Union[str, Color]] = Var.create_safe(Color("accent", 9))
- # If false set, background of bars will not be drawn. If true set, background of bars will be drawn which have the props calculated internally.
+ # The width of the line stroke. Default: Color("accent", 9)
+ fill: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9))
+
+ # If false set, background of bars will not be drawn. If true set, background of bars will be drawn which have the props calculated internally. Default: False
background: Var[bool]
- # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally.
+ # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
label: Var[bool]
# The stack id of bar, when two bars have the same value axis and same stack_id, then the two bars are stacked in order.
@@ -370,30 +412,15 @@ class Bar(Cartesian):
# Max size of the bar
max_bar_size: Var[int]
+ # If set a value, the option is the radius of all the rounded corners. If set a array, the option are in turn the radiuses of top-left corner, top-right corner, bottom-right corner, bottom-left corner. Default: 0
+ radius: Var[Union[int, List[int]]]
+
# The active bar is shown when a user enters a bar chart and this chart has tooltip. If set to false, no active bar will be drawn. If set to true, active bar will be drawn with the props calculated internally. If passed an object, active bar will be drawn, and the internally calculated props will be merged with the key value pairs of the passed object.
- # active_bar: Var[Union[bool, Dict[str, Any]]]
+ # active_bar: Var[Union[bool, Dict[str, Any]]] #noqa: ERA001
# Valid children components
_valid_children: List[str] = ["Cell", "LabelList", "ErrorBar"]
- # If set false, animation of bar will be disabled.
- is_animation_active: Var[bool]
-
- # Specifies when the animation should begin, the unit of this option is ms, default 0.
- animation_begin: Var[int]
-
- # Specifies the duration of animation, the unit of this option is ms, default 1500.
- animation_duration: Var[int]
-
- # The type of easing function, default 'ease'
- animation_easing: Var[LiteralAnimationEasing]
-
- # The customized event handler of animation start
- on_animation_start: EventHandler[lambda: []]
-
- # The customized event handler of animation end
- on_animation_end: EventHandler[lambda: []]
-
class Line(Cartesian):
"""A Line component in Recharts."""
@@ -405,32 +432,32 @@ class Line(Cartesian):
# The interpolation type of line. And customized interpolation function can be set to type. It's the same as type in Area.
type_: Var[LiteralAreaType]
- # The color of the line stroke.
- stroke: Var[Union[str, Color]] = Var.create_safe(Color("accent", 9))
+ # The color of the line stroke. Default: rx.color("accent", 9)
+ stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9))
- # The width of the line stroke.
+ # The width of the line stroke. Default: 1
stroke_width: Var[int]
- # The dot is shown when mouse enter a line chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally.
- dot: Var[Union[bool, Dict[str, Any]]] = Var.create_safe(
+ # The dot is shown when mouse enter a line chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 10), "fill": rx.color("accent", 4)}
+ dot: Var[Union[bool, Dict[str, Any]]] = LiteralVar.create(
{
"stroke": Color("accent", 10),
"fill": Color("accent", 4),
}
)
- # The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally.
- active_dot: Var[Union[bool, Dict[str, Any]]] = Var.create_safe(
+ # The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 2), "fill": rx.color("accent", 10)}
+ active_dot: Var[Union[bool, Dict[str, Any]]] = LiteralVar.create(
{
"stroke": Color("accent", 2),
"fill": Color("accent", 10),
}
)
- # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally.
+ # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
label: Var[bool]
- # Hides the line when true, useful when toggling visibility state via legend.
+ # Hides the line when true, useful when toggling visibility state via legend. Default: False
hide: Var[bool]
# Whether to connect a graph line across null points.
@@ -439,8 +466,11 @@ class Line(Cartesian):
# The unit of data. This option will be used in tooltip.
unit: Var[Union[str, int]]
- # The name of data displayed in the axis. This option will be used to represent an index in a scatter chart.
- name: Var[Union[str, int]]
+ # The coordinates of all the points in the line, usually calculated internally.
+ points: Var[List[Dict[str, Any]]]
+
+ # The pattern of dashes and gaps used to paint the line.
+ stroke_dasharray: Var[str]
# Valid children components
_valid_children: List[str] = ["LabelList", "ErrorBar"]
@@ -456,71 +486,68 @@ class Scatter(Recharts):
# The source data, in which each element is an object.
data: Var[List[Dict[str, Any]]]
- # The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye' | 'none'
+ # The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye' | 'none'. Default: "circle"
legend_type: Var[LiteralLegendType]
- # The id of x-axis which is corresponding to the data.
+ # The id of x-axis which is corresponding to the data. Default: 0
x_axis_id: Var[Union[str, int]]
- # The id of y-axis which is corresponding to the data.
+ # The id of y-axis which is corresponding to the data. Default: 0
y_axis_id: Var[Union[str, int]]
- # The id of z-axis which is corresponding to the data.
- z_axis_id: Var[str]
+ # The id of z-axis which is corresponding to the data. Default: 0
+ z_axis_id: Var[Union[str, int]]
- # If false set, line will not be drawn. If true set, line will be drawn which have the props calculated internally.
+ # If false set, line will not be drawn. If true set, line will be drawn which have the props calculated internally. Default: False
line: Var[bool]
- # If a string set, specified symbol will be used to show scatter item. 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye'
+ # If a string set, specified symbol will be used to show scatter item. 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye'. Default: "circle"
shape: Var[LiteralShape]
- # If 'joint' set, line will generated by just jointing all the points. If 'fitting' set, line will be generated by fitting algorithm. 'joint' | 'fitting'
+ # If 'joint' set, line will generated by just jointing all the points. If 'fitting' set, line will be generated by fitting algorithm. 'joint' | 'fitting'. Default: "joint"
line_type: Var[LiteralLineType]
- # The fill
- fill: Var[Union[str, Color]] = Var.create_safe(Color("accent", 9))
-
- # the name
- name: Var[Union[str, int]]
+ # The fill color of the scatter. Default: rx.color("accent", 9)
+ fill: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9))
# Valid children components.
_valid_children: List[str] = ["LabelList", "ErrorBar"]
- # If set false, animation of bar will be disabled.
+ # If set false, animation of bar will be disabled. Default: True in CSR, False in SSR
is_animation_active: Var[bool]
- # Specifies when the animation should begin, the unit of this option is ms, default 0.
+ # Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_begin: Var[int]
- # Specifies the duration of animation, the unit of this option is ms, default 1500.
+ # Specifies the duration of animation, the unit of this option is ms. Default: 1500
animation_duration: Var[int]
- # The type of easing function, default 'ease'
+ # The type of easing function. Default: "ease"
animation_easing: Var[LiteralAnimationEasing]
# The customized event handler of click on the component in this group
- on_click: EventHandler[lambda: []]
+ on_click: EventHandler[no_args_event_spec]
# The customized event handler of mousedown on the component in this group
- on_mouse_down: EventHandler[lambda: []]
+ on_mouse_down: EventHandler[no_args_event_spec]
# The customized event handler of mouseup on the component in this group
- on_mouse_up: EventHandler[lambda: []]
+ on_mouse_up: EventHandler[no_args_event_spec]
# The customized event handler of mousemove on the component in this group
- on_mouse_move: EventHandler[lambda: []]
+ on_mouse_move: EventHandler[no_args_event_spec]
# The customized event handler of mouseover on the component in this group
- on_mouse_over: EventHandler[lambda: []]
+ on_mouse_over: EventHandler[no_args_event_spec]
# The customized event handler of mouseout on the component in this group
- on_mouse_out: EventHandler[lambda: []]
+ on_mouse_out: EventHandler[no_args_event_spec]
# The customized event handler of mouseenter on the component in this group
- on_mouse_enter: EventHandler[lambda: []]
+ on_mouse_enter: EventHandler[no_args_event_spec]
# The customized event handler of mouseleave on the component in this group
- on_mouse_leave: EventHandler[lambda: []]
+ on_mouse_leave: EventHandler[no_args_event_spec]
class Funnel(Recharts):
@@ -533,62 +560,65 @@ class Funnel(Recharts):
# The source data, in which each element is an object.
data: Var[List[Dict[str, Any]]]
- # The key of a group of data which should be unique in an area chart.
+ # The key or getter of a group of data which should be unique in a FunnelChart.
data_key: Var[Union[str, int]]
- # The key or getter of a group of data which should be unique in a LineChart.
+ # The key of each sector's name. Default: "name"
name_key: Var[str]
- # The type of icon in legend. If set to 'none', no legend item will be rendered.
+ # The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "line"
legend_type: Var[LiteralLegendType]
- # If set false, animation of line will be disabled.
+ # If set false, animation of line will be disabled. Default: True
is_animation_active: Var[bool]
- # Specifies when the animation should begin, the unit of this option is ms.
+ # Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_begin: Var[int]
- # Specifies the duration of animation, the unit of this option is ms.
+ # Specifies the duration of animation, the unit of this option is ms. Default: 1500
animation_duration: Var[int]
- # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'
+ # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default "ease"
animation_easing: Var[LiteralAnimationEasing]
- # stroke color
- stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 3))
+ # Stroke color. Default: rx.color("gray", 3)
+ stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 3))
+
+ # The coordinates of all the trapezoids in the funnel, usually calculated internally.
+ trapezoids: Var[List[Dict[str, Any]]]
# Valid children components
_valid_children: List[str] = ["LabelList", "Cell"]
# The customized event handler of animation start
- on_animation_start: EventHandler[lambda: []]
+ on_animation_start: EventHandler[no_args_event_spec]
# The customized event handler of animation end
- on_animation_end: EventHandler[lambda: []]
+ on_animation_end: EventHandler[no_args_event_spec]
# The customized event handler of click on the component in this group
- on_click: EventHandler[lambda: []]
+ on_click: EventHandler[no_args_event_spec]
# The customized event handler of mousedown on the component in this group
- on_mouse_down: EventHandler[lambda: []]
+ on_mouse_down: EventHandler[no_args_event_spec]
# The customized event handler of mouseup on the component in this group
- on_mouse_up: EventHandler[lambda: []]
+ on_mouse_up: EventHandler[no_args_event_spec]
# The customized event handler of mousemove on the component in this group
- on_mouse_move: EventHandler[lambda: []]
+ on_mouse_move: EventHandler[no_args_event_spec]
# The customized event handler of mouseover on the component in this group
- on_mouse_over: EventHandler[lambda: []]
+ on_mouse_over: EventHandler[no_args_event_spec]
# The customized event handler of mouseout on the component in this group
- on_mouse_out: EventHandler[lambda: []]
+ on_mouse_out: EventHandler[no_args_event_spec]
# The customized event handler of mouseenter on the component in this group
- on_mouse_enter: EventHandler[lambda: []]
+ on_mouse_enter: EventHandler[no_args_event_spec]
# The customized event handler of mouseleave on the component in this group
- on_mouse_leave: EventHandler[lambda: []]
+ on_mouse_leave: EventHandler[no_args_event_spec]
class ErrorBar(Recharts):
@@ -598,38 +628,38 @@ class ErrorBar(Recharts):
alias = "RechartsErrorBar"
- # The direction of error bar. 'x' | 'y' | 'both'
+ # Only used for ScatterChart with error bars in two directions. Only accepts a value of "x" or "y" and makes the error bars lie in that direction.
direction: Var[LiteralDirection]
# The key of a group of data which should be unique in an area chart.
data_key: Var[Union[str, int]]
- # The width of the error bar ends.
+ # The width of the error bar ends. Default: 5
width: Var[int]
- # The stroke color of error bar.
- stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 8))
+ # The stroke color of error bar. Default: rx.color("gray", 8)
+ stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 8))
- # The stroke width of error bar.
- stroke_width: Var[int]
+ # The stroke width of error bar. Default: 1.5
+ stroke_width: Var[Union[int, float]]
class Reference(Recharts):
"""A base class for reference components in Reference."""
- # The id of x-axis which is corresponding to the data.
+ # The id of x-axis which is corresponding to the data. Default: 0
x_axis_id: Var[Union[str, int]]
- # The id of y-axis which is corresponding to the data.
+ # The id of y-axis which is corresponding to the data. Default: 0
y_axis_id: Var[Union[str, int]]
- # Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas.
+ # Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard"
if_overflow: Var[LiteralIfOverflow]
# If set a string or a number, default label will be drawn, and the option is content.
label: Var[Union[str, int]]
- # If set true, the line will be rendered in front of bars in BarChart, etc.
+ # If set true, the line will be rendered in front of bars in BarChart, etc. Default: False
is_front: Var[bool]
@@ -649,7 +679,7 @@ class ReferenceLine(Reference):
# The color of the reference line.
stroke: Var[Union[str, Color]]
- # The width of the stroke.
+ # The width of the stroke. Default: 1
stroke_width: Var[Union[str, int]]
# Valid children components
@@ -685,28 +715,28 @@ class ReferenceDot(Reference):
_valid_children: List[str] = ["Label"]
# The customized event handler of click on the component in this chart
- on_click: EventHandler[lambda: []]
+ on_click: EventHandler[no_args_event_spec]
# The customized event handler of mousedown on the component in this chart
- on_mouse_down: EventHandler[lambda: []]
+ on_mouse_down: EventHandler[no_args_event_spec]
# The customized event handler of mouseup on the component in this chart
- on_mouse_up: EventHandler[lambda: []]
+ on_mouse_up: EventHandler[no_args_event_spec]
# The customized event handler of mouseover on the component in this chart
- on_mouse_over: EventHandler[lambda: []]
+ on_mouse_over: EventHandler[no_args_event_spec]
# The customized event handler of mouseout on the component in this chart
- on_mouse_out: EventHandler[lambda: []]
+ on_mouse_out: EventHandler[no_args_event_spec]
# The customized event handler of mouseenter on the component in this chart
- on_mouse_enter: EventHandler[lambda: []]
+ on_mouse_enter: EventHandler[no_args_event_spec]
# The customized event handler of mousemove on the component in this chart
- on_mouse_move: EventHandler[lambda: []]
+ on_mouse_move: EventHandler[no_args_event_spec]
# The customized event handler of mouseleave on the component in this chart
- on_mouse_leave: EventHandler[lambda: []]
+ on_mouse_leave: EventHandler[no_args_event_spec]
class ReferenceArea(Recharts):
@@ -743,10 +773,10 @@ class ReferenceArea(Recharts):
# A boundary value of the area. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys. If one of y1 or y2 is invalidate, the area will cover along y-axis.
y2: Var[Union[str, int]]
- # Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas.
+ # Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard"
if_overflow: Var[LiteralIfOverflow]
- # If set true, the line will be rendered in front of bars in BarChart, etc.
+ # If set true, the line will be rendered in front of bars in BarChart, etc. Default: False
is_front: Var[bool]
# Valid children components
@@ -756,16 +786,16 @@ class ReferenceArea(Recharts):
class Grid(Recharts):
"""A base class for grid components in Recharts."""
- # The x-coordinate of grid.
+ # The x-coordinate of grid. Default: 0
x: Var[int]
- # The y-coordinate of grid.
+ # The y-coordinate of grid. Default: 0
y: Var[int]
- # The width of grid.
+ # The width of grid. Default: 0
width: Var[int]
- # The height of grid.
+ # The height of grid. Default: 0
height: Var[int]
@@ -776,29 +806,29 @@ class CartesianGrid(Grid):
alias = "RechartsCartesianGrid"
- # The horizontal line configuration.
+ # The horizontal line configuration. Default: True
horizontal: Var[bool]
- # The vertical line configuration.
+ # The vertical line configuration. Default: True
vertical: Var[bool]
- # The x-coordinates in pixel values of all vertical lines.
+ # The x-coordinates in pixel values of all vertical lines. Default: []
vertical_points: Var[List[Union[str, int]]]
- # The x-coordinates in pixel values of all vertical lines.
+ # The x-coordinates in pixel values of all vertical lines. Default: []
horizontal_points: Var[List[Union[str, int]]]
# The background of grid.
fill: Var[Union[str, Color]]
- # The opacity of the background used to fill the space between grid lines
+ # The opacity of the background used to fill the space between grid lines.
fill_opacity: Var[float]
- # The pattern of dashes and gaps used to paint the lines of the grid
+ # The pattern of dashes and gaps used to paint the lines of the grid.
stroke_dasharray: Var[str]
- # the stroke color of grid
- stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 7))
+ # the stroke color of grid. Default: rx.color("gray", 7)
+ stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 7))
class CartesianAxis(Grid):
@@ -808,28 +838,31 @@ class CartesianAxis(Grid):
alias = "RechartsCartesianAxis"
- # The orientation of axis 'top' | 'bottom' | 'left' | 'right'
+ # The orientation of axis 'top' | 'bottom' | 'left' | 'right'. Default: "bottom"
orientation: Var[LiteralOrientationTopBottomLeftRight]
- # If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line.
+ # The box of viewing area. Default: {"x": 0, "y": 0, "width": 0, "height": 0}
+ view_box: Var[Dict[str, Any]]
+
+ # If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. Default: True
axis_line: Var[bool]
- # If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines.
+ # If set false, no ticks will be drawn.
+ tick: Var[bool]
+
+ # If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. Default: True
tick_line: Var[bool]
- # The length of tick line.
+ # The length of tick line. Default: 6
tick_size: Var[int]
- # If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically.
+ # If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd"
interval: Var[LiteralInterval]
- # If set false, no ticks will be drawn.
- ticks: Var[bool]
-
# If set a string or a number, default label will be drawn, and the option is content.
- label: Var[str]
+ label: Var[Union[str, int]]
- # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside.
+ # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False
mirror: Var[bool]
# The margin between tick line and tick.
diff --git a/reflex/components/recharts/cartesian.pyi b/reflex/components/recharts/cartesian.pyi
index 498ed7444..64921ec55 100644
--- a/reflex/components/recharts/cartesian.pyi
+++ b/reflex/components/recharts/cartesian.pyi
@@ -3,16 +3,14 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Union, overload
from reflex.constants.colors import Color
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
-from .recharts import (
- Recharts,
-)
+from .recharts import Recharts
class Axis(Recharts):
@overload
@@ -20,125 +18,123 @@ class Axis(Recharts):
def create( # type: ignore
cls,
*children,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
hide: Optional[Union[Var[bool], bool]] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
type_: Optional[
- Union[Var[Literal["number", "category"]], Literal["number", "category"]]
+ Union[Literal["category", "number"], Var[Literal["category", "number"]]]
+ ] = None,
+ interval: Optional[
+ Union[
+ Literal[
+ "equidistantPreserveStart",
+ "preserveEnd",
+ "preserveStart",
+ "preserveStartEnd",
+ ],
+ Var[
+ Union[
+ Literal[
+ "equidistantPreserveStart",
+ "preserveEnd",
+ "preserveStart",
+ "preserveStartEnd",
+ ],
+ int,
+ ]
+ ],
+ int,
+ ]
] = None,
allow_decimals: Optional[Union[Var[bool], bool]] = None,
allow_data_overflow: Optional[Union[Var[bool], bool]] = None,
allow_duplicated_category: Optional[Union[Var[bool], bool]] = None,
+ domain: Optional[Union[List, Var[List]]] = None,
axis_line: Optional[Union[Var[bool], bool]] = None,
mirror: Optional[Union[Var[bool], bool]] = None,
reversed: Optional[Union[Var[bool], bool]] = None,
label: Optional[
- Union[Var[Union[Dict[str, Any], int, str]], str, int, Dict[str, Any]]
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], int, str]], int, str]
] = None,
scale: Optional[
Union[
+ Literal[
+ "auto",
+ "band",
+ "identity",
+ "linear",
+ "log",
+ "ordinal",
+ "point",
+ "pow",
+ "quantile",
+ "quantize",
+ "sequential",
+ "sqrt",
+ "threshold",
+ "time",
+ "utc",
+ ],
Var[
Literal[
"auto",
- "linear",
- "pow",
- "sqrt",
- "log",
- "identity",
- "time",
"band",
- "point",
+ "identity",
+ "linear",
+ "log",
"ordinal",
+ "point",
+ "pow",
"quantile",
"quantize",
- "utc",
"sequential",
+ "sqrt",
"threshold",
+ "time",
+ "utc",
]
],
- Literal[
- "auto",
- "linear",
- "pow",
- "sqrt",
- "log",
- "identity",
- "time",
- "band",
- "point",
- "ordinal",
- "quantile",
- "quantize",
- "utc",
- "sequential",
- "threshold",
- ],
]
] = None,
- unit: Optional[Union[Var[Union[int, str]], str, int]] = None,
- name: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ unit: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ name: Optional[Union[Var[Union[int, str]], int, str]] = None,
ticks: Optional[
- Union[Var[List[Union[int, str]]], List[Union[int, str]]]
+ Union[List[Union[int, str]], Var[List[Union[int, str]]]]
] = None,
tick: Optional[Union[Var[bool], bool]] = None,
tick_count: Optional[Union[Var[int], int]] = None,
tick_line: Optional[Union[Var[bool], bool]] = None,
tick_size: Optional[Union[Var[int], int]] = None,
min_tick_gap: Optional[Union[Var[int], int]] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- text_anchor: Optional[Union[Var[str], str]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ text_anchor: Optional[
+ Union[
+ Literal["end", "middle", "start"],
+ Var[Literal["end", "middle", "start"]],
+ ]
+ ] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Axis":
"""Create the component.
@@ -146,28 +142,37 @@ class Axis(Recharts):
Args:
*children: The children of the component.
data_key: The key of data displayed in the axis.
- hide: If set true, the axis do not display in the chart.
+ hide: If set true, the axis do not display in the chart. Default: False
width: The width of axis which is usually calculated internally.
- height: The height of axis, which can be setted by user.
+ height: The height of axis, which can be set by user.
type_: The type of axis 'number' | 'category'
- allow_decimals: Allow the ticks of XAxis to be decimals or not.
- allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain.
- allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category".
- axis_line: If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line.
- mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside.
- reversed: Reverse the ticks or not.
+ interval: If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd"
+ allow_decimals: Allow the ticks of Axis to be decimals or not. Default: True
+ allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. Default: False
+ allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True
+ domain: The range of the axis. Work best in conjunction with allow_data_overflow. Default: [0, "auto"]
+ axis_line: If set false, no axis line will be drawn. Default: True
+ mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False
+ reversed: Reverse the ticks or not. Default: False
label: The label of axis, which appears next to the axis.
- scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold' | Function
+ scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto"
unit: The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart.
name: The name of data displayed in the axis. This option will be used to represent an index in a scatter chart.
ticks: Set the values of axis ticks manually.
tick: If set false, no ticks will be drawn.
- tick_count: The count of axis ticks.
- tick_line: If set false, no axis tick lines will be drawn.
- tick_size: The length of tick line.
- min_tick_gap: The minimum gap between two adjacent labels
- stroke: The stroke color of axis
- text_anchor: The text anchor of axis
+ tick_count: The count of axis ticks. Not used if 'type' is 'category'. Default: 5
+ tick_line: If set false, no axis tick lines will be drawn. Default: True
+ tick_size: The length of tick line. Default: 6
+ min_tick_gap: The minimum gap between two adjacent labels. Default: 5
+ stroke: The stroke color of axis. Default: rx.color("gray", 9)
+ text_anchor: The text anchor of axis. Default: "middle"
+ on_click: The customized event handler of click on the ticks of this axis
+ on_mouse_down: The customized event handler of mousedown on the ticks of this axis
+ on_mouse_up: The customized event handler of mouseup on the ticks of this axis
+ on_mouse_move: The customized event handler of mousemove on the ticks of this axis
+ on_mouse_out: The customized event handler of mouseout on the ticks of this axis
+ on_mouse_enter: The customized event handler of mouseenter on the ticks of this axis
+ on_mouse_leave: The customized event handler of mouseleave on the ticks of this axis
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -188,163 +193,172 @@ class XAxis(Axis):
cls,
*children,
orientation: Optional[
- Union[Var[Literal["top", "bottom"]], Literal["top", "bottom"]]
+ Union[Literal["bottom", "top"], Var[Literal["bottom", "top"]]]
] = None,
- x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
include_hidden: Optional[Union[Var[bool], bool]] = None,
- domain: Optional[Union[Var[List], List]] = None,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ angle: Optional[Union[Var[int], int]] = None,
+ padding: Optional[Union[Dict[str, int], Var[Dict[str, int]]]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
hide: Optional[Union[Var[bool], bool]] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
type_: Optional[
- Union[Var[Literal["number", "category"]], Literal["number", "category"]]
+ Union[Literal["category", "number"], Var[Literal["category", "number"]]]
+ ] = None,
+ interval: Optional[
+ Union[
+ Literal[
+ "equidistantPreserveStart",
+ "preserveEnd",
+ "preserveStart",
+ "preserveStartEnd",
+ ],
+ Var[
+ Union[
+ Literal[
+ "equidistantPreserveStart",
+ "preserveEnd",
+ "preserveStart",
+ "preserveStartEnd",
+ ],
+ int,
+ ]
+ ],
+ int,
+ ]
] = None,
allow_decimals: Optional[Union[Var[bool], bool]] = None,
allow_data_overflow: Optional[Union[Var[bool], bool]] = None,
allow_duplicated_category: Optional[Union[Var[bool], bool]] = None,
+ domain: Optional[Union[List, Var[List]]] = None,
axis_line: Optional[Union[Var[bool], bool]] = None,
mirror: Optional[Union[Var[bool], bool]] = None,
reversed: Optional[Union[Var[bool], bool]] = None,
label: Optional[
- Union[Var[Union[Dict[str, Any], int, str]], str, int, Dict[str, Any]]
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], int, str]], int, str]
] = None,
scale: Optional[
Union[
+ Literal[
+ "auto",
+ "band",
+ "identity",
+ "linear",
+ "log",
+ "ordinal",
+ "point",
+ "pow",
+ "quantile",
+ "quantize",
+ "sequential",
+ "sqrt",
+ "threshold",
+ "time",
+ "utc",
+ ],
Var[
Literal[
"auto",
- "linear",
- "pow",
- "sqrt",
- "log",
- "identity",
- "time",
"band",
- "point",
+ "identity",
+ "linear",
+ "log",
"ordinal",
+ "point",
+ "pow",
"quantile",
"quantize",
- "utc",
"sequential",
+ "sqrt",
"threshold",
+ "time",
+ "utc",
]
],
- Literal[
- "auto",
- "linear",
- "pow",
- "sqrt",
- "log",
- "identity",
- "time",
- "band",
- "point",
- "ordinal",
- "quantile",
- "quantize",
- "utc",
- "sequential",
- "threshold",
- ],
]
] = None,
- unit: Optional[Union[Var[Union[int, str]], str, int]] = None,
- name: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ unit: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ name: Optional[Union[Var[Union[int, str]], int, str]] = None,
ticks: Optional[
- Union[Var[List[Union[int, str]]], List[Union[int, str]]]
+ Union[List[Union[int, str]], Var[List[Union[int, str]]]]
] = None,
tick: Optional[Union[Var[bool], bool]] = None,
tick_count: Optional[Union[Var[int], int]] = None,
tick_line: Optional[Union[Var[bool], bool]] = None,
tick_size: Optional[Union[Var[int], int]] = None,
min_tick_gap: Optional[Union[Var[int], int]] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- text_anchor: Optional[Union[Var[str], str]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ text_anchor: Optional[
+ Union[
+ Literal["end", "middle", "start"],
+ Var[Literal["end", "middle", "start"]],
+ ]
+ ] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "XAxis":
"""Create the component.
Args:
*children: The children of the component.
- orientation: The orientation of axis 'top' | 'bottom'
- x_axis_id: The id of x-axis which is corresponding to the data.
- include_hidden: Ensures that all datapoints within a chart contribute to its domain calculation, even when they are hidden
- domain: The range of the axis. Work best in conjuction with allow_data_overflow.
+ orientation: The orientation of axis 'top' | 'bottom'. Default: "bottom"
+ x_axis_id: The id of x-axis which is corresponding to the data. Default: 0
+ include_hidden: Ensures that all datapoints within a chart contribute to its domain calculation, even when they are hidden. Default: False
+ angle: The angle of axis ticks. Default: 0
+ padding: Specify the padding of x-axis. Default: {"left": 0, "right": 0}
data_key: The key of data displayed in the axis.
- hide: If set true, the axis do not display in the chart.
+ hide: If set true, the axis do not display in the chart. Default: False
width: The width of axis which is usually calculated internally.
- height: The height of axis, which can be setted by user.
+ height: The height of axis, which can be set by user.
type_: The type of axis 'number' | 'category'
- allow_decimals: Allow the ticks of XAxis to be decimals or not.
- allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain.
- allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category".
- axis_line: If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line.
- mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside.
- reversed: Reverse the ticks or not.
+ interval: If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd"
+ allow_decimals: Allow the ticks of Axis to be decimals or not. Default: True
+ allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. Default: False
+ allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True
+ domain: The range of the axis. Work best in conjunction with allow_data_overflow. Default: [0, "auto"]
+ axis_line: If set false, no axis line will be drawn. Default: True
+ mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False
+ reversed: Reverse the ticks or not. Default: False
label: The label of axis, which appears next to the axis.
- scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold' | Function
+ scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto"
unit: The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart.
name: The name of data displayed in the axis. This option will be used to represent an index in a scatter chart.
ticks: Set the values of axis ticks manually.
tick: If set false, no ticks will be drawn.
- tick_count: The count of axis ticks.
- tick_line: If set false, no axis tick lines will be drawn.
- tick_size: The length of tick line.
- min_tick_gap: The minimum gap between two adjacent labels
- stroke: The stroke color of axis
- text_anchor: The text anchor of axis
+ tick_count: The count of axis ticks. Not used if 'type' is 'category'. Default: 5
+ tick_line: If set false, no axis tick lines will be drawn. Default: True
+ tick_size: The length of tick line. Default: 6
+ min_tick_gap: The minimum gap between two adjacent labels. Default: 5
+ stroke: The stroke color of axis. Default: rx.color("gray", 9)
+ text_anchor: The text anchor of axis. Default: "middle"
+ on_click: The customized event handler of click on the ticks of this axis
+ on_mouse_down: The customized event handler of mousedown on the ticks of this axis
+ on_mouse_up: The customized event handler of mouseup on the ticks of this axis
+ on_mouse_move: The customized event handler of mousemove on the ticks of this axis
+ on_mouse_out: The customized event handler of mouseout on the ticks of this axis
+ on_mouse_enter: The customized event handler of mouseenter on the ticks of this axis
+ on_mouse_leave: The customized event handler of mouseleave on the ticks of this axis
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -365,161 +379,168 @@ class YAxis(Axis):
cls,
*children,
orientation: Optional[
- Union[Var[Literal["left", "right"]], Literal["left", "right"]]
+ Union[Literal["left", "right"], Var[Literal["left", "right"]]]
] = None,
- y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- domain: Optional[Union[Var[List], List]] = None,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ padding: Optional[Union[Dict[str, int], Var[Dict[str, int]]]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
hide: Optional[Union[Var[bool], bool]] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
type_: Optional[
- Union[Var[Literal["number", "category"]], Literal["number", "category"]]
+ Union[Literal["category", "number"], Var[Literal["category", "number"]]]
+ ] = None,
+ interval: Optional[
+ Union[
+ Literal[
+ "equidistantPreserveStart",
+ "preserveEnd",
+ "preserveStart",
+ "preserveStartEnd",
+ ],
+ Var[
+ Union[
+ Literal[
+ "equidistantPreserveStart",
+ "preserveEnd",
+ "preserveStart",
+ "preserveStartEnd",
+ ],
+ int,
+ ]
+ ],
+ int,
+ ]
] = None,
allow_decimals: Optional[Union[Var[bool], bool]] = None,
allow_data_overflow: Optional[Union[Var[bool], bool]] = None,
allow_duplicated_category: Optional[Union[Var[bool], bool]] = None,
+ domain: Optional[Union[List, Var[List]]] = None,
axis_line: Optional[Union[Var[bool], bool]] = None,
mirror: Optional[Union[Var[bool], bool]] = None,
reversed: Optional[Union[Var[bool], bool]] = None,
label: Optional[
- Union[Var[Union[Dict[str, Any], int, str]], str, int, Dict[str, Any]]
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], int, str]], int, str]
] = None,
scale: Optional[
Union[
+ Literal[
+ "auto",
+ "band",
+ "identity",
+ "linear",
+ "log",
+ "ordinal",
+ "point",
+ "pow",
+ "quantile",
+ "quantize",
+ "sequential",
+ "sqrt",
+ "threshold",
+ "time",
+ "utc",
+ ],
Var[
Literal[
"auto",
- "linear",
- "pow",
- "sqrt",
- "log",
- "identity",
- "time",
"band",
- "point",
+ "identity",
+ "linear",
+ "log",
"ordinal",
+ "point",
+ "pow",
"quantile",
"quantize",
- "utc",
"sequential",
+ "sqrt",
"threshold",
+ "time",
+ "utc",
]
],
- Literal[
- "auto",
- "linear",
- "pow",
- "sqrt",
- "log",
- "identity",
- "time",
- "band",
- "point",
- "ordinal",
- "quantile",
- "quantize",
- "utc",
- "sequential",
- "threshold",
- ],
]
] = None,
- unit: Optional[Union[Var[Union[int, str]], str, int]] = None,
- name: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ unit: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ name: Optional[Union[Var[Union[int, str]], int, str]] = None,
ticks: Optional[
- Union[Var[List[Union[int, str]]], List[Union[int, str]]]
+ Union[List[Union[int, str]], Var[List[Union[int, str]]]]
] = None,
tick: Optional[Union[Var[bool], bool]] = None,
tick_count: Optional[Union[Var[int], int]] = None,
tick_line: Optional[Union[Var[bool], bool]] = None,
tick_size: Optional[Union[Var[int], int]] = None,
min_tick_gap: Optional[Union[Var[int], int]] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- text_anchor: Optional[Union[Var[str], str]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ text_anchor: Optional[
+ Union[
+ Literal["end", "middle", "start"],
+ Var[Literal["end", "middle", "start"]],
+ ]
+ ] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "YAxis":
"""Create the component.
Args:
*children: The children of the component.
- orientation: The orientation of axis 'left' | 'right'
- y_axis_id: The id of y-axis which is corresponding to the data.
- domain: The range of the axis. Work best in conjuction with allow_data_overflow.
+ orientation: The orientation of axis 'left' | 'right'. Default: "left"
+ y_axis_id: The id of y-axis which is corresponding to the data. Default: 0
+ padding: Specify the padding of y-axis. Default: {"top": 0, "bottom": 0}
data_key: The key of data displayed in the axis.
- hide: If set true, the axis do not display in the chart.
+ hide: If set true, the axis do not display in the chart. Default: False
width: The width of axis which is usually calculated internally.
- height: The height of axis, which can be setted by user.
+ height: The height of axis, which can be set by user.
type_: The type of axis 'number' | 'category'
- allow_decimals: Allow the ticks of XAxis to be decimals or not.
- allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain.
- allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category".
- axis_line: If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line.
- mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside.
- reversed: Reverse the ticks or not.
+ interval: If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd"
+ allow_decimals: Allow the ticks of Axis to be decimals or not. Default: True
+ allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. Default: False
+ allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True
+ domain: The range of the axis. Work best in conjunction with allow_data_overflow. Default: [0, "auto"]
+ axis_line: If set false, no axis line will be drawn. Default: True
+ mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False
+ reversed: Reverse the ticks or not. Default: False
label: The label of axis, which appears next to the axis.
- scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold' | Function
+ scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto"
unit: The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart.
name: The name of data displayed in the axis. This option will be used to represent an index in a scatter chart.
ticks: Set the values of axis ticks manually.
tick: If set false, no ticks will be drawn.
- tick_count: The count of axis ticks.
- tick_line: If set false, no axis tick lines will be drawn.
- tick_size: The length of tick line.
- min_tick_gap: The minimum gap between two adjacent labels
- stroke: The stroke color of axis
- text_anchor: The text anchor of axis
+ tick_count: The count of axis ticks. Not used if 'type' is 'category'. Default: 5
+ tick_line: If set false, no axis tick lines will be drawn. Default: True
+ tick_size: The length of tick line. Default: 6
+ min_tick_gap: The minimum gap between two adjacent labels. Default: 5
+ stroke: The stroke color of axis. Default: rx.color("gray", 9)
+ text_anchor: The text anchor of axis. Default: "middle"
+ on_click: The customized event handler of click on the ticks of this axis
+ on_mouse_down: The customized event handler of mousedown on the ticks of this axis
+ on_mouse_up: The customized event handler of mouseup on the ticks of this axis
+ on_mouse_move: The customized event handler of mousemove on the ticks of this axis
+ on_mouse_out: The customized event handler of mouseout on the ticks of this axis
+ on_mouse_enter: The customized event handler of mouseenter on the ticks of this axis
+ on_mouse_leave: The customized event handler of mouseleave on the ticks of this axis
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -539,48 +560,49 @@ class ZAxis(Recharts):
def create( # type: ignore
cls,
*children,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
- range: Optional[Union[Var[List[int]], List[int]]] = None,
- unit: Optional[Union[Var[Union[int, str]], str, int]] = None,
- name: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ z_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ range: Optional[Union[List[int], Var[List[int]]]] = None,
+ unit: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ name: Optional[Union[Var[Union[int, str]], int, str]] = None,
scale: Optional[
Union[
+ Literal[
+ "auto",
+ "band",
+ "identity",
+ "linear",
+ "log",
+ "ordinal",
+ "point",
+ "pow",
+ "quantile",
+ "quantize",
+ "sequential",
+ "sqrt",
+ "threshold",
+ "time",
+ "utc",
+ ],
Var[
Literal[
"auto",
- "linear",
- "pow",
- "sqrt",
- "log",
- "identity",
- "time",
"band",
- "point",
+ "identity",
+ "linear",
+ "log",
"ordinal",
+ "point",
+ "pow",
"quantile",
"quantize",
- "utc",
"sequential",
+ "sqrt",
"threshold",
+ "time",
+ "utc",
]
],
- Literal[
- "auto",
- "linear",
- "pow",
- "sqrt",
- "log",
- "identity",
- "time",
- "band",
- "point",
- "ordinal",
- "quantile",
- "quantize",
- "utc",
- "sequential",
- "threshold",
- ],
]
] = None,
style: Optional[Style] = None,
@@ -588,52 +610,22 @@ class ZAxis(Recharts):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ZAxis":
"""Create the component.
@@ -641,10 +633,11 @@ class ZAxis(Recharts):
Args:
*children: The children of the component.
data_key: The key of data displayed in the axis.
- range: The range of axis.
+ z_axis_id: The unique id of z-axis. Default: 0
+ range: The range of axis. Default: [10, 10]
unit: The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart.
name: The name of data displayed in the axis. This option will be used to represent an index in a scatter chart.
- scale: If 'auto' set, the scale function is decided by the type of chart, and the props type.
+ scale: If 'auto' set, the scale function is decided by the type of chart, and the props type. Default: "auto"
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -665,14 +658,14 @@ class Brush(Recharts):
def create( # type: ignore
cls,
*children,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
x: Optional[Union[Var[int], int]] = None,
y: Optional[Union[Var[int], int]] = None,
width: Optional[Union[Var[int], int]] = None,
height: Optional[Union[Var[int], int]] = None,
- data: Optional[Union[Var[List[Any]], List[Any]]] = None,
+ data: Optional[Union[List[Any], Var[List[Any]]]] = None,
traveller_width: Optional[Union[Var[int], int]] = None,
gap: Optional[Union[Var[int], int]] = None,
start_index: Optional[Union[Var[int], int]] = None,
@@ -682,10 +675,8 @@ class Brush(Recharts):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_change: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Brush":
"""Create the component.
@@ -695,15 +686,15 @@ class Brush(Recharts):
stroke: The stroke color of brush
fill: The fill color of brush
data_key: The key of data displayed in the axis.
- x: The x-coordinate of brush.
- y: The y-coordinate of brush.
- width: The width of brush.
- height: The height of brush.
- data: The data domain of brush, [min, max].
- traveller_width: The width of each traveller.
- gap: The data with gap of refreshing chart. If the option is not set, the chart will be refreshed every time
- start_index: The default start index of brush. If the option is not set, the start index will be 0.
- end_index: The default end index of brush. If the option is not set, the end index will be 1.
+ x: The x-coordinate of brush. Default: 0
+ y: The y-coordinate of brush. Default: 0
+ width: The width of brush. Default: 0
+ height: The height of brush. Default: 40
+ data: The original data of a LineChart, a BarChart or an AreaChart.
+ traveller_width: The width of each traveller. Default: 5
+ gap: The data with gap of refreshing chart. If the option is not set, the chart will be refreshed every time. Default: 1
+ start_index: The default start index of brush. If the option is not set, the start index will be 0. Default: 0
+ end_index: The default end index of brush. If the option is not set, the end index will be calculated by the length of data.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -725,96 +716,79 @@ class Cartesian(Recharts):
*children,
layout: Optional[
Union[
- Var[Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
- x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
legend_type: Optional[
Union[
- Var[
- Literal[
- "line",
- "plainline",
- "square",
- "rect",
- "circle",
- "cross",
- "diamond",
- "star",
- "triangle",
- "wye",
- "none",
- ]
- ],
Literal[
- "line",
- "plainline",
- "square",
- "rect",
"circle",
"cross",
"diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
"star",
"triangle",
"wye",
- "none",
+ ],
+ Var[
+ Literal[
+ "circle",
+ "cross",
+ "diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
+ "star",
+ "triangle",
+ "wye",
+ ]
],
]
] = None,
+ is_animation_active: Optional[Union[Var[bool], bool]] = None,
+ animation_begin: Optional[Union[Var[int], int]] = None,
+ animation_duration: Optional[Union[Var[int], int]] = None,
+ animation_easing: Optional[
+ Union[
+ Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
+ Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
+ ]
+ ] = None,
+ unit: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ name: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_animation_end: Optional[EventType[[], BASE_STATE]] = None,
+ on_animation_start: Optional[EventType[[], BASE_STATE]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Cartesian":
"""Create the component.
@@ -823,9 +797,25 @@ class Cartesian(Recharts):
*children: The children of the component.
layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical'
data_key: The key of a group of data which should be unique in an area chart.
- x_axis_id: The id of x-axis which is corresponding to the data.
- y_axis_id: The id of y-axis which is corresponding to the data.
- legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none'optional
+ x_axis_id: The id of x-axis which is corresponding to the data. Default: 0
+ y_axis_id: The id of y-axis which is corresponding to the data. Default: 0
+ legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none' optional
+ is_animation_active: If set false, animation of bar will be disabled. Default: True
+ animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
+ animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
+ animation_easing: The type of easing function. Default: "ease"
+ unit: The unit of data. This option will be used in tooltip.
+ name: The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively.
+ on_animation_start: The customized event handler of animation start
+ on_animation_end: The customized event handler of animation end
+ on_click: The customized event handler of click on the component in this group
+ on_mouse_down: The customized event handler of mousedown on the component in this group
+ on_mouse_up: The customized event handler of mouseup on the component in this group
+ on_mouse_move: The customized event handler of mousemove on the component in this group
+ on_mouse_over: The customized event handler of mouseover on the component in this group
+ on_mouse_out: The customized event handler of mouseout on the component in this group
+ on_mouse_enter: The customized event handler of mouseenter on the component in this group
+ on_mouse_leave: The customized event handler of mouseleave on the component in this group
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -845,172 +835,175 @@ class Area(Cartesian):
def create( # type: ignore
cls,
*children,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
stroke_width: Optional[Union[Var[int], int]] = None,
- fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
type_: Optional[
Union[
+ Literal[
+ "basis",
+ "basisClosed",
+ "basisOpen",
+ "bump",
+ "bumpX",
+ "bumpY",
+ "linear",
+ "linearClosed",
+ "monotone",
+ "monotoneX",
+ "monotoneY",
+ "natural",
+ "step",
+ "stepAfter",
+ "stepBefore",
+ ],
Var[
Literal[
"basis",
"basisClosed",
"basisOpen",
+ "bump",
"bumpX",
"bumpY",
- "bump",
"linear",
"linearClosed",
- "natural",
+ "monotone",
"monotoneX",
"monotoneY",
- "monotone",
+ "natural",
"step",
- "stepBefore",
"stepAfter",
+ "stepBefore",
]
],
- Literal[
- "basis",
- "basisClosed",
- "basisOpen",
- "bumpX",
- "bumpY",
- "bump",
- "linear",
- "linearClosed",
- "natural",
- "monotoneX",
- "monotoneY",
- "monotone",
- "step",
- "stepBefore",
- "stepAfter",
- ],
]
] = None,
dot: Optional[
- Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]]
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool]
] = None,
active_dot: Optional[
- Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]]
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool]
] = None,
label: Optional[Union[Var[bool], bool]] = None,
- stack_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- unit: Optional[Union[Var[Union[int, str]], str, int]] = None,
- name: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ base_line: Optional[
+ Union[List[Dict[str, Any]], Var[Union[List[Dict[str, Any]], str]], str]
+ ] = None,
+ points: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ stack_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ connect_nulls: Optional[Union[Var[bool], bool]] = None,
layout: Optional[
Union[
- Var[Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
- x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
legend_type: Optional[
Union[
- Var[
- Literal[
- "line",
- "plainline",
- "square",
- "rect",
- "circle",
- "cross",
- "diamond",
- "star",
- "triangle",
- "wye",
- "none",
- ]
- ],
Literal[
- "line",
- "plainline",
- "square",
- "rect",
"circle",
"cross",
"diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
"star",
"triangle",
"wye",
- "none",
+ ],
+ Var[
+ Literal[
+ "circle",
+ "cross",
+ "diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
+ "star",
+ "triangle",
+ "wye",
+ ]
],
]
] = None,
+ is_animation_active: Optional[Union[Var[bool], bool]] = None,
+ animation_begin: Optional[Union[Var[int], int]] = None,
+ animation_duration: Optional[Union[Var[int], int]] = None,
+ animation_easing: Optional[
+ Union[
+ Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
+ Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
+ ]
+ ] = None,
+ unit: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ name: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_animation_end: Optional[EventType[[], BASE_STATE]] = None,
+ on_animation_start: Optional[EventType[[], BASE_STATE]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Area":
"""Create the component.
Args:
*children: The children of the component.
- stroke: The color of the line stroke.
- stroke_width: The width of the line stroke.
- fill: The color of the area fill.
- type_: The interpolation type of area. And customized interpolation function can be set to type. 'basis' | 'basisClosed' | 'basisOpen' | 'bumpX' | 'bumpY' | 'bump' | 'linear' | 'linearClosed' | 'natural' | 'monotoneX' | 'monotoneY' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter' |
- dot: If false set, dots will not be drawn. If true set, dots will be drawn which have the props calculated internally.
- active_dot: The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally.
- label: If set false, labels will not be drawn. If set true, labels will be drawn which have the props calculated internally.
+ stroke: The color of the line stroke. Default: rx.color("accent", 9)
+ stroke_width: The width of the line stroke. Default: 1
+ fill: The color of the area fill. Default: rx.color("accent", 5)
+ type_: The interpolation type of area. And customized interpolation function can be set to type. 'basis' | 'basisClosed' | 'basisOpen' | 'bumpX' | 'bumpY' | 'bump' | 'linear' | 'linearClosed' | 'natural' | 'monotoneX' | 'monotoneY' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter'. Default: "monotone"
+ dot: If false set, dots will not be drawn. If true set, dots will be drawn which have the props calculated internally. Default: False
+ active_dot: The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {stroke: rx.color("accent", 2), fill: rx.color("accent", 10)}
+ label: If set false, labels will not be drawn. If set true, labels will be drawn which have the props calculated internally. Default: False
+ base_line: The value which can describle the line, usually calculated internally.
+ points: The coordinates of all the points in the area, usually calculated internally.
stack_id: The stack id of area, when two areas have the same value axis and same stack_id, then the two areas are stacked in order.
- unit: The unit of data. This option will be used in tooltip.
- name: The name of data. This option will be used in tooltip and legend to represent a bar. If no value was set to this option, the value of dataKey will be used alternatively.
+ connect_nulls: Whether to connect a graph area across null points. Default: False
layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical'
data_key: The key of a group of data which should be unique in an area chart.
- x_axis_id: The id of x-axis which is corresponding to the data.
- y_axis_id: The id of y-axis which is corresponding to the data.
- legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none'optional
+ x_axis_id: The id of x-axis which is corresponding to the data. Default: 0
+ y_axis_id: The id of y-axis which is corresponding to the data. Default: 0
+ legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none' optional
+ is_animation_active: If set false, animation of bar will be disabled. Default: True
+ animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
+ animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
+ animation_easing: The type of easing function. Default: "ease"
+ unit: The unit of data. This option will be used in tooltip.
+ name: The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively.
+ on_animation_start: The customized event handler of animation start
+ on_animation_end: The customized event handler of animation end
+ on_click: The customized event handler of click on the component in this group
+ on_mouse_down: The customized event handler of mousedown on the component in this group
+ on_mouse_up: The customized event handler of mouseup on the component in this group
+ on_mouse_move: The customized event handler of mousemove on the component in this group
+ on_mouse_over: The customized event handler of mouseover on the component in this group
+ on_mouse_out: The customized event handler of mouseout on the component in this group
+ on_mouse_enter: The customized event handler of mouseenter on the component in this group
+ on_mouse_leave: The customized event handler of mouseleave on the component in this group
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -1030,65 +1023,66 @@ class Bar(Cartesian):
def create( # type: ignore
cls,
*children,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
stroke_width: Optional[Union[Var[int], int]] = None,
- fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
background: Optional[Union[Var[bool], bool]] = None,
label: Optional[Union[Var[bool], bool]] = None,
stack_id: Optional[Union[Var[str], str]] = None,
- unit: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ unit: Optional[Union[Var[Union[int, str]], int, str]] = None,
min_point_size: Optional[Union[Var[int], int]] = None,
- name: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ name: Optional[Union[Var[Union[int, str]], int, str]] = None,
bar_size: Optional[Union[Var[int], int]] = None,
max_bar_size: Optional[Union[Var[int], int]] = None,
+ radius: Optional[Union[List[int], Var[Union[List[int], int]], int]] = None,
+ layout: Optional[
+ Union[
+ Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
+ ]
+ ] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ legend_type: Optional[
+ Union[
+ Literal[
+ "circle",
+ "cross",
+ "diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
+ "star",
+ "triangle",
+ "wye",
+ ],
+ Var[
+ Literal[
+ "circle",
+ "cross",
+ "diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
+ "star",
+ "triangle",
+ "wye",
+ ]
+ ],
+ ]
+ ] = None,
is_animation_active: Optional[Union[Var[bool], bool]] = None,
animation_begin: Optional[Union[Var[int], int]] = None,
animation_duration: Optional[Union[Var[int], int]] = None,
animation_easing: Optional[
Union[
- Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]],
- Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"],
- ]
- ] = None,
- layout: Optional[
- Union[
- Var[Literal["horizontal", "vertical"]],
- Literal["horizontal", "vertical"],
- ]
- ] = None,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
- x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- legend_type: Optional[
- Union[
- Var[
- Literal[
- "line",
- "plainline",
- "square",
- "rect",
- "circle",
- "cross",
- "diamond",
- "star",
- "triangle",
- "wye",
- "none",
- ]
- ],
- Literal[
- "line",
- "plainline",
- "square",
- "rect",
- "circle",
- "cross",
- "diamond",
- "star",
- "triangle",
- "wye",
- "none",
- ],
+ Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
+ Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
]
] = None,
style: Optional[Style] = None,
@@ -1096,58 +1090,24 @@ class Bar(Cartesian):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_animation_end: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_animation_start: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_animation_end: Optional[EventType[[], BASE_STATE]] = None,
+ on_animation_start: Optional[EventType[[], BASE_STATE]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Bar":
"""Create the component.
@@ -1156,24 +1116,35 @@ class Bar(Cartesian):
*children: The children of the component.
stroke: The color of the line stroke.
stroke_width: The width of the line stroke.
- fill: The width of the line stroke.
- background: If false set, background of bars will not be drawn. If true set, background of bars will be drawn which have the props calculated internally.
- label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally.
+ fill: The width of the line stroke. Default: Color("accent", 9)
+ background: If false set, background of bars will not be drawn. If true set, background of bars will be drawn which have the props calculated internally. Default: False
+ label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
stack_id: The stack id of bar, when two bars have the same value axis and same stack_id, then the two bars are stacked in order.
unit: The unit of data. This option will be used in tooltip.
min_point_size: The minimal height of a bar in a horizontal BarChart, or the minimal width of a bar in a vertical BarChart. By default, 0 values are not shown. To visualize a 0 (or close to zero) point, set the minimal point size to a pixel value like 3. In stacked bar charts, minPointSize might not be respected for tightly packed values. So we strongly recommend not using this prop in stacked BarCharts.
- name: The name of data. This option will be used in tooltip and legend to represent a bar. If no value was set to this option, the value of dataKey will be used alternatively.
+ name: The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively.
bar_size: Size of the bar (if one bar_size is set then a bar_size must be set for all bars)
max_bar_size: Max size of the bar
- is_animation_active: If set false, animation of bar will be disabled.
- animation_begin: Specifies when the animation should begin, the unit of this option is ms, default 0.
- animation_duration: Specifies the duration of animation, the unit of this option is ms, default 1500.
- animation_easing: The type of easing function, default 'ease'
+ radius: If set a value, the option is the radius of all the rounded corners. If set a array, the option are in turn the radiuses of top-left corner, top-right corner, bottom-right corner, bottom-left corner. Default: 0
layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical'
data_key: The key of a group of data which should be unique in an area chart.
- x_axis_id: The id of x-axis which is corresponding to the data.
- y_axis_id: The id of y-axis which is corresponding to the data.
- legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none'optional
+ x_axis_id: The id of x-axis which is corresponding to the data. Default: 0
+ y_axis_id: The id of y-axis which is corresponding to the data. Default: 0
+ legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none' optional
+ is_animation_active: If set false, animation of bar will be disabled. Default: True
+ animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
+ animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
+ animation_easing: The type of easing function. Default: "ease"
+ on_animation_start: The customized event handler of animation start
+ on_animation_end: The customized event handler of animation end
+ on_click: The customized event handler of click on the component in this group
+ on_mouse_down: The customized event handler of mousedown on the component in this group
+ on_mouse_up: The customized event handler of mouseup on the component in this group
+ on_mouse_move: The customized event handler of mousemove on the component in this group
+ on_mouse_over: The customized event handler of mouseover on the component in this group
+ on_mouse_out: The customized event handler of mouseout on the component in this group
+ on_mouse_enter: The customized event handler of mouseenter on the component in this group
+ on_mouse_leave: The customized event handler of mouseleave on the component in this group
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -1195,149 +1166,132 @@ class Line(Cartesian):
*children,
type_: Optional[
Union[
+ Literal[
+ "basis",
+ "basisClosed",
+ "basisOpen",
+ "bump",
+ "bumpX",
+ "bumpY",
+ "linear",
+ "linearClosed",
+ "monotone",
+ "monotoneX",
+ "monotoneY",
+ "natural",
+ "step",
+ "stepAfter",
+ "stepBefore",
+ ],
Var[
Literal[
"basis",
"basisClosed",
"basisOpen",
+ "bump",
"bumpX",
"bumpY",
- "bump",
"linear",
"linearClosed",
- "natural",
+ "monotone",
"monotoneX",
"monotoneY",
- "monotone",
+ "natural",
"step",
- "stepBefore",
"stepAfter",
+ "stepBefore",
]
],
- Literal[
- "basis",
- "basisClosed",
- "basisOpen",
- "bumpX",
- "bumpY",
- "bump",
- "linear",
- "linearClosed",
- "natural",
- "monotoneX",
- "monotoneY",
- "monotone",
- "step",
- "stepBefore",
- "stepAfter",
- ],
]
] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
stroke_width: Optional[Union[Var[int], int]] = None,
dot: Optional[
- Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]]
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool]
] = None,
active_dot: Optional[
- Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]]
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool]
] = None,
label: Optional[Union[Var[bool], bool]] = None,
hide: Optional[Union[Var[bool], bool]] = None,
connect_nulls: Optional[Union[Var[bool], bool]] = None,
- unit: Optional[Union[Var[Union[int, str]], str, int]] = None,
- name: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ unit: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ points: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ stroke_dasharray: Optional[Union[Var[str], str]] = None,
layout: Optional[
Union[
- Var[Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
- x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
legend_type: Optional[
Union[
- Var[
- Literal[
- "line",
- "plainline",
- "square",
- "rect",
- "circle",
- "cross",
- "diamond",
- "star",
- "triangle",
- "wye",
- "none",
- ]
- ],
Literal[
- "line",
- "plainline",
- "square",
- "rect",
"circle",
"cross",
"diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
"star",
"triangle",
"wye",
- "none",
+ ],
+ Var[
+ Literal[
+ "circle",
+ "cross",
+ "diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
+ "star",
+ "triangle",
+ "wye",
+ ]
],
]
] = None,
+ is_animation_active: Optional[Union[Var[bool], bool]] = None,
+ animation_begin: Optional[Union[Var[int], int]] = None,
+ animation_duration: Optional[Union[Var[int], int]] = None,
+ animation_easing: Optional[
+ Union[
+ Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
+ Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
+ ]
+ ] = None,
+ name: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_animation_end: Optional[EventType[[], BASE_STATE]] = None,
+ on_animation_start: Optional[EventType[[], BASE_STATE]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Line":
"""Create the component.
@@ -1345,20 +1299,36 @@ class Line(Cartesian):
Args:
*children: The children of the component.
type_: The interpolation type of line. And customized interpolation function can be set to type. It's the same as type in Area.
- stroke: The color of the line stroke.
- stroke_width: The width of the line stroke.
- dot: The dot is shown when mouse enter a line chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally.
- active_dot: The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally.
- label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally.
- hide: Hides the line when true, useful when toggling visibility state via legend.
+ stroke: The color of the line stroke. Default: rx.color("accent", 9)
+ stroke_width: The width of the line stroke. Default: 1
+ dot: The dot is shown when mouse enter a line chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 10), "fill": rx.color("accent", 4)}
+ active_dot: The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 2), "fill": rx.color("accent", 10)}
+ label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
+ hide: Hides the line when true, useful when toggling visibility state via legend. Default: False
connect_nulls: Whether to connect a graph line across null points.
unit: The unit of data. This option will be used in tooltip.
- name: The name of data displayed in the axis. This option will be used to represent an index in a scatter chart.
+ points: The coordinates of all the points in the line, usually calculated internally.
+ stroke_dasharray: The pattern of dashes and gaps used to paint the line.
layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical'
data_key: The key of a group of data which should be unique in an area chart.
- x_axis_id: The id of x-axis which is corresponding to the data.
- y_axis_id: The id of y-axis which is corresponding to the data.
- legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none'optional
+ x_axis_id: The id of x-axis which is corresponding to the data. Default: 0
+ y_axis_id: The id of y-axis which is corresponding to the data. Default: 0
+ legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none' optional
+ is_animation_active: If set false, animation of bar will be disabled. Default: True
+ animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
+ animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
+ animation_easing: The type of easing function. Default: "ease"
+ name: The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively.
+ on_animation_start: The customized event handler of animation start
+ on_animation_end: The customized event handler of animation end
+ on_click: The customized event handler of click on the component in this group
+ on_mouse_down: The customized event handler of mousedown on the component in this group
+ on_mouse_up: The customized event handler of mouseup on the component in this group
+ on_mouse_move: The customized event handler of mousemove on the component in this group
+ on_mouse_over: The customized event handler of mouseover on the component in this group
+ on_mouse_out: The customized event handler of mouseout on the component in this group
+ on_mouse_enter: The customized event handler of mouseenter on the component in this group
+ on_mouse_leave: The customized event handler of mouseleave on the component in this group
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -1378,73 +1348,72 @@ class Scatter(Recharts):
def create( # type: ignore
cls,
*children,
- data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None,
+ data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
legend_type: Optional[
Union[
- Var[
- Literal[
- "line",
- "plainline",
- "square",
- "rect",
- "circle",
- "cross",
- "diamond",
- "star",
- "triangle",
- "wye",
- "none",
- ]
- ],
Literal[
- "line",
- "plainline",
- "square",
- "rect",
"circle",
"cross",
"diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
"star",
"triangle",
"wye",
- "none",
],
- ]
- ] = None,
- x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- z_axis_id: Optional[Union[Var[str], str]] = None,
- line: Optional[Union[Var[bool], bool]] = None,
- shape: Optional[
- Union[
Var[
Literal[
- "square",
"circle",
"cross",
"diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
"star",
"triangle",
"wye",
]
],
+ ]
+ ] = None,
+ x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ z_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ line: Optional[Union[Var[bool], bool]] = None,
+ shape: Optional[
+ Union[
Literal[
- "square", "circle", "cross", "diamond", "star", "triangle", "wye"
+ "circle", "cross", "diamond", "square", "star", "triangle", "wye"
+ ],
+ Var[
+ Literal[
+ "circle",
+ "cross",
+ "diamond",
+ "square",
+ "star",
+ "triangle",
+ "wye",
+ ]
],
]
] = None,
line_type: Optional[
- Union[Var[Literal["joint", "fitting"]], Literal["joint", "fitting"]]
+ Union[Literal["fitting", "joint"], Var[Literal["fitting", "joint"]]]
] = None,
- fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- name: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
is_animation_active: Optional[Union[Var[bool], bool]] = None,
animation_begin: Optional[Union[Var[int], int]] = None,
animation_duration: Optional[Union[Var[int], int]] = None,
animation_easing: Optional[
Union[
- Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]],
- Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"],
+ Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
+ Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
]
] = None,
style: Optional[Style] = None,
@@ -1452,52 +1421,22 @@ class Scatter(Recharts):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Scatter":
"""Create the component.
@@ -1505,19 +1444,26 @@ class Scatter(Recharts):
Args:
*children: The children of the component.
data: The source data, in which each element is an object.
- legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye' | 'none'
- x_axis_id: The id of x-axis which is corresponding to the data.
- y_axis_id: The id of y-axis which is corresponding to the data.
- z_axis_id: The id of z-axis which is corresponding to the data.
- line: If false set, line will not be drawn. If true set, line will be drawn which have the props calculated internally.
- shape: If a string set, specified symbol will be used to show scatter item. 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye'
- line_type: If 'joint' set, line will generated by just jointing all the points. If 'fitting' set, line will be generated by fitting algorithm. 'joint' | 'fitting'
- fill: The fill
- name: the name
- is_animation_active: If set false, animation of bar will be disabled.
- animation_begin: Specifies when the animation should begin, the unit of this option is ms, default 0.
- animation_duration: Specifies the duration of animation, the unit of this option is ms, default 1500.
- animation_easing: The type of easing function, default 'ease'
+ legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye' | 'none'. Default: "circle"
+ x_axis_id: The id of x-axis which is corresponding to the data. Default: 0
+ y_axis_id: The id of y-axis which is corresponding to the data. Default: 0
+ z_axis_id: The id of z-axis which is corresponding to the data. Default: 0
+ line: If false set, line will not be drawn. If true set, line will be drawn which have the props calculated internally. Default: False
+ shape: If a string set, specified symbol will be used to show scatter item. 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye'. Default: "circle"
+ line_type: If 'joint' set, line will generated by just jointing all the points. If 'fitting' set, line will be generated by fitting algorithm. 'joint' | 'fitting'. Default: "joint"
+ fill: The fill color of the scatter. Default: rx.color("accent", 9)
+ is_animation_active: If set false, animation of bar will be disabled. Default: True in CSR, False in SSR
+ animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
+ animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
+ animation_easing: The type of easing function. Default: "ease"
+ on_click: The customized event handler of click on the component in this group
+ on_mouse_down: The customized event handler of mousedown on the component in this group
+ on_mouse_up: The customized event handler of mouseup on the component in this group
+ on_mouse_move: The customized event handler of mousemove on the component in this group
+ on_mouse_over: The customized event handler of mouseover on the component in this group
+ on_mouse_out: The customized event handler of mouseout on the component in this group
+ on_mouse_enter: The customized event handler of mouseenter on the component in this group
+ on_mouse_leave: The customized event handler of mouseleave on the component in this group
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -1537,38 +1483,38 @@ class Funnel(Recharts):
def create( # type: ignore
cls,
*children,
- data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
name_key: Optional[Union[Var[str], str]] = None,
legend_type: Optional[
Union[
- Var[
- Literal[
- "line",
- "plainline",
- "square",
- "rect",
- "circle",
- "cross",
- "diamond",
- "star",
- "triangle",
- "wye",
- "none",
- ]
- ],
Literal[
- "line",
- "plainline",
- "square",
- "rect",
"circle",
"cross",
"diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
"star",
"triangle",
"wye",
- "none",
+ ],
+ Var[
+ Literal[
+ "circle",
+ "cross",
+ "diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
+ "star",
+ "triangle",
+ "wye",
+ ]
],
]
] = None,
@@ -1577,68 +1523,37 @@ class Funnel(Recharts):
animation_duration: Optional[Union[Var[int], int]] = None,
animation_easing: Optional[
Union[
- Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]],
- Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"],
+ Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
+ Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
]
] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ trapezoids: Optional[
+ Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]
+ ] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_animation_end: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_animation_start: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_animation_end: Optional[EventType[[], BASE_STATE]] = None,
+ on_animation_start: Optional[EventType[[], BASE_STATE]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Funnel":
"""Create the component.
@@ -1646,14 +1561,25 @@ class Funnel(Recharts):
Args:
*children: The children of the component.
data: The source data, in which each element is an object.
- data_key: The key of a group of data which should be unique in an area chart.
- name_key: The key or getter of a group of data which should be unique in a LineChart.
- legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered.
- is_animation_active: If set false, animation of line will be disabled.
- animation_begin: Specifies when the animation should begin, the unit of this option is ms.
- animation_duration: Specifies the duration of animation, the unit of this option is ms.
- animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'
- stroke: stroke color
+ data_key: The key or getter of a group of data which should be unique in a FunnelChart.
+ name_key: The key of each sector's name. Default: "name"
+ legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "line"
+ is_animation_active: If set false, animation of line will be disabled. Default: True
+ animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
+ animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
+ animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default "ease"
+ stroke: Stroke color. Default: rx.color("gray", 3)
+ trapezoids: The coordinates of all the trapezoids in the funnel, usually calculated internally.
+ on_animation_start: The customized event handler of animation start
+ on_animation_end: The customized event handler of animation end
+ on_click: The customized event handler of click on the component in this group
+ on_mouse_down: The customized event handler of mousedown on the component in this group
+ on_mouse_up: The customized event handler of mouseup on the component in this group
+ on_mouse_move: The customized event handler of mousemove on the component in this group
+ on_mouse_over: The customized event handler of mouseover on the component in this group
+ on_mouse_out: The customized event handler of mouseout on the component in this group
+ on_mouse_enter: The customized event handler of mouseenter on the component in this group
+ on_mouse_leave: The customized event handler of mouseleave on the component in this group
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -1673,75 +1599,43 @@ class ErrorBar(Recharts):
def create( # type: ignore
cls,
*children,
- direction: Optional[
- Union[Var[Literal["x", "y", "both"]], Literal["x", "y", "both"]]
- ] = None,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ direction: Optional[Union[Literal["x", "y"], Var[Literal["x", "y"]]]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
width: Optional[Union[Var[int], int]] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- stroke_width: Optional[Union[Var[int], int]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ stroke_width: Optional[Union[Var[Union[float, int]], float, int]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ErrorBar":
"""Create the component.
Args:
*children: The children of the component.
- direction: The direction of error bar. 'x' | 'y' | 'both'
+ direction: Only used for ScatterChart with error bars in two directions. Only accepts a value of "x" or "y" and makes the error bars lie in that direction.
data_key: The key of a group of data which should be unique in an area chart.
- width: The width of the error bar ends.
- stroke: The stroke color of error bar.
- stroke_width: The stroke width of error bar.
+ width: The width of the error bar ends. Default: 5
+ stroke: The stroke color of error bar. Default: rx.color("gray", 8)
+ stroke_width: The stroke width of error bar. Default: 1.5
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -1761,78 +1655,48 @@ class Reference(Recharts):
def create( # type: ignore
cls,
*children,
- x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
if_overflow: Optional[
Union[
- Var[Literal["discard", "hidden", "visible", "extendDomain"]],
- Literal["discard", "hidden", "visible", "extendDomain"],
+ Literal["discard", "extendDomain", "hidden", "visible"],
+ Var[Literal["discard", "extendDomain", "hidden", "visible"]],
]
] = None,
- label: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ label: Optional[Union[Var[Union[int, str]], int, str]] = None,
is_front: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Reference":
"""Create the component.
Args:
*children: The children of the component.
- x_axis_id: The id of x-axis which is corresponding to the data.
- y_axis_id: The id of y-axis which is corresponding to the data.
- if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas.
+ x_axis_id: The id of x-axis which is corresponding to the data. Default: 0
+ y_axis_id: The id of y-axis which is corresponding to the data. Default: 0
+ if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard"
label: If set a string or a number, default label will be drawn, and the option is content.
- is_front: If set true, the line will be rendered in front of bars in BarChart, etc.
+ is_front: If set true, the line will be rendered in front of bars in BarChart, etc. Default: False
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -1852,72 +1716,42 @@ class ReferenceLine(Reference):
def create( # type: ignore
cls,
*children,
- x: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y: Optional[Union[Var[Union[int, str]], str, int]] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- stroke_width: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ x: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ stroke_width: Optional[Union[Var[Union[int, str]], int, str]] = None,
segment: Optional[List[Any]] = None,
- x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
if_overflow: Optional[
Union[
- Var[Literal["discard", "hidden", "visible", "extendDomain"]],
- Literal["discard", "hidden", "visible", "extendDomain"],
+ Literal["discard", "extendDomain", "hidden", "visible"],
+ Var[Literal["discard", "extendDomain", "hidden", "visible"]],
]
] = None,
- label: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ label: Optional[Union[Var[Union[int, str]], int, str]] = None,
is_front: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ReferenceLine":
"""Create the component.
@@ -1927,13 +1761,13 @@ class ReferenceLine(Reference):
x: If set a string or a number, a vertical line perpendicular to the x-axis specified by xAxisId will be drawn. If the specified x-axis is a number axis, the type of x must be Number. If the specified x-axis is a category axis, the value of x must be one of the categorys, otherwise no line will be drawn.
y: If set a string or a number, a horizontal line perpendicular to the y-axis specified by yAxisId will be drawn. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys, otherwise no line will be drawn.
stroke: The color of the reference line.
- stroke_width: The width of the stroke.
+ stroke_width: The width of the stroke. Default: 1
segment: Array of endpoints in { x, y } format. These endpoints would be used to draw the ReferenceLine.
- x_axis_id: The id of x-axis which is corresponding to the data.
- y_axis_id: The id of y-axis which is corresponding to the data.
- if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas.
+ x_axis_id: The id of x-axis which is corresponding to the data. Default: 0
+ y_axis_id: The id of y-axis which is corresponding to the data. Default: 0
+ if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard"
label: If set a string or a number, default label will be drawn, and the option is content.
- is_front: If set true, the line will be rendered in front of bars in BarChart, etc.
+ is_front: If set true, the line will be rendered in front of bars in BarChart, etc. Default: False
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -1953,72 +1787,42 @@ class ReferenceDot(Reference):
def create( # type: ignore
cls,
*children,
- x: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ x: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y: Optional[Union[Var[Union[int, str]], int, str]] = None,
r: Optional[Union[Var[int], int]] = None,
- fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
if_overflow: Optional[
Union[
- Var[Literal["discard", "hidden", "visible", "extendDomain"]],
- Literal["discard", "hidden", "visible", "extendDomain"],
+ Literal["discard", "extendDomain", "hidden", "visible"],
+ Var[Literal["discard", "extendDomain", "hidden", "visible"]],
]
] = None,
- label: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ label: Optional[Union[Var[Union[int, str]], int, str]] = None,
is_front: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ReferenceDot":
"""Create the component.
@@ -2030,11 +1834,19 @@ class ReferenceDot(Reference):
r: The radius of dot.
fill: The color of the area fill.
stroke: The color of the line stroke.
- x_axis_id: The id of x-axis which is corresponding to the data.
- y_axis_id: The id of y-axis which is corresponding to the data.
- if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas.
+ on_click: The customized event handler of click on the component in this chart
+ on_mouse_down: The customized event handler of mousedown on the component in this chart
+ on_mouse_up: The customized event handler of mouseup on the component in this chart
+ on_mouse_over: The customized event handler of mouseover on the component in this chart
+ on_mouse_out: The customized event handler of mouseout on the component in this chart
+ on_mouse_enter: The customized event handler of mouseenter on the component in this chart
+ on_mouse_move: The customized event handler of mousemove on the component in this chart
+ on_mouse_leave: The customized event handler of mouseleave on the component in this chart
+ x_axis_id: The id of x-axis which is corresponding to the data. Default: 0
+ y_axis_id: The id of y-axis which is corresponding to the data. Default: 0
+ if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard"
label: If set a string or a number, default label will be drawn, and the option is content.
- is_front: If set true, the line will be rendered in front of bars in BarChart, etc.
+ is_front: If set true, the line will be rendered in front of bars in BarChart, etc. Default: False
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -2054,19 +1866,19 @@ class ReferenceArea(Recharts):
def create( # type: ignore
cls,
*children,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
fill_opacity: Optional[Union[Var[float], float]] = None,
- x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None,
- x1: Optional[Union[Var[Union[int, str]], str, int]] = None,
- x2: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y1: Optional[Union[Var[Union[int, str]], str, int]] = None,
- y2: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ x1: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ x2: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y1: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ y2: Optional[Union[Var[Union[int, str]], int, str]] = None,
if_overflow: Optional[
Union[
- Var[Literal["discard", "hidden", "visible", "extendDomain"]],
- Literal["discard", "hidden", "visible", "extendDomain"],
+ Literal["discard", "extendDomain", "hidden", "visible"],
+ Var[Literal["discard", "extendDomain", "hidden", "visible"]],
]
] = None,
is_front: Optional[Union[Var[bool], bool]] = None,
@@ -2075,52 +1887,22 @@ class ReferenceArea(Recharts):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ReferenceArea":
"""Create the component.
@@ -2136,8 +1918,8 @@ class ReferenceArea(Recharts):
x2: A boundary value of the area. If the specified x-axis is a number axis, the type of x must be Number. If the specified x-axis is a category axis, the value of x must be one of the categorys. If one of x1 or x2 is invalidate, the area will cover along x-axis.
y1: A boundary value of the area. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys. If one of y1 or y2 is invalidate, the area will cover along y-axis.
y2: A boundary value of the area. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys. If one of y1 or y2 is invalidate, the area will cover along y-axis.
- if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas.
- is_front: If set true, the line will be rendered in front of bars in BarChart, etc.
+ if_overflow: Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard"
+ is_front: If set true, the line will be rendered in front of bars in BarChart, etc. Default: False
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -2166,62 +1948,32 @@ class Grid(Recharts):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Grid":
"""Create the component.
Args:
*children: The children of the component.
- x: The x-coordinate of grid.
- y: The y-coordinate of grid.
- width: The width of grid.
- height: The height of grid.
+ x: The x-coordinate of grid. Default: 0
+ y: The y-coordinate of grid. Default: 0
+ width: The width of grid. Default: 0
+ height: The height of grid. Default: 0
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -2244,15 +1996,15 @@ class CartesianGrid(Grid):
horizontal: Optional[Union[Var[bool], bool]] = None,
vertical: Optional[Union[Var[bool], bool]] = None,
vertical_points: Optional[
- Union[Var[List[Union[int, str]]], List[Union[int, str]]]
+ Union[List[Union[int, str]], Var[List[Union[int, str]]]]
] = None,
horizontal_points: Optional[
- Union[Var[List[Union[int, str]]], List[Union[int, str]]]
+ Union[List[Union[int, str]], Var[List[Union[int, str]]]]
] = None,
- fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
fill_opacity: Optional[Union[Var[float], float]] = None,
stroke_dasharray: Optional[Union[Var[str], str]] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
x: Optional[Union[Var[int], int]] = None,
y: Optional[Union[Var[int], int]] = None,
width: Optional[Union[Var[int], int]] = None,
@@ -2262,70 +2014,40 @@ class CartesianGrid(Grid):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "CartesianGrid":
"""Create the component.
Args:
*children: The children of the component.
- horizontal: The horizontal line configuration.
- vertical: The vertical line configuration.
- vertical_points: The x-coordinates in pixel values of all vertical lines.
- horizontal_points: The x-coordinates in pixel values of all vertical lines.
+ horizontal: The horizontal line configuration. Default: True
+ vertical: The vertical line configuration. Default: True
+ vertical_points: The x-coordinates in pixel values of all vertical lines. Default: []
+ horizontal_points: The x-coordinates in pixel values of all vertical lines. Default: []
fill: The background of grid.
- fill_opacity: The opacity of the background used to fill the space between grid lines
- stroke_dasharray: The pattern of dashes and gaps used to paint the lines of the grid
- stroke: the stroke color of grid
- x: The x-coordinate of grid.
- y: The y-coordinate of grid.
- width: The width of grid.
- height: The height of grid.
+ fill_opacity: The opacity of the background used to fill the space between grid lines.
+ stroke_dasharray: The pattern of dashes and gaps used to paint the lines of the grid.
+ stroke: the stroke color of grid. Default: rx.color("gray", 7)
+ x: The x-coordinate of grid. Default: 0
+ y: The y-coordinate of grid. Default: 0
+ width: The width of grid. Default: 0
+ height: The height of grid. Default: 0
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -2347,21 +2069,22 @@ class CartesianAxis(Grid):
*children,
orientation: Optional[
Union[
- Var[Literal["top", "bottom", "left", "right"]],
- Literal["top", "bottom", "left", "right"],
+ Literal["bottom", "left", "right", "top"],
+ Var[Literal["bottom", "left", "right", "top"]],
]
] = None,
+ view_box: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
axis_line: Optional[Union[Var[bool], bool]] = None,
+ tick: Optional[Union[Var[bool], bool]] = None,
tick_line: Optional[Union[Var[bool], bool]] = None,
tick_size: Optional[Union[Var[int], int]] = None,
interval: Optional[
Union[
- Var[Literal["preserveStart", "preserveEnd", "preserveStartEnd"]],
- Literal["preserveStart", "preserveEnd", "preserveStartEnd"],
+ Literal["preserveEnd", "preserveStart", "preserveStartEnd"],
+ Var[Literal["preserveEnd", "preserveStart", "preserveStartEnd"]],
]
] = None,
- ticks: Optional[Union[Var[bool], bool]] = None,
- label: Optional[Union[Var[str], str]] = None,
+ label: Optional[Union[Var[Union[int, str]], int, str]] = None,
mirror: Optional[Union[Var[bool], bool]] = None,
tick_margin: Optional[Union[Var[int], int]] = None,
x: Optional[Union[Var[int], int]] = None,
@@ -2373,71 +2096,42 @@ class CartesianAxis(Grid):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "CartesianAxis":
"""Create the component.
Args:
*children: The children of the component.
- orientation: The orientation of axis 'top' | 'bottom' | 'left' | 'right'
- axis_line: If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line.
- tick_line: If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines.
- tick_size: The length of tick line.
- interval: If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically.
- ticks: If set false, no ticks will be drawn.
+ orientation: The orientation of axis 'top' | 'bottom' | 'left' | 'right'. Default: "bottom"
+ view_box: The box of viewing area. Default: {"x": 0, "y": 0, "width": 0, "height": 0}
+ axis_line: If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. Default: True
+ tick: If set false, no ticks will be drawn.
+ tick_line: If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. Default: True
+ tick_size: The length of tick line. Default: 6
+ interval: If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd"
label: If set a string or a number, default label will be drawn, and the option is content.
- mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside.
+ mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False
tick_margin: The margin between tick line and tick.
- x: The x-coordinate of grid.
- y: The y-coordinate of grid.
- width: The width of grid.
- height: The height of grid.
+ x: The x-coordinate of grid. Default: 0
+ y: The y-coordinate of grid. Default: 0
+ width: The width of grid. Default: 0
+ height: The height of grid. Default: 0
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/recharts/charts.py b/reflex/components/recharts/charts.py
index 0f52545d0..85e10c2c5 100644
--- a/reflex/components/recharts/charts.py
+++ b/reflex/components/recharts/charts.py
@@ -8,8 +8,8 @@ from reflex.components.component import Component
from reflex.components.recharts.general import ResponsiveContainer
from reflex.constants import EventTriggers
from reflex.constants.colors import Color
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, no_args_event_spec
+from reflex.vars.base import Var
from .recharts import (
LiteralAnimationEasing,
@@ -31,16 +31,16 @@ class ChartBase(RechartsCharts):
height: Var[Union[str, int]] = "100%" # type: ignore
# The customized event handler of click on the component in this chart
- on_click: EventHandler[lambda: []]
+ on_click: EventHandler[no_args_event_spec]
# The customized event handler of mouseenter on the component in this chart
- on_mouse_enter: EventHandler[lambda: []]
+ on_mouse_enter: EventHandler[no_args_event_spec]
# The customized event handler of mousemove on the component in this chart
- on_mouse_move: EventHandler[lambda: []]
+ on_mouse_move: EventHandler[no_args_event_spec]
# The customized event handler of mouseleave on the component in this chart
- on_mouse_leave: EventHandler[lambda: []]
+ on_mouse_leave: EventHandler[no_args_event_spec]
@staticmethod
def _ensure_valid_dimension(name: str, value: Any) -> None:
@@ -84,10 +84,10 @@ class ChartBase(RechartsCharts):
cls._ensure_valid_dimension("width", width)
cls._ensure_valid_dimension("height", height)
- dim_props = dict(
- width=width or "100%",
- height=height or "100%",
- )
+ dim_props = {
+ "width": width or "100%",
+ "height": height or "100%",
+ }
# Provide min dimensions so the graph always appears, even if the outer container is zero-size.
if width is None:
dim_props["min_width"] = 200
@@ -112,10 +112,10 @@ class CategoricalChartBase(ChartBase):
# If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush.
sync_id: Var[str]
- # When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function
+ # When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function. Default: "index"
sync_method: Var[LiteralSyncMethod]
- # The layout of area in the chart. 'horizontal' | 'vertical'
+ # The layout of area in the chart. 'horizontal' | 'vertical'. Default: "horizontal"
layout: Var[LiteralLayout]
# The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette'
@@ -129,7 +129,7 @@ class AreaChart(CategoricalChartBase):
alias = "RechartsAreaChart"
- # The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'
+ # The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'. Default: "auto"
base_value: Var[Union[int, LiteralComposedChartBaseValue]]
# Valid children components
@@ -155,11 +155,11 @@ class BarChart(CategoricalChartBase):
alias = "RechartsBarChart"
- # The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number
- bar_category_gap: Var[Union[str, int]] = Var.create_safe("10%", _var_is_string=True) # type: ignore
+ # The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number. Default: "10%"
+ bar_category_gap: Var[Union[str, int]]
- # The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number
- bar_gap: Var[Union[str, int]] = Var.create_safe(4) # type: ignore
+ # The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number. Default: 4
+ bar_gap: Var[Union[str, int]]
# The width of all the bars in the chart. Number
bar_size: Var[int]
@@ -167,10 +167,10 @@ class BarChart(CategoricalChartBase):
# The maximum width of all the bars in a horizontal BarChart, or maximum height in a vertical BarChart.
max_bar_size: Var[int]
- # The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape.
+ # The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. Default: "none"
stack_offset: Var[LiteralStackOffset]
- # If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.)
+ # If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.) Default: False
reverse_stack_order: Var[bool]
# Valid children components
@@ -217,19 +217,19 @@ class ComposedChart(CategoricalChartBase):
alias = "RechartsComposedChart"
- # The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'
+ # The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'. Default: "auto"
base_value: Var[Union[int, LiteralComposedChartBaseValue]]
- # The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number
- bar_category_gap: Var[Union[str, int]] # type: ignore
+ # The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number. Default: "10%"
+ bar_category_gap: Var[Union[str, int]]
- # The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number
- bar_gap: Var[Union[str, int]] # type: ignore
+ # The gap between two bars in the same category. Default: 4
+ bar_gap: Var[int]
- # The width of all the bars in the chart. Number
+ # The width or height of each bar. If the barSize is not specified, the size of the bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups.
bar_size: Var[int]
- # If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.)
+ # If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position). Default: False
reverse_stack_order: Var[bool]
# Valid children components
@@ -270,16 +270,16 @@ class PieChart(ChartBase):
]
# The customized event handler of mousedown on the sectors in this group
- on_mouse_down: EventHandler[lambda: []]
+ on_mouse_down: EventHandler[no_args_event_spec]
# The customized event handler of mouseup on the sectors in this group
- on_mouse_up: EventHandler[lambda: []]
+ on_mouse_up: EventHandler[no_args_event_spec]
# The customized event handler of mouseover on the sectors in this group
- on_mouse_over: EventHandler[lambda: []]
+ on_mouse_over: EventHandler[no_args_event_spec]
# The customized event handler of mouseout on the sectors in this group
- on_mouse_out: EventHandler[lambda: []]
+ on_mouse_out: EventHandler[no_args_event_spec]
class RadarChart(ChartBase):
@@ -292,25 +292,25 @@ class RadarChart(ChartBase):
# The source data, in which each element is an object.
data: Var[List[Dict[str, Any]]]
- # The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
+ # The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. Default: {"top": 0, "right": 0, "left": 0, "bottom": 0}
margin: Var[Dict[str, Any]]
- # The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage
+ # The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage. Default: "50%"
cx: Var[Union[int, str]]
- # The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage
+ # The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage. Default: "50%"
cy: Var[Union[int, str]]
- # The angle of first radial direction line.
+ # The angle of first radial direction line. Default: 90
start_angle: Var[int]
- # The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'.
+ # The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'. Default: -270
end_angle: Var[int]
- # The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage
+ # The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: 0
inner_radius: Var[Union[int, str]]
- # The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage
+ # The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: "80%"
outer_radius: Var[Union[int, str]]
# Valid children components
@@ -330,9 +330,9 @@ class RadarChart(ChartBase):
A dict mapping the event trigger to the var that is passed to the handler.
"""
return {
- EventTriggers.ON_CLICK: lambda: [],
- EventTriggers.ON_MOUSE_ENTER: lambda: [],
- EventTriggers.ON_MOUSE_LEAVE: lambda: [],
+ EventTriggers.ON_CLICK: no_args_event_spec,
+ EventTriggers.ON_MOUSE_ENTER: no_args_event_spec,
+ EventTriggers.ON_MOUSE_LEAVE: no_args_event_spec,
}
@@ -346,31 +346,31 @@ class RadialBarChart(ChartBase):
# The source data which each element is an object.
data: Var[List[Dict[str, Any]]]
- # The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
+ # The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "left": 5 "bottom": 5}
margin: Var[Dict[str, Any]]
- # The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage
+ # The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage. Default: "50%"
cx: Var[Union[int, str]]
- # The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage
+ # The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage. Default: "50%"
cy: Var[Union[int, str]]
- # The angle of first radial direction line.
+ # The angle of first radial direction line. Default: 0
start_angle: Var[int]
- # The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'.
+ # The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'. Default: 360
end_angle: Var[int]
- # The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage
+ # The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: "30%"
inner_radius: Var[Union[int, str]]
- # The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage
+ # The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: "100%"
outer_radius: Var[Union[int, str]]
- # The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number
+ # The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number. Default: "10%"
bar_category_gap: Var[Union[int, str]]
- # The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number
+ # The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number. Default: 4
bar_gap: Var[str]
# The size of each bar. If the barSize is not specified, the size of bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups.
@@ -394,7 +394,7 @@ class ScatterChart(ChartBase):
alias = "RechartsScatterChart"
- # The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
+ # The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "bottom": 5, "left": 5}
margin: Var[Dict[str, Any]]
# Valid children components
@@ -419,14 +419,14 @@ class ScatterChart(ChartBase):
A dict mapping the event trigger to the var that is passed to the handler.
"""
return {
- EventTriggers.ON_CLICK: lambda: [],
- EventTriggers.ON_MOUSE_DOWN: lambda: [],
- EventTriggers.ON_MOUSE_UP: lambda: [],
- EventTriggers.ON_MOUSE_MOVE: lambda: [],
- EventTriggers.ON_MOUSE_OVER: lambda: [],
- EventTriggers.ON_MOUSE_OUT: lambda: [],
- EventTriggers.ON_MOUSE_ENTER: lambda: [],
- EventTriggers.ON_MOUSE_LEAVE: lambda: [],
+ EventTriggers.ON_CLICK: no_args_event_spec,
+ EventTriggers.ON_MOUSE_DOWN: no_args_event_spec,
+ EventTriggers.ON_MOUSE_UP: no_args_event_spec,
+ EventTriggers.ON_MOUSE_MOVE: no_args_event_spec,
+ EventTriggers.ON_MOUSE_OVER: no_args_event_spec,
+ EventTriggers.ON_MOUSE_OUT: no_args_event_spec,
+ EventTriggers.ON_MOUSE_ENTER: no_args_event_spec,
+ EventTriggers.ON_MOUSE_LEAVE: no_args_event_spec,
}
@@ -437,10 +437,10 @@ class FunnelChart(ChartBase):
alias = "RechartsFunnelChart"
- # The layout of bars in the chart. centeric
+ # The layout of bars in the chart. Default: "centric"
layout: Var[str]
- # The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
+ # The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "bottom": 5, "left": 5}
margin: Var[Dict[str, Any]]
# The stroke color of each bar. String | Object
@@ -457,38 +457,41 @@ class Treemap(RechartsCharts):
alias = "RechartsTreemap"
- # The width of chart container. String or Integer
+ # The width of chart container. String or Integer. Default: "100%"
width: Var[Union[str, int]] = "100%" # type: ignore
- # The height of chart container.
+ # The height of chart container. String or Integer. Default: "100%"
height: Var[Union[str, int]] = "100%" # type: ignore
# data of treemap. Array
data: Var[List[Dict[str, Any]]]
- # The key of a group of data which should be unique in a treemap. String | Number | Function
+ # The key of a group of data which should be unique in a treemap. String | Number. Default: "value"
data_key: Var[Union[str, int]]
+ # The key of each sector's name. String. Default: "name"
+ name_key: Var[str]
+
# The treemap will try to keep every single rectangle's aspect ratio near the aspectRatio given. Number
aspect_ratio: Var[int]
- # If set false, animation of area will be disabled.
+ # If set false, animation of area will be disabled. Default: True
is_animation_active: Var[bool]
- # Specifies when the animation should begin, the unit of this option is ms.
+ # Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_begin: Var[int]
- # Specifies the duration of animation, the unit of this option is ms.
+ # Specifies the duration of animation, the unit of this option is ms. Default: 1500
animation_duration: Var[int]
- # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'
+ # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease"
animation_easing: Var[LiteralAnimationEasing]
# The customized event handler of animation start
- on_animation_start: EventHandler[lambda: []]
+ on_animation_start: EventHandler[no_args_event_spec]
# The customized event handler of animation end
- on_animation_end: EventHandler[lambda: []]
+ on_animation_end: EventHandler[no_args_event_spec]
@classmethod
def create(cls, *children, **props) -> Component:
diff --git a/reflex/components/recharts/charts.pyi b/reflex/components/recharts/charts.pyi
index 9984bd8c5..6bf9b6a60 100644
--- a/reflex/components/recharts/charts.pyi
+++ b/reflex/components/recharts/charts.pyi
@@ -3,16 +3,14 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Union, overload
from reflex.constants.colors import Color
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
-from .recharts import (
- RechartsCharts,
-)
+from .recharts import RechartsCharts
class ChartBase(RechartsCharts):
@overload
@@ -20,59 +18,29 @@ class ChartBase(RechartsCharts):
def create( # type: ignore
cls,
*children,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ChartBase":
"""Create a chart component.
@@ -81,6 +49,10 @@ class ChartBase(RechartsCharts):
*children: The children of the chart component.
width: The width of chart container. String or Integer
height: The height of chart container.
+ on_click: The customized event handler of click on the component in this chart
+ on_mouse_enter: The customized event handler of mouseenter on the component in this chart
+ on_mouse_move: The customized event handler of mousemove on the component in this chart
+ on_mouse_leave: The customized event handler of mouseleave on the component in this chart
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -100,77 +72,47 @@ class CategoricalChartBase(ChartBase):
def create( # type: ignore
cls,
*children,
- data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None,
- margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
+ data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
sync_id: Optional[Union[Var[str], str]] = None,
sync_method: Optional[
- Union[Var[Literal["index", "value"]], Literal["index", "value"]]
+ Union[Literal["index", "value"], Var[Literal["index", "value"]]]
] = None,
layout: Optional[
Union[
- Var[Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
stack_offset: Optional[
Union[
- Var[Literal["expand", "none", "wiggle", "silhouette"]],
- Literal["expand", "none", "wiggle", "silhouette"],
+ Literal["expand", "none", "silhouette", "wiggle"],
+ Var[Literal["expand", "none", "silhouette", "wiggle"]],
]
] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "CategoricalChartBase":
"""Create a chart component.
@@ -180,11 +122,15 @@ class CategoricalChartBase(ChartBase):
data: The source data, in which each element is an object.
margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush.
- sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function
- layout: The layout of area in the chart. 'horizontal' | 'vertical'
+ sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function. Default: "index"
+ layout: The layout of area in the chart. 'horizontal' | 'vertical'. Default: "horizontal"
stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette'
width: The width of chart container. String or Integer
height: The height of chart container.
+ on_click: The customized event handler of click on the component in this chart
+ on_mouse_enter: The customized event handler of mouseenter on the component in this chart
+ on_mouse_move: The customized event handler of mousemove on the component in this chart
+ on_mouse_leave: The customized event handler of mouseleave on the component in this chart
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -206,97 +152,71 @@ class AreaChart(CategoricalChartBase):
*children,
base_value: Optional[
Union[
- Var[Union[Literal["dataMin", "dataMax", "auto"], int]],
+ Literal["auto", "dataMax", "dataMin"],
+ Var[Union[Literal["auto", "dataMax", "dataMin"], int]],
int,
- Literal["dataMin", "dataMax", "auto"],
]
] = None,
- data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None,
- margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
+ data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
sync_id: Optional[Union[Var[str], str]] = None,
sync_method: Optional[
- Union[Var[Literal["index", "value"]], Literal["index", "value"]]
+ Union[Literal["index", "value"], Var[Literal["index", "value"]]]
] = None,
layout: Optional[
Union[
- Var[Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
stack_offset: Optional[
Union[
- Var[Literal["expand", "none", "wiggle", "silhouette"]],
- Literal["expand", "none", "wiggle", "silhouette"],
+ Literal["expand", "none", "silhouette", "wiggle"],
+ Var[Literal["expand", "none", "silhouette", "wiggle"]],
]
] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "AreaChart":
"""Create a chart component.
Args:
*children: The children of the chart component.
- base_value: The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'
+ base_value: The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'. Default: "auto"
data: The source data, in which each element is an object.
margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush.
- sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function
- layout: The layout of area in the chart. 'horizontal' | 'vertical'
+ sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function. Default: "index"
+ layout: The layout of area in the chart. 'horizontal' | 'vertical'. Default: "horizontal"
stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette'
width: The width of chart container. String or Integer
height: The height of chart container.
+ on_click: The customized event handler of click on the component in this chart
+ on_mouse_enter: The customized event handler of mouseenter on the component in this chart
+ on_mouse_move: The customized event handler of mousemove on the component in this chart
+ on_mouse_leave: The customized event handler of mouseleave on the component in this chart
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -316,101 +236,75 @@ class BarChart(CategoricalChartBase):
def create( # type: ignore
cls,
*children,
- bar_category_gap: Optional[Union[Var[Union[int, str]], str, int]] = None,
- bar_gap: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ bar_category_gap: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ bar_gap: Optional[Union[Var[Union[int, str]], int, str]] = None,
bar_size: Optional[Union[Var[int], int]] = None,
max_bar_size: Optional[Union[Var[int], int]] = None,
stack_offset: Optional[
Union[
- Var[Literal["expand", "none", "wiggle", "silhouette"]],
- Literal["expand", "none", "wiggle", "silhouette"],
+ Literal["expand", "none", "silhouette", "wiggle"],
+ Var[Literal["expand", "none", "silhouette", "wiggle"]],
]
] = None,
reverse_stack_order: Optional[Union[Var[bool], bool]] = None,
- data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None,
- margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
+ data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
sync_id: Optional[Union[Var[str], str]] = None,
sync_method: Optional[
- Union[Var[Literal["index", "value"]], Literal["index", "value"]]
+ Union[Literal["index", "value"], Var[Literal["index", "value"]]]
] = None,
layout: Optional[
Union[
- Var[Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "BarChart":
"""Create a chart component.
Args:
*children: The children of the chart component.
- bar_category_gap: The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number
- bar_gap: The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number
+ bar_category_gap: The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number. Default: "10%"
+ bar_gap: The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number. Default: 4
bar_size: The width of all the bars in the chart. Number
max_bar_size: The maximum width of all the bars in a horizontal BarChart, or maximum height in a vertical BarChart.
stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette'
- reverse_stack_order: If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.)
+ reverse_stack_order: If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.) Default: False
data: The source data, in which each element is an object.
margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush.
- sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function
- layout: The layout of area in the chart. 'horizontal' | 'vertical'
+ sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function. Default: "index"
+ layout: The layout of area in the chart. 'horizontal' | 'vertical'. Default: "horizontal"
width: The width of chart container. String or Integer
height: The height of chart container.
+ on_click: The customized event handler of click on the component in this chart
+ on_mouse_enter: The customized event handler of mouseenter on the component in this chart
+ on_mouse_move: The customized event handler of mousemove on the component in this chart
+ on_mouse_leave: The customized event handler of mouseleave on the component in this chart
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -430,77 +324,47 @@ class LineChart(CategoricalChartBase):
def create( # type: ignore
cls,
*children,
- data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None,
- margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
+ data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
sync_id: Optional[Union[Var[str], str]] = None,
sync_method: Optional[
- Union[Var[Literal["index", "value"]], Literal["index", "value"]]
+ Union[Literal["index", "value"], Var[Literal["index", "value"]]]
] = None,
layout: Optional[
Union[
- Var[Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
stack_offset: Optional[
Union[
- Var[Literal["expand", "none", "wiggle", "silhouette"]],
- Literal["expand", "none", "wiggle", "silhouette"],
+ Literal["expand", "none", "silhouette", "wiggle"],
+ Var[Literal["expand", "none", "silhouette", "wiggle"]],
]
] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "LineChart":
"""Create a chart component.
@@ -510,11 +374,15 @@ class LineChart(CategoricalChartBase):
data: The source data, in which each element is an object.
margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush.
- sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function
- layout: The layout of area in the chart. 'horizontal' | 'vertical'
+ sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function. Default: "index"
+ layout: The layout of area in the chart. 'horizontal' | 'vertical'. Default: "horizontal"
stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette'
width: The width of chart container. String or Integer
height: The height of chart container.
+ on_click: The customized event handler of click on the component in this chart
+ on_mouse_enter: The customized event handler of mouseenter on the component in this chart
+ on_mouse_move: The customized event handler of mousemove on the component in this chart
+ on_mouse_leave: The customized event handler of mouseleave on the component in this chart
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -536,105 +404,79 @@ class ComposedChart(CategoricalChartBase):
*children,
base_value: Optional[
Union[
- Var[Union[Literal["dataMin", "dataMax", "auto"], int]],
+ Literal["auto", "dataMax", "dataMin"],
+ Var[Union[Literal["auto", "dataMax", "dataMin"], int]],
int,
- Literal["dataMin", "dataMax", "auto"],
]
] = None,
- bar_category_gap: Optional[Union[Var[Union[int, str]], str, int]] = None,
- bar_gap: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ bar_category_gap: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ bar_gap: Optional[Union[Var[int], int]] = None,
bar_size: Optional[Union[Var[int], int]] = None,
reverse_stack_order: Optional[Union[Var[bool], bool]] = None,
- data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None,
- margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
+ data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
sync_id: Optional[Union[Var[str], str]] = None,
sync_method: Optional[
- Union[Var[Literal["index", "value"]], Literal["index", "value"]]
+ Union[Literal["index", "value"], Var[Literal["index", "value"]]]
] = None,
layout: Optional[
Union[
- Var[Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
stack_offset: Optional[
Union[
- Var[Literal["expand", "none", "wiggle", "silhouette"]],
- Literal["expand", "none", "wiggle", "silhouette"],
+ Literal["expand", "none", "silhouette", "wiggle"],
+ Var[Literal["expand", "none", "silhouette", "wiggle"]],
]
] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ComposedChart":
"""Create a chart component.
Args:
*children: The children of the chart component.
- base_value: The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'
- bar_category_gap: The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number
- bar_gap: The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number
- bar_size: The width of all the bars in the chart. Number
- reverse_stack_order: If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.)
+ base_value: The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'. Default: "auto"
+ bar_category_gap: The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number. Default: "10%"
+ bar_gap: The gap between two bars in the same category. Default: 4
+ bar_size: The width or height of each bar. If the barSize is not specified, the size of the bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups.
+ reverse_stack_order: If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position). Default: False
data: The source data, in which each element is an object.
margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
sync_id: If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush.
- sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function
- layout: The layout of area in the chart. 'horizontal' | 'vertical'
+ sync_method: When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function. Default: "index"
+ layout: The layout of area in the chart. 'horizontal' | 'vertical'. Default: "horizontal"
stack_offset: The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette'
width: The width of chart container. String or Integer
height: The height of chart container.
+ on_click: The customized event handler of click on the component in this chart
+ on_mouse_enter: The customized event handler of mouseenter on the component in this chart
+ on_mouse_move: The customized event handler of mousemove on the component in this chart
+ on_mouse_leave: The customized event handler of mouseleave on the component in this chart
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -654,60 +496,30 @@ class PieChart(ChartBase):
def create( # type: ignore
cls,
*children,
- margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "PieChart":
"""Create a chart component.
@@ -715,8 +527,16 @@ class PieChart(ChartBase):
Args:
*children: The children of the chart component.
margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
+ on_mouse_down: The customized event handler of mousedown on the sectors in this group
+ on_mouse_up: The customized event handler of mouseup on the sectors in this group
+ on_mouse_over: The customized event handler of mouseover on the sectors in this group
+ on_mouse_out: The customized event handler of mouseout on the sectors in this group
width: The width of chart container. String or Integer
height: The height of chart container.
+ on_click: The customized event handler of click on the component in this chart
+ on_mouse_enter: The customized event handler of mouseenter on the component in this chart
+ on_mouse_move: The customized event handler of mousemove on the component in this chart
+ on_mouse_leave: The customized event handler of mouseleave on the component in this chart
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -737,31 +557,25 @@ class RadarChart(ChartBase):
def create( # type: ignore
cls,
*children,
- data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None,
- margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
+ data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
cx: Optional[Union[Var[Union[int, str]], int, str]] = None,
cy: Optional[Union[Var[Union[int, str]], int, str]] = None,
start_angle: Optional[Union[Var[int], int]] = None,
end_angle: Optional[Union[Var[int], int]] = None,
inner_radius: Optional[Union[Var[Union[int, str]], int, str]] = None,
outer_radius: Optional[Union[Var[Union[int, str]], int, str]] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "RadarChart":
"""Create a chart component.
@@ -769,15 +583,18 @@ class RadarChart(ChartBase):
Args:
*children: The children of the chart component.
data: The source data, in which each element is an object.
- margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
- cx: The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage
- cy: The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage
- start_angle: The angle of first radial direction line.
- end_angle: The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'.
- inner_radius: The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage
- outer_radius: The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage
+ margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. Default: {"top": 0, "right": 0, "left": 0, "bottom": 0}
+ cx: The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage. Default: "50%"
+ cy: The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage. Default: "50%"
+ start_angle: The angle of first radial direction line. Default: 90
+ end_angle: The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'. Default: -270
+ inner_radius: The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: 0
+ outer_radius: The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: "80%"
width: The width of chart container. String or Integer
height: The height of chart container.
+ on_click: The customized event handler of click on the component in this chart
+ on_mouse_enter: The customized event handler of mouseenter on the component in this chart
+ on_mouse_leave: The customized event handler of mouseleave on the component in this chart
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -797,8 +614,8 @@ class RadialBarChart(ChartBase):
def create( # type: ignore
cls,
*children,
- data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None,
- margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
+ data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
cx: Optional[Union[Var[Union[int, str]], int, str]] = None,
cy: Optional[Union[Var[Union[int, str]], int, str]] = None,
start_angle: Optional[Union[Var[int], int]] = None,
@@ -808,59 +625,29 @@ class RadialBarChart(ChartBase):
bar_category_gap: Optional[Union[Var[Union[int, str]], int, str]] = None,
bar_gap: Optional[Union[Var[str], str]] = None,
bar_size: Optional[Union[Var[int], int]] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "RadialBarChart":
"""Create a chart component.
@@ -868,18 +655,22 @@ class RadialBarChart(ChartBase):
Args:
*children: The children of the chart component.
data: The source data which each element is an object.
- margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
- cx: The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage
- cy: The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage
- start_angle: The angle of first radial direction line.
- end_angle: The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'.
- inner_radius: The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage
- outer_radius: The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage
- bar_category_gap: The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number
- bar_gap: The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number
+ margin: The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "left": 5 "bottom": 5}
+ cx: The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage. Default: "50%"
+ cy: The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage. Default: "50%"
+ start_angle: The angle of first radial direction line. Default: 0
+ end_angle: The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'. Default: 360
+ inner_radius: The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: "30%"
+ outer_radius: The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage. Default: "100%"
+ bar_category_gap: The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number. Default: "10%"
+ bar_gap: The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number. Default: 4
bar_size: The size of each bar. If the barSize is not specified, the size of bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups.
width: The width of chart container. String or Integer
height: The height of chart container.
+ on_click: The customized event handler of click on the component in this chart
+ on_mouse_enter: The customized event handler of mouseenter on the component in this chart
+ on_mouse_move: The customized event handler of mousemove on the component in this chart
+ on_mouse_leave: The customized event handler of mouseleave on the component in this chart
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -900,48 +691,36 @@ class ScatterChart(ChartBase):
def create( # type: ignore
cls,
*children,
- margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ScatterChart":
"""Create a chart component.
Args:
*children: The children of the chart component.
- margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
+ margin: The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "bottom": 5, "left": 5}
width: The width of chart container. String or Integer
height: The height of chart container.
+ on_click: The customized event handler of click on the component in this chart
+ on_mouse_enter: The customized event handler of mouseenter on the component in this chart
+ on_mouse_move: The customized event handler of mousemove on the component in this chart
+ on_mouse_leave: The customized event handler of mouseleave on the component in this chart
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -962,72 +741,46 @@ class FunnelChart(ChartBase):
cls,
*children,
layout: Optional[Union[Var[str], str]] = None,
- margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "FunnelChart":
"""Create a chart component.
Args:
*children: The children of the chart component.
- layout: The layout of bars in the chart. centeric
- margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}.
+ layout: The layout of bars in the chart. Default: "centric"
+ margin: The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "bottom": 5, "left": 5}
stroke: The stroke color of each bar. String | Object
width: The width of chart container. String or Integer
height: The height of chart container.
+ on_click: The customized event handler of click on the component in this chart
+ on_mouse_enter: The customized event handler of mouseenter on the component in this chart
+ on_mouse_move: The customized event handler of mousemove on the component in this chart
+ on_mouse_leave: The customized event handler of mouseleave on the component in this chart
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -1047,18 +800,19 @@ class Treemap(RechartsCharts):
def create( # type: ignore
cls,
*children,
- width: Optional[Union[Var[Union[int, str]], str, int]] = None,
- height: Optional[Union[Var[Union[int, str]], str, int]] = None,
- data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ width: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ height: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ name_key: Optional[Union[Var[str], str]] = None,
aspect_ratio: Optional[Union[Var[int], int]] = None,
is_animation_active: Optional[Union[Var[bool], bool]] = None,
animation_begin: Optional[Union[Var[int], int]] = None,
animation_duration: Optional[Union[Var[int], int]] = None,
animation_easing: Optional[
Union[
- Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]],
- Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"],
+ Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
+ Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
]
] = None,
style: Optional[Style] = None,
@@ -1066,73 +820,42 @@ class Treemap(RechartsCharts):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_animation_end: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_animation_start: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_animation_end: Optional[EventType[[], BASE_STATE]] = None,
+ on_animation_start: Optional[EventType[[], BASE_STATE]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Treemap":
"""Create a chart component.
Args:
*children: The children of the chart component.
- width: The width of chart container. String or Integer
- height: The height of chart container.
+ width: The width of chart container. String or Integer. Default: "100%"
+ height: The height of chart container. String or Integer. Default: "100%"
data: data of treemap. Array
- data_key: The key of a group of data which should be unique in a treemap. String | Number | Function
+ data_key: The key of a group of data which should be unique in a treemap. String | Number. Default: "value"
+ name_key: The key of each sector's name. String. Default: "name"
aspect_ratio: The treemap will try to keep every single rectangle's aspect ratio near the aspectRatio given. Number
- is_animation_active: If set false, animation of area will be disabled.
- animation_begin: Specifies when the animation should begin, the unit of this option is ms.
- animation_duration: Specifies the duration of animation, the unit of this option is ms.
- animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'
+ is_animation_active: If set false, animation of area will be disabled. Default: True
+ animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
+ animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
+ animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease"
+ on_animation_start: The customized event handler of animation start
+ on_animation_end: The customized event handler of animation end
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/recharts/general.py b/reflex/components/recharts/general.py
index 613e6fbf0..1769ea125 100644
--- a/reflex/components/recharts/general.py
+++ b/reflex/components/recharts/general.py
@@ -6,8 +6,8 @@ from typing import Any, Dict, List, Union
from reflex.components.component import MemoizationLeaf
from reflex.constants.colors import Color
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, no_args_event_spec
+from reflex.vars.base import LiteralVar, Var
from .recharts import (
LiteralAnimationEasing,
@@ -30,21 +30,24 @@ class ResponsiveContainer(Recharts, MemoizationLeaf):
# The aspect ratio of the container. The final aspect ratio of the SVG element will be (width / height) * aspect. Number
aspect: Var[int]
- # The width of chart container. Can be a number or string
+ # The width of chart container. Can be a number or string. Default: "100%"
width: Var[Union[int, str]]
- # The height of chart container. Number
+ # The height of chart container. Can be a number or string. Default: "100%"
height: Var[Union[int, str]]
- # The minimum width of chart container.
+ # The minimum width of chart container. Number
min_width: Var[int]
# The minimum height of chart container. Number
min_height: Var[int]
- # If specified a positive number, debounced function will be used to handle the resize event.
+ # If specified a positive number, debounced function will be used to handle the resize event. Default: 0
debounce: Var[int]
+ # If specified provides a callback providing the updated chart width and height values.
+ on_resize: EventHandler[no_args_event_spec]
+
# Valid children components
_valid_children: List[str] = [
"AreaChart",
@@ -73,21 +76,24 @@ class Legend(Recharts):
# The height of legend container. Number
height: Var[int]
- # The layout of legend items. 'horizontal' | 'vertical'
+ # The layout of legend items. 'horizontal' | 'vertical'. Default: "horizontal"
layout: Var[LiteralLayout]
- # The alignment of legend items in 'horizontal' direction, which can be 'left', 'center', 'right'.
+ # The alignment of legend items in 'horizontal' direction, which can be 'left', 'center', 'right'. Default: "center"
align: Var[LiteralLegendAlign]
- # The alignment of legend items in 'vertical' direction, which can be 'top', 'middle', 'bottom'.
+ # The alignment of legend items in 'vertical' direction, which can be 'top', 'middle', 'bottom'. Default: "bottom"
vertical_align: Var[LiteralVerticalAlign]
- # The size of icon in each legend item.
+ # The size of icon in each legend item. Default: 14
icon_size: Var[int]
# The type of icon in each legend item. 'line' | 'plainline' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye'
icon_type: Var[LiteralIconType]
+ # The source data of the content to be displayed in the legend, usually calculated internally. Default: []
+ payload: Var[List[Dict[str, Any]]]
+
# The width of chart container, usually calculated internally.
chart_width: Var[int]
@@ -98,28 +104,28 @@ class Legend(Recharts):
margin: Var[Dict[str, Any]]
# The customized event handler of click on the items in this group
- on_click: EventHandler[lambda: []]
+ on_click: EventHandler[no_args_event_spec]
# The customized event handler of mousedown on the items in this group
- on_mouse_down: EventHandler[lambda: []]
+ on_mouse_down: EventHandler[no_args_event_spec]
# The customized event handler of mouseup on the items in this group
- on_mouse_up: EventHandler[lambda: []]
+ on_mouse_up: EventHandler[no_args_event_spec]
# The customized event handler of mousemove on the items in this group
- on_mouse_move: EventHandler[lambda: []]
+ on_mouse_move: EventHandler[no_args_event_spec]
# The customized event handler of mouseover on the items in this group
- on_mouse_over: EventHandler[lambda: []]
+ on_mouse_over: EventHandler[no_args_event_spec]
# The customized event handler of mouseout on the items in this group
- on_mouse_out: EventHandler[lambda: []]
+ on_mouse_out: EventHandler[no_args_event_spec]
# The customized event handler of mouseenter on the items in this group
- on_mouse_enter: EventHandler[lambda: []]
+ on_mouse_enter: EventHandler[no_args_event_spec]
# The customized event handler of mouseleave on the items in this group
- on_mouse_leave: EventHandler[lambda: []]
+ on_mouse_leave: EventHandler[no_args_event_spec]
class GraphingTooltip(Recharts):
@@ -129,17 +135,17 @@ class GraphingTooltip(Recharts):
alias = "RechartsTooltip"
- # The separator between name and value.
+ # The separator between name and value. Default: ":"
separator: Var[str]
- # The offset size of tooltip. Number
+ # The offset size of tooltip. Number. Default: 10
offset: Var[int]
- # When an item of the payload has value null or undefined, this item won't be displayed.
+ # When an item of the payload has value null or undefined, this item won't be displayed. Default: True
filter_null: Var[bool]
- # If set false, no cursor will be drawn when tooltip is active.
- cursor: Var[Union[Dict[str, Any], bool]] = Var.create_safe(
+ # If set false, no cursor will be drawn when tooltip is active. Default: {"strokeWidth": 1, "fill": rx.color("gray", 3)}
+ cursor: Var[Union[Dict[str, Any], bool]] = LiteralVar.create(
{
"strokeWidth": 1,
"fill": Color("gray", 3),
@@ -149,17 +155,18 @@ class GraphingTooltip(Recharts):
# The box of viewing area, which has the shape of {x: someVal, y: someVal, width: someVal, height: someVal}, usually calculated internally.
view_box: Var[Dict[str, Any]]
- # The style of default tooltip content item which is a li element. DEFAULT: {}
- item_style: Var[Dict[str, Any]] = Var.create_safe(
+ # The style of default tooltip content item which is a li element. Default: {"color": rx.color("gray", 12)}
+ item_style: Var[Dict[str, Any]] = LiteralVar.create(
{
"color": Color("gray", 12),
}
)
- # The style of tooltip wrapper which is a dom element. DEFAULT: {}
+ # The style of tooltip wrapper which is a dom element. Default: {}
wrapper_style: Var[Dict[str, Any]]
- # The style of tooltip content which is a dom element. DEFAULT: {}
- content_style: Var[Dict[str, Any]] = Var.create_safe(
+
+ # The style of tooltip content which is a dom element. Default: {"background": rx.color("gray", 1), "borderColor": rx.color("gray", 4), "borderRadius": "8px"}
+ content_style: Var[Dict[str, Any]] = LiteralVar.create(
{
"background": Color("gray", 1),
"borderColor": Color("gray", 4),
@@ -167,30 +174,28 @@ class GraphingTooltip(Recharts):
}
)
- # The style of default tooltip label which is a p element. DEFAULT: {}
- label_style: Var[Dict[str, Any]] = Var.create_safe({"color": Color("gray", 11)})
+ # The style of default tooltip label which is a p element. Default: {"color": rx.color("gray", 11)}
+ label_style: Var[Dict[str, Any]] = LiteralVar.create({"color": Color("gray", 11)})
- # This option allows the tooltip to extend beyond the viewBox of the chart itself. DEFAULT: { x: false, y: false }
- allow_escape_view_box: Var[Dict[str, bool]] = Var.create_safe(
- {"x": False, "y": False}
- )
+ # This option allows the tooltip to extend beyond the viewBox of the chart itself. Default: {"x": False, "y": False}
+ allow_escape_view_box: Var[Dict[str, bool]]
- # If set true, the tooltip is displayed. If set false, the tooltip is hidden, usually calculated internally.
+ # If set true, the tooltip is displayed. If set false, the tooltip is hidden, usually calculated internally. Default: False
active: Var[bool]
# If this field is set, the tooltip position will be fixed and will not move anymore.
position: Var[Dict[str, Any]]
- # The coordinate of tooltip which is usually calculated internally.
+ # The coordinate of tooltip which is usually calculated internally. Default: {"x": 0, "y": 0}
coordinate: Var[Dict[str, Any]]
- # If set false, animation of tooltip will be disabled. DEFAULT: true in CSR, and false in SSR
+ # If set false, animation of tooltip will be disabled. Default: True
is_animation_active: Var[bool]
- # Specifies the duration of animation, the unit of this option is ms. DEFAULT: 1500
+ # Specifies the duration of animation, the unit of this option is ms. Default: 1500
animation_duration: Var[int]
- # The type of easing function. DEFAULT: 'ease'
+ # The type of easing function. Default: "ease"
animation_easing: Var[LiteralAnimationEasing]
@@ -224,17 +229,17 @@ class LabelList(Recharts):
# The key of a group of label values in data.
data_key: Var[Union[str, int]]
- # The position of each label relative to it view box。"Top" | "left" | "right" | "bottom" | "inside" | "outside" | "insideLeft" | "insideRight" | "insideTop" | "insideBottom" | "insideTopLeft" | "insideBottomLeft" | "insideTopRight" | "insideBottomRight" | "insideStart" | "insideEnd" | "end" | "center"
+ # The position of each label relative to it view box. "Top" | "left" | "right" | "bottom" | "inside" | "outside" | "insideLeft" | "insideRight" | "insideTop" | "insideBottom" | "insideTopLeft" | "insideBottomLeft" | "insideTopRight" | "insideBottomRight" | "insideStart" | "insideEnd" | "end" | "center"
position: Var[LiteralPosition]
- # The offset to the specified "position"
+ # The offset to the specified "position". Default: 5
offset: Var[int]
- # The fill color of each label
- fill: Var[Union[str, Color]] = Var.create_safe(Color("gray", 10))
+ # The fill color of each label. Default: rx.color("gray", 10)
+ fill: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 10))
- # The stroke color of each label
- stroke: Var[Union[str, Color]] = Var.create_safe("none", _var_is_string=True)
+ # The stroke color of each label. Default: "none"
+ stroke: Var[Union[str, Color]] = LiteralVar.create("none")
responsive_container = ResponsiveContainer.create
diff --git a/reflex/components/recharts/general.pyi b/reflex/components/recharts/general.pyi
index 9dd2ae19c..823a50fce 100644
--- a/reflex/components/recharts/general.pyi
+++ b/reflex/components/recharts/general.pyi
@@ -3,17 +3,15 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Union, overload
from reflex.components.component import MemoizationLeaf
from reflex.constants.colors import Color
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
-from .recharts import (
- Recharts,
-)
+from .recharts import Recharts
class ResponsiveContainer(Recharts, MemoizationLeaf):
@overload
@@ -32,52 +30,23 @@ class ResponsiveContainer(Recharts, MemoizationLeaf):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_resize: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "ResponsiveContainer":
"""Create a new memoization leaf component.
@@ -85,11 +54,12 @@ class ResponsiveContainer(Recharts, MemoizationLeaf):
Args:
*children: The children of the component.
aspect: The aspect ratio of the container. The final aspect ratio of the SVG element will be (width / height) * aspect. Number
- width: The width of chart container. Can be a number or string
- height: The height of chart container. Number
- min_width: The minimum width of chart container.
+ width: The width of chart container. Can be a number or string. Default: "100%"
+ height: The height of chart container. Can be a number or string. Default: "100%"
+ min_width: The minimum width of chart container. Number
min_height: The minimum height of chart container. Number
- debounce: If specified a positive number, debounced function will be used to handle the resize event.
+ debounce: If specified a positive number, debounced function will be used to handle the resize event. Default: 0
+ on_resize: If specified provides a callback providing the updated chart width and height values.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -113,107 +83,80 @@ class Legend(Recharts):
height: Optional[Union[Var[int], int]] = None,
layout: Optional[
Union[
- Var[Literal["horizontal", "vertical"]],
Literal["horizontal", "vertical"],
+ Var[Literal["horizontal", "vertical"]],
]
] = None,
align: Optional[
Union[
- Var[Literal["left", "center", "right"]],
- Literal["left", "center", "right"],
+ Literal["center", "left", "right"],
+ Var[Literal["center", "left", "right"]],
]
] = None,
vertical_align: Optional[
Union[
- Var[Literal["top", "middle", "bottom"]],
- Literal["top", "middle", "bottom"],
+ Literal["bottom", "middle", "top"],
+ Var[Literal["bottom", "middle", "top"]],
]
] = None,
icon_size: Optional[Union[Var[int], int]] = None,
icon_type: Optional[
Union[
+ Literal[
+ "circle",
+ "cross",
+ "diamond",
+ "line",
+ "plainline",
+ "rect",
+ "square",
+ "star",
+ "triangle",
+ "wye",
+ ],
Var[
Literal[
- "line",
- "plainline",
- "square",
- "rect",
"circle",
"cross",
"diamond",
+ "line",
+ "plainline",
+ "rect",
+ "square",
"star",
"triangle",
"wye",
]
],
- Literal[
- "line",
- "plainline",
- "square",
- "rect",
- "circle",
- "cross",
- "diamond",
- "star",
- "triangle",
- "wye",
- ],
]
] = None,
+ payload: Optional[
+ Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]
+ ] = None,
chart_width: Optional[Union[Var[int], int]] = None,
chart_height: Optional[Union[Var[int], int]] = None,
- margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
+ margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Legend":
"""Create the component.
@@ -222,14 +165,23 @@ class Legend(Recharts):
*children: The children of the component.
width: The width of legend container. Number
height: The height of legend container. Number
- layout: The layout of legend items. 'horizontal' | 'vertical'
- align: The alignment of legend items in 'horizontal' direction, which can be 'left', 'center', 'right'.
- vertical_align: The alignment of legend items in 'vertical' direction, which can be 'top', 'middle', 'bottom'.
- icon_size: The size of icon in each legend item.
+ layout: The layout of legend items. 'horizontal' | 'vertical'. Default: "horizontal"
+ align: The alignment of legend items in 'horizontal' direction, which can be 'left', 'center', 'right'. Default: "center"
+ vertical_align: The alignment of legend items in 'vertical' direction, which can be 'top', 'middle', 'bottom'. Default: "bottom"
+ icon_size: The size of icon in each legend item. Default: 14
icon_type: The type of icon in each legend item. 'line' | 'plainline' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye'
+ payload: The source data of the content to be displayed in the legend, usually calculated internally. Default: []
chart_width: The width of chart container, usually calculated internally.
chart_height: The height of chart container, usually calculated internally.
margin: The margin of chart container, usually calculated internally.
+ on_click: The customized event handler of click on the items in this group
+ on_mouse_down: The customized event handler of mousedown on the items in this group
+ on_mouse_up: The customized event handler of mouseup on the items in this group
+ on_mouse_move: The customized event handler of mousemove on the items in this group
+ on_mouse_over: The customized event handler of mouseover on the items in this group
+ on_mouse_out: The customized event handler of mouseout on the items in this group
+ on_mouse_enter: The customized event handler of mouseenter on the items in this group
+ on_mouse_leave: The customized event handler of mouseleave on the items in this group
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -253,25 +205,25 @@ class GraphingTooltip(Recharts):
offset: Optional[Union[Var[int], int]] = None,
filter_null: Optional[Union[Var[bool], bool]] = None,
cursor: Optional[
- Union[Var[Union[Dict[str, Any], bool]], Dict[str, Any], bool]
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool]
] = None,
- view_box: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
- item_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
- wrapper_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
- content_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
- label_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
+ view_box: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
+ item_style: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
+ wrapper_style: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
+ content_style: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
+ label_style: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
allow_escape_view_box: Optional[
- Union[Var[Dict[str, bool]], Dict[str, bool]]
+ Union[Dict[str, bool], Var[Dict[str, bool]]]
] = None,
active: Optional[Union[Var[bool], bool]] = None,
- position: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
- coordinate: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
+ position: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
+ coordinate: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
is_animation_active: Optional[Union[Var[bool], bool]] = None,
animation_duration: Optional[Union[Var[int], int]] = None,
animation_easing: Optional[
Union[
- Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]],
- Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"],
+ Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
+ Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
]
] = None,
style: Optional[Style] = None,
@@ -279,74 +231,44 @@ class GraphingTooltip(Recharts):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "GraphingTooltip":
"""Create the component.
Args:
*children: The children of the component.
- separator: The separator between name and value.
- offset: The offset size of tooltip. Number
- filter_null: When an item of the payload has value null or undefined, this item won't be displayed.
- cursor: If set false, no cursor will be drawn when tooltip is active.
+ separator: The separator between name and value. Default: ":"
+ offset: The offset size of tooltip. Number. Default: 10
+ filter_null: When an item of the payload has value null or undefined, this item won't be displayed. Default: True
+ cursor: If set false, no cursor will be drawn when tooltip is active. Default: {"strokeWidth": 1, "fill": rx.color("gray", 3)}
view_box: The box of viewing area, which has the shape of {x: someVal, y: someVal, width: someVal, height: someVal}, usually calculated internally.
- item_style: The style of default tooltip content item which is a li element. DEFAULT: {}
- wrapper_style: The style of tooltip wrapper which is a dom element. DEFAULT: {}
- content_style: The style of tooltip content which is a dom element. DEFAULT: {}
- label_style: The style of default tooltip label which is a p element. DEFAULT: {}
- allow_escape_view_box: This option allows the tooltip to extend beyond the viewBox of the chart itself. DEFAULT: { x: false, y: false }
- active: If set true, the tooltip is displayed. If set false, the tooltip is hidden, usually calculated internally.
+ item_style: The style of default tooltip content item which is a li element. Default: {"color": rx.color("gray", 12)}
+ wrapper_style: The style of tooltip wrapper which is a dom element. Default: {}
+ content_style: The style of tooltip content which is a dom element. Default: {"background": rx.color("gray", 1), "borderColor": rx.color("gray", 4), "borderRadius": "8px"}
+ label_style: The style of default tooltip label which is a p element. Default: {"color": rx.color("gray", 11)}
+ allow_escape_view_box: This option allows the tooltip to extend beyond the viewBox of the chart itself. Default: {"x": False, "y": False}
+ active: If set true, the tooltip is displayed. If set false, the tooltip is hidden, usually calculated internally. Default: False
position: If this field is set, the tooltip position will be fixed and will not move anymore.
- coordinate: The coordinate of tooltip which is usually calculated internally.
- is_animation_active: If set false, animation of tooltip will be disabled. DEFAULT: true in CSR, and false in SSR
- animation_duration: Specifies the duration of animation, the unit of this option is ms. DEFAULT: 1500
- animation_easing: The type of easing function. DEFAULT: 'ease'
+ coordinate: The coordinate of tooltip which is usually calculated internally. Default: {"x": 0, "y": 0}
+ is_animation_active: If set false, animation of tooltip will be disabled. Default: True
+ animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
+ animation_easing: The type of easing function. Default: "ease"
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -366,52 +288,52 @@ class Label(Recharts):
def create( # type: ignore
cls,
*children,
- view_box: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
+ view_box: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None,
value: Optional[Union[Var[str], str]] = None,
offset: Optional[Union[Var[int], int]] = None,
position: Optional[
Union[
- Var[
- Literal[
- "top",
- "left",
- "right",
- "bottom",
- "inside",
- "outside",
- "insideLeft",
- "insideRight",
- "insideTop",
- "insideBottom",
- "insideTopLeft",
- "insideBottomLeft",
- "insideTopRight",
- "insideBottomRight",
- "insideStart",
- "insideEnd",
- "end",
- "center",
- ]
- ],
Literal[
- "top",
- "left",
- "right",
"bottom",
+ "center",
+ "end",
"inside",
- "outside",
+ "insideBottom",
+ "insideBottomLeft",
+ "insideBottomRight",
+ "insideEnd",
"insideLeft",
"insideRight",
- "insideTop",
- "insideBottom",
- "insideTopLeft",
- "insideBottomLeft",
- "insideTopRight",
- "insideBottomRight",
"insideStart",
- "insideEnd",
- "end",
- "center",
+ "insideTop",
+ "insideTopLeft",
+ "insideTopRight",
+ "left",
+ "outside",
+ "right",
+ "top",
+ ],
+ Var[
+ Literal[
+ "bottom",
+ "center",
+ "end",
+ "inside",
+ "insideBottom",
+ "insideBottomLeft",
+ "insideBottomRight",
+ "insideEnd",
+ "insideLeft",
+ "insideRight",
+ "insideStart",
+ "insideTop",
+ "insideTopLeft",
+ "insideTopRight",
+ "left",
+ "outside",
+ "right",
+ "top",
+ ]
],
]
] = None,
@@ -420,52 +342,22 @@ class Label(Recharts):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Label":
"""Create the component.
@@ -495,107 +387,77 @@ class LabelList(Recharts):
def create( # type: ignore
cls,
*children,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
position: Optional[
Union[
- Var[
- Literal[
- "top",
- "left",
- "right",
- "bottom",
- "inside",
- "outside",
- "insideLeft",
- "insideRight",
- "insideTop",
- "insideBottom",
- "insideTopLeft",
- "insideBottomLeft",
- "insideTopRight",
- "insideBottomRight",
- "insideStart",
- "insideEnd",
- "end",
- "center",
- ]
- ],
Literal[
- "top",
- "left",
- "right",
"bottom",
+ "center",
+ "end",
"inside",
- "outside",
+ "insideBottom",
+ "insideBottomLeft",
+ "insideBottomRight",
+ "insideEnd",
"insideLeft",
"insideRight",
- "insideTop",
- "insideBottom",
- "insideTopLeft",
- "insideBottomLeft",
- "insideTopRight",
- "insideBottomRight",
"insideStart",
- "insideEnd",
- "end",
- "center",
+ "insideTop",
+ "insideTopLeft",
+ "insideTopRight",
+ "left",
+ "outside",
+ "right",
+ "top",
+ ],
+ Var[
+ Literal[
+ "bottom",
+ "center",
+ "end",
+ "inside",
+ "insideBottom",
+ "insideBottomLeft",
+ "insideBottomRight",
+ "insideEnd",
+ "insideLeft",
+ "insideRight",
+ "insideStart",
+ "insideTop",
+ "insideTopLeft",
+ "insideTopRight",
+ "left",
+ "outside",
+ "right",
+ "top",
+ ]
],
]
] = None,
offset: Optional[Union[Var[int], int]] = None,
- fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "LabelList":
"""Create the component.
@@ -603,10 +465,10 @@ class LabelList(Recharts):
Args:
*children: The children of the component.
data_key: The key of a group of label values in data.
- position: The position of each label relative to it view box。"Top" | "left" | "right" | "bottom" | "inside" | "outside" | "insideLeft" | "insideRight" | "insideTop" | "insideBottom" | "insideTopLeft" | "insideBottomLeft" | "insideTopRight" | "insideBottomRight" | "insideStart" | "insideEnd" | "end" | "center"
- offset: The offset to the specified "position"
- fill: The fill color of each label
- stroke: The stroke color of each label
+ position: The position of each label relative to it view box. "Top" | "left" | "right" | "bottom" | "inside" | "outside" | "insideLeft" | "insideRight" | "insideTop" | "insideBottom" | "insideTopLeft" | "insideBottomLeft" | "insideTopRight" | "insideBottomRight" | "insideStart" | "insideEnd" | "end" | "center"
+ offset: The offset to the specified "position". Default: 5
+ fill: The fill color of each label. Default: rx.color("gray", 10)
+ stroke: The stroke color of each label. Default: "none"
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/recharts/polar.py b/reflex/components/recharts/polar.py
index 64fa00ecd..1f4974d4c 100644
--- a/reflex/components/recharts/polar.py
+++ b/reflex/components/recharts/polar.py
@@ -6,13 +6,14 @@ from typing import Any, Dict, List, Union
from reflex.constants import EventTriggers
from reflex.constants.colors import Color
-from reflex.event import EventHandler
-from reflex.vars import Var
+from reflex.event import EventHandler, no_args_event_spec
+from reflex.vars.base import LiteralVar, Var
from .recharts import (
LiteralAnimationEasing,
LiteralGridType,
LiteralLegendType,
+ LiteralOrientationLeftRightMiddle,
LiteralPolarRadiusType,
LiteralScale,
Recharts,
@@ -26,56 +27,74 @@ class Pie(Recharts):
alias = "RechartsPie"
- # data
+ # The source data which each element is an object.
data: Var[List[Dict[str, Any]]]
# The key of each sector's value.
data_key: Var[Union[str, int]]
- # The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width.
+ # The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width. Default: "50%"
cx: Var[Union[int, str]]
- # The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height.
+ # The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height. Default: "50%"
cy: Var[Union[int, str]]
- # The inner radius of pie, which can be set to a percent value.
+ # The inner radius of pie, which can be set to a percent value. Default: 0
inner_radius: Var[Union[int, str]]
- # The outer radius of pie, which can be set to a percent value.
+ # The outer radius of pie, which can be set to a percent value. Default: "80%"
outer_radius: Var[Union[int, str]]
- # The angle of first sector.
+ # The angle of first sector. Default: 0
start_angle: Var[int]
- # The direction of sectors. 1 means clockwise and -1 means anticlockwise.
+ # The end angle of last sector, which should be unequal to start_angle. Default: 360
end_angle: Var[int]
- # The minimum angle of each unzero data.
+ # The minimum angle of each unzero data. Default: 0
min_angle: Var[int]
- # The angle between two sectors.
+ # The angle between two sectors. Default: 0
padding_angle: Var[int]
- # The key of each sector's name.
+ # The key of each sector's name. Default: "name"
name_key: Var[str]
- # The type of icon in legend. If set to 'none', no legend item will be rendered.
+ # The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect"
legend_type: Var[LiteralLegendType]
- # If false set, labels will not be drawn.
+ # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
label: Var[bool] = False # type: ignore
- # If false set, label lines will not be drawn.
+ # If false set, label lines will not be drawn. If true set, label lines will be drawn which have the props calculated internally. Default: False
label_line: Var[bool]
+ # The index of active sector in Pie, this option can be changed in mouse event handlers.
+ data: Var[List[Dict[str, Any]]]
+
# Valid children components
_valid_children: List[str] = ["Cell", "LabelList"]
- # Stoke color
- stroke: Var[Union[str, Color]] = Var.create_safe(Color("accent", 9))
+ # Stoke color. Default: rx.color("accent", 9)
+ stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9))
- # Fill color
- fill: Var[Union[str, Color]] = Var.create_safe(Color("accent", 3))
+ # Fill color. Default: rx.color("accent", 3)
+ fill: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 3))
+
+ # If set false, animation of tooltip will be disabled. Default: true in CSR, and false in SSR
+ is_animation_active: Var[bool]
+
+ # Specifies when the animation should begin, the unit of this option is ms. Default: 400
+ animation_begin: Var[int]
+
+ # Specifies the duration of animation, the unit of this option is ms. Default: 1500
+ animation_duration: Var[int]
+
+ # The type of easing function. Default: "ease"
+ animation_easing: Var[LiteralAnimationEasing]
+
+ # The tabindex of wrapper surrounding the cells. Default: 0
+ root_tab_index: Var[int]
def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
"""Get the event triggers that pass the component's value to the handler.
@@ -84,12 +103,14 @@ class Pie(Recharts):
A dict mapping the event trigger to the var that is passed to the handler.
"""
return {
- EventTriggers.ON_CLICK: lambda: [],
- EventTriggers.ON_MOUSE_MOVE: lambda: [],
- EventTriggers.ON_MOUSE_OVER: lambda: [],
- EventTriggers.ON_MOUSE_OUT: lambda: [],
- EventTriggers.ON_MOUSE_ENTER: lambda: [],
- EventTriggers.ON_MOUSE_LEAVE: lambda: [],
+ EventTriggers.ON_ANIMATION_START: no_args_event_spec,
+ EventTriggers.ON_ANIMATION_END: no_args_event_spec,
+ EventTriggers.ON_CLICK: no_args_event_spec,
+ EventTriggers.ON_MOUSE_MOVE: no_args_event_spec,
+ EventTriggers.ON_MOUSE_OVER: no_args_event_spec,
+ EventTriggers.ON_MOUSE_OUT: no_args_event_spec,
+ EventTriggers.ON_MOUSE_ENTER: no_args_event_spec,
+ EventTriggers.ON_MOUSE_LEAVE: no_args_event_spec,
}
@@ -103,39 +124,53 @@ class Radar(Recharts):
# The key of a group of data which should be unique in a radar chart.
data_key: Var[Union[str, int]]
- # The coordinates of all the vertexes of the radar shape, like [{ x, y }].
+ # The coordinates of all the vertices of the radar shape, like [{ x, y }].
points: Var[List[Dict[str, Any]]]
- # If false set, dots will not be drawn
+ # If false set, dots will not be drawn. Default: True
dot: Var[bool]
- # Stoke color
- stroke: Var[Union[str, Color]] = Var.create_safe(Color("accent", 9))
+ # Stoke color. Default: rx.color("accent", 9)
+ stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9))
- # Fill color
- fill: Var[str] = Var.create_safe(Color("accent", 3))
+ # Fill color. Default: rx.color("accent", 3)
+ fill: Var[str] = LiteralVar.create(Color("accent", 3))
- # opacity
- fill_opacity: Var[float] = Var.create_safe(0.6)
+ # The opacity to fill the chart. Default: 0.6
+ fill_opacity: Var[float] = LiteralVar.create(0.6)
- # The type of icon in legend. If set to 'none', no legend item will be rendered.
- legend_type: Var[str]
+ # The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect"
+ legend_type: Var[LiteralLegendType]
- # If false set, labels will not be drawn
+ # If false set, labels will not be drawn. Default: True
label: Var[bool]
- # Specifies when the animation should begin, the unit of this option is ms.
+ # If set false, animation of polygon will be disabled. Default: True in CSR, and False in SSR
+ is_animation_active: Var[bool]
+
+ # Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_begin: Var[int]
- # Specifies the duration of animation, the unit of this option is ms.
+ # Specifies the duration of animation, the unit of this option is ms. Default: 1500
animation_duration: Var[int]
- # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'
+ # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease"
animation_easing: Var[LiteralAnimationEasing]
# Valid children components
_valid_children: List[str] = ["LabelList"]
+ def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
+ """Get the event triggers that pass the component's value to the handler.
+
+ Returns:
+ A dict mapping the event trigger to the var that is passed to the handler.
+ """
+ return {
+ EventTriggers.ON_ANIMATION_START: no_args_event_spec,
+ EventTriggers.ON_ANIMATION_END: no_args_event_spec,
+ }
+
class RadialBar(Recharts):
"""A RadialBar chart component in Recharts."""
@@ -144,31 +179,34 @@ class RadialBar(Recharts):
alias = "RechartsRadialBar"
+ # The source data which each element is an object.
+ data: Var[List[Dict[str, Any]]]
+
# The key of a group of data which should be unique to show the meaning of angle axis.
data_key: Var[Union[str, int]]
- # Min angle of each bar. A positive value between 0 and 360.
+ # Min angle of each bar. A positive value between 0 and 360. Default: 0
min_angle: Var[int]
- # Type of legend
- legend_type: Var[str]
+ # The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect"
+ legend_type: Var[LiteralLegendType]
- # If false set, labels will not be drawn.
+ # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
label: Var[Union[bool, Dict[str, Any]]]
- # If false set, background sector will not be drawn.
+ # If false set, background sector will not be drawn. Default: False
background: Var[Union[bool, Dict[str, Any]]]
- # If set false, animation of radial bars will be disabled. By default true in CSR, and false in SSR
+ # If set false, animation of radial bars will be disabled. Default: True
is_animation_active: Var[bool]
- # Specifies when the animation should begin, the unit of this option is ms. By default 0
+ # Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_begin: Var[int]
- # Specifies the duration of animation, the unit of this option is ms. By default 1500
+ # Specifies the duration of animation, the unit of this option is ms. Default 1500
animation_duration: Var[int]
- # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. By default 'ease'
+ # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease"
animation_easing: Var[LiteralAnimationEasing]
# Valid children components
@@ -181,14 +219,14 @@ class RadialBar(Recharts):
A dict mapping the event trigger to the var that is passed to the handler.
"""
return {
- EventTriggers.ON_CLICK: lambda: [],
- EventTriggers.ON_MOUSE_MOVE: lambda: [],
- EventTriggers.ON_MOUSE_OVER: lambda: [],
- EventTriggers.ON_MOUSE_OUT: lambda: [],
- EventTriggers.ON_MOUSE_ENTER: lambda: [],
- EventTriggers.ON_MOUSE_LEAVE: lambda: [],
- EventTriggers.ON_ANIMATION_START: lambda: [],
- EventTriggers.ON_ANIMATION_END: lambda: [],
+ EventTriggers.ON_CLICK: no_args_event_spec,
+ EventTriggers.ON_MOUSE_MOVE: no_args_event_spec,
+ EventTriggers.ON_MOUSE_OVER: no_args_event_spec,
+ EventTriggers.ON_MOUSE_OUT: no_args_event_spec,
+ EventTriggers.ON_MOUSE_ENTER: no_args_event_spec,
+ EventTriggers.ON_MOUSE_LEAVE: no_args_event_spec,
+ EventTriggers.ON_ANIMATION_START: no_args_event_spec,
+ EventTriggers.ON_ANIMATION_END: no_args_event_spec,
}
@@ -211,56 +249,56 @@ class PolarAngleAxis(Recharts):
# The outer radius of circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy.
radius: Var[Union[int, str]]
- # If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option.
+ # If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. Default: True
axis_line: Var[Union[bool, Dict[str, Any]]]
- # The type of axis line.
- axis_line_type: Var[str]
+ # The type of axis line. Default: "polygon"
+ axis_line_type: Var[LiteralGridType]
- # If false set, tick lines will not be drawn. If true set, tick lines will be drawn which have the props calculated internally. If object set, tick lines will be drawn which have the props mergered by the internal calculated props and the option.
- tick_line: Var[Union[bool, Dict[str, Any]]] = Var.create_safe(False)
+ # If false set, tick lines will not be drawn. If true set, tick lines will be drawn which have the props calculated internally. If object set, tick lines will be drawn which have the props mergered by the internal calculated props and the option. Default: False
+ tick_line: Var[Union[bool, Dict[str, Any]]] = LiteralVar.create(False)
- # The width or height of tick.
- tick: Var[Union[int, str]]
+ # If false set, ticks will not be drawn. If true set, ticks will be drawn which have the props calculated internally. If object set, ticks will be drawn which have the props mergered by the internal calculated props and the option. Default: True
+ tick: Var[Union[bool, Dict[str, Any]]]
# The array of every tick's value and angle.
ticks: Var[List[Dict[str, Any]]]
- # The orientation of axis text.
- orient: Var[str]
+ # The orientation of axis text. Default: "outer"
+ orientation: Var[str]
- # The stroke color of axis
- stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 10))
+ # The stroke color of axis. Default: rx.color("gray", 10)
+ stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 10))
- # Allow the axis has duplicated categorys or not when the type of axis is "category".
+ # Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True
allow_duplicated_category: Var[bool]
# Valid children components.
_valid_children: List[str] = ["Label"]
# The customized event handler of click on the ticks of this axis.
- on_click: EventHandler[lambda: []]
+ on_click: EventHandler[no_args_event_spec]
# The customized event handler of mousedown on the the ticks of this axis.
- on_mouse_down: EventHandler[lambda: []]
+ on_mouse_down: EventHandler[no_args_event_spec]
# The customized event handler of mouseup on the ticks of this axis.
- on_mouse_up: EventHandler[lambda: []]
+ on_mouse_up: EventHandler[no_args_event_spec]
# The customized event handler of mousemove on the ticks of this axis.
- on_mouse_move: EventHandler[lambda: []]
+ on_mouse_move: EventHandler[no_args_event_spec]
# The customized event handler of mouseover on the ticks of this axis.
- on_mouse_over: EventHandler[lambda: []]
+ on_mouse_over: EventHandler[no_args_event_spec]
# The customized event handler of mouseout on the ticks of this axis.
- on_mouse_out: EventHandler[lambda: []]
+ on_mouse_out: EventHandler[no_args_event_spec]
# The customized event handler of moustenter on the ticks of this axis.
- on_mouse_enter: EventHandler[lambda: []]
+ on_mouse_enter: EventHandler[no_args_event_spec]
# The customized event handler of mouseleave on the ticks of this axis.
- on_mouse_leave: EventHandler[lambda: []]
+ on_mouse_leave: EventHandler[no_args_event_spec]
class PolarGrid(Recharts):
@@ -270,17 +308,17 @@ class PolarGrid(Recharts):
alias = "RechartsPolarGrid"
- # The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width.
- cx: Var[Union[int, str]]
+ # The x-coordinate of center.
+ cx: Var[int]
- # The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height.
- cy: Var[Union[int, str]]
+ # The y-coordinate of center.
+ cy: Var[int]
# The radius of the inner polar grid.
- inner_radius: Var[Union[int, str]]
+ inner_radius: Var[int]
# The radius of the outer polar grid.
- outer_radius: Var[Union[int, str]]
+ outer_radius: Var[int]
# The array of every line grid's angle.
polar_angles: Var[List[int]]
@@ -288,11 +326,11 @@ class PolarGrid(Recharts):
# The array of every line grid's radius.
polar_radius: Var[List[int]]
- # The type of polar grids. 'polygon' | 'circle'
+ # The type of polar grids. 'polygon' | 'circle'. Default: "polygon"
grid_type: Var[LiteralGridType]
- # The stroke color of grid
- stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 10))
+ # The stroke color of grid. Default: rx.color("gray", 10)
+ stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 10))
# Valid children components
_valid_children: List[str] = ["RadarChart", "RadiarBarChart"]
@@ -305,47 +343,47 @@ class PolarRadiusAxis(Recharts):
alias = "RechartsPolarRadiusAxis"
- # The angle of radial direction line to display axis text.
+ # The angle of radial direction line to display axis text. Default: 0
angle: Var[int]
- # The type of axis line. 'number' | 'category'
+ # The type of axis line. 'number' | 'category'. Default: "category"
type_: Var[LiteralPolarRadiusType]
- # Allow the axis has duplicated categorys or not when the type of axis is "category".
+ # Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True
allow_duplicated_category: Var[bool]
# The x-coordinate of center.
- cx: Var[Union[int, str]]
+ cx: Var[int]
# The y-coordinate of center.
- cy: Var[Union[int, str]]
+ cy: Var[int]
- # If set to true, the ticks of this axis are reversed.
+ # If set to true, the ticks of this axis are reversed. Default: False
reversed: Var[bool]
- # The orientation of axis text.
- orientation: Var[str]
+ # The orientation of axis text. Default: "right"
+ orientation: Var[LiteralOrientationLeftRightMiddle]
- # If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option.
+ # If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. Default: True
axis_line: Var[Union[bool, Dict[str, Any]]]
- # The width or height of tick.
- tick: Var[Union[int, str]]
+ # If false set, ticks will not be drawn. If true set, ticks will be drawn which have the props calculated internally. If object set, ticks will be drawn which have the props mergered by the internal calculated props and the option. Default: True
+ tick: Var[Union[bool, Dict[str, Any]]]
- # The count of ticks.
+ # The count of axis ticks. Not used if 'type' is 'category'. Default: 5
tick_count: Var[int]
- # If 'auto' set, the scale funtion is linear scale. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'
+ # If 'auto' set, the scale function is linear scale. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto"
scale: Var[LiteralScale]
# Valid children components
_valid_children: List[str] = ["Label"]
- # The domain of the polar radius axis, specifying the minimum and maximum values.
- domain: Var[List[int]] = Var.create_safe([0, 250])
+ # The domain of the polar radius axis, specifying the minimum and maximum values. Default: [0, "auto"]
+ domain: Var[List[Union[int, str]]]
- # The stroke color of axis
- stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 10))
+ # The stroke color of axis. Default: rx.color("gray", 10)
+ stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 10))
def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
"""Get the event triggers that pass the component's value to the handler.
@@ -354,12 +392,12 @@ class PolarRadiusAxis(Recharts):
A dict mapping the event trigger to the var that is passed to the handler.
"""
return {
- EventTriggers.ON_CLICK: lambda: [],
- EventTriggers.ON_MOUSE_MOVE: lambda: [],
- EventTriggers.ON_MOUSE_OVER: lambda: [],
- EventTriggers.ON_MOUSE_OUT: lambda: [],
- EventTriggers.ON_MOUSE_ENTER: lambda: [],
- EventTriggers.ON_MOUSE_LEAVE: lambda: [],
+ EventTriggers.ON_CLICK: no_args_event_spec,
+ EventTriggers.ON_MOUSE_MOVE: no_args_event_spec,
+ EventTriggers.ON_MOUSE_OVER: no_args_event_spec,
+ EventTriggers.ON_MOUSE_OUT: no_args_event_spec,
+ EventTriggers.ON_MOUSE_ENTER: no_args_event_spec,
+ EventTriggers.ON_MOUSE_LEAVE: no_args_event_spec,
}
diff --git a/reflex/components/recharts/polar.pyi b/reflex/components/recharts/polar.pyi
index d91186296..5388fbcf2 100644
--- a/reflex/components/recharts/polar.pyi
+++ b/reflex/components/recharts/polar.pyi
@@ -3,16 +3,14 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Union, overload
from reflex.constants.colors import Color
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
-from .recharts import (
- Recharts,
-)
+from .recharts import Recharts
class Pie(Recharts):
def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ...
@@ -21,8 +19,8 @@ class Pie(Recharts):
def create( # type: ignore
cls,
*children,
- data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
cx: Optional[Union[Var[Union[int, str]], int, str]] = None,
cy: Optional[Union[Var[Union[int, str]], int, str]] = None,
inner_radius: Optional[Union[Var[Union[int, str]], int, str]] = None,
@@ -34,86 +32,91 @@ class Pie(Recharts):
name_key: Optional[Union[Var[str], str]] = None,
legend_type: Optional[
Union[
- Var[
- Literal[
- "line",
- "plainline",
- "square",
- "rect",
- "circle",
- "cross",
- "diamond",
- "star",
- "triangle",
- "wye",
- "none",
- ]
- ],
Literal[
- "line",
- "plainline",
- "square",
- "rect",
"circle",
"cross",
"diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
"star",
"triangle",
"wye",
- "none",
+ ],
+ Var[
+ Literal[
+ "circle",
+ "cross",
+ "diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
+ "star",
+ "triangle",
+ "wye",
+ ]
],
]
] = None,
label: Optional[Union[Var[bool], bool]] = None,
label_line: Optional[Union[Var[bool], bool]] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
- fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
+ is_animation_active: Optional[Union[Var[bool], bool]] = None,
+ animation_begin: Optional[Union[Var[int], int]] = None,
+ animation_duration: Optional[Union[Var[int], int]] = None,
+ animation_easing: Optional[
+ Union[
+ Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
+ Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
+ ]
+ ] = None,
+ root_tab_index: Optional[Union[Var[int], int]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_animation_end: Optional[EventType[[], BASE_STATE]] = None,
+ on_animation_start: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Pie":
"""Create the component.
Args:
*children: The children of the component.
- data: data
+ data: The index of active sector in Pie, this option can be changed in mouse event handlers.
data_key: The key of each sector's value.
- cx: The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width.
- cy: The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height.
- inner_radius: The inner radius of pie, which can be set to a percent value.
- outer_radius: The outer radius of pie, which can be set to a percent value.
- start_angle: The angle of first sector.
- end_angle: The direction of sectors. 1 means clockwise and -1 means anticlockwise.
- min_angle: The minimum angle of each unzero data.
- padding_angle: The angle between two sectors.
- name_key: The key of each sector's name.
- legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered.
- label: If false set, labels will not be drawn.
- label_line: If false set, label lines will not be drawn.
- stroke: Stoke color
- fill: Fill color
+ cx: The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width. Default: "50%"
+ cy: The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height. Default: "50%"
+ inner_radius: The inner radius of pie, which can be set to a percent value. Default: 0
+ outer_radius: The outer radius of pie, which can be set to a percent value. Default: "80%"
+ start_angle: The angle of first sector. Default: 0
+ end_angle: The end angle of last sector, which should be unequal to start_angle. Default: 360
+ min_angle: The minimum angle of each unzero data. Default: 0
+ padding_angle: The angle between two sectors. Default: 0
+ name_key: The key of each sector's name. Default: "name"
+ legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect"
+ label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
+ label_line: If false set, label lines will not be drawn. If true set, label lines will be drawn which have the props calculated internally. Default: False
+ stroke: Stoke color. Default: rx.color("accent", 9)
+ fill: Fill color. Default: rx.color("accent", 3)
+ is_animation_active: If set false, animation of tooltip will be disabled. Default: true in CSR, and false in SSR
+ animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 400
+ animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
+ animation_easing: The type of easing function. Default: "ease"
+ root_tab_index: The tabindex of wrapper surrounding the cells. Default: 0
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -128,25 +131,58 @@ class Pie(Recharts):
...
class Radar(Recharts):
+ def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ...
@overload
@classmethod
def create( # type: ignore
cls,
*children,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
- points: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ points: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
dot: Optional[Union[Var[bool], bool]] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
fill: Optional[Union[Var[str], str]] = None,
fill_opacity: Optional[Union[Var[float], float]] = None,
- legend_type: Optional[Union[Var[str], str]] = None,
+ legend_type: Optional[
+ Union[
+ Literal[
+ "circle",
+ "cross",
+ "diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
+ "star",
+ "triangle",
+ "wye",
+ ],
+ Var[
+ Literal[
+ "circle",
+ "cross",
+ "diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
+ "star",
+ "triangle",
+ "wye",
+ ]
+ ],
+ ]
+ ] = None,
label: Optional[Union[Var[bool], bool]] = None,
+ is_animation_active: Optional[Union[Var[bool], bool]] = None,
animation_begin: Optional[Union[Var[int], int]] = None,
animation_duration: Optional[Union[Var[int], int]] = None,
animation_easing: Optional[
Union[
- Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]],
- Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"],
+ Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
+ Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
]
] = None,
style: Optional[Style] = None,
@@ -154,52 +190,9 @@ class Radar(Recharts):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_animation_end: Optional[EventType[[], BASE_STATE]] = None,
+ on_animation_start: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Radar":
"""Create the component.
@@ -207,16 +200,17 @@ class Radar(Recharts):
Args:
*children: The children of the component.
data_key: The key of a group of data which should be unique in a radar chart.
- points: The coordinates of all the vertexes of the radar shape, like [{ x, y }].
- dot: If false set, dots will not be drawn
- stroke: Stoke color
- fill: Fill color
- fill_opacity: opacity
- legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered.
- label: If false set, labels will not be drawn
- animation_begin: Specifies when the animation should begin, the unit of this option is ms.
- animation_duration: Specifies the duration of animation, the unit of this option is ms.
- animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'
+ points: The coordinates of all the vertices of the radar shape, like [{ x, y }].
+ dot: If false set, dots will not be drawn. Default: True
+ stroke: Stoke color. Default: rx.color("accent", 9)
+ fill: Fill color. Default: rx.color("accent", 3)
+ fill_opacity: The opacity to fill the chart. Default: 0.6
+ legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect"
+ label: If false set, labels will not be drawn. Default: True
+ is_animation_active: If set false, animation of polygon will be disabled. Default: True in CSR, and False in SSR
+ animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
+ animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
+ animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease"
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -237,22 +231,54 @@ class RadialBar(Recharts):
def create( # type: ignore
cls,
*children,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
min_angle: Optional[Union[Var[int], int]] = None,
- legend_type: Optional[Union[Var[str], str]] = None,
+ legend_type: Optional[
+ Union[
+ Literal[
+ "circle",
+ "cross",
+ "diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
+ "star",
+ "triangle",
+ "wye",
+ ],
+ Var[
+ Literal[
+ "circle",
+ "cross",
+ "diamond",
+ "line",
+ "none",
+ "plainline",
+ "rect",
+ "square",
+ "star",
+ "triangle",
+ "wye",
+ ]
+ ],
+ ]
+ ] = None,
label: Optional[
- Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]]
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool]
] = None,
background: Optional[
- Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]]
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool]
] = None,
is_animation_active: Optional[Union[Var[bool], bool]] = None,
animation_begin: Optional[Union[Var[int], int]] = None,
animation_duration: Optional[Union[Var[int], int]] = None,
animation_easing: Optional[
Union[
- Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]],
- Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"],
+ Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
+ Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
]
] = None,
style: Optional[Style] = None,
@@ -260,46 +286,31 @@ class RadialBar(Recharts):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_animation_end: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_animation_start: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_animation_end: Optional[EventType[[], BASE_STATE]] = None,
+ on_animation_start: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "RadialBar":
"""Create the component.
Args:
*children: The children of the component.
+ data: The source data which each element is an object.
data_key: The key of a group of data which should be unique to show the meaning of angle axis.
- min_angle: Min angle of each bar. A positive value between 0 and 360.
- legend_type: Type of legend
- label: If false set, labels will not be drawn.
- background: If false set, background sector will not be drawn.
- is_animation_active: If set false, animation of radial bars will be disabled. By default true in CSR, and false in SSR
- animation_begin: Specifies when the animation should begin, the unit of this option is ms. By default 0
- animation_duration: Specifies the duration of animation, the unit of this option is ms. By default 1500
- animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. By default 'ease'
+ min_angle: Min angle of each bar. A positive value between 0 and 360. Default: 0
+ legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect"
+ label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
+ background: If false set, background sector will not be drawn. Default: False
+ is_animation_active: If set false, animation of radial bars will be disabled. Default: True
+ animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
+ animation_duration: Specifies the duration of animation, the unit of this option is ms. Default 1500
+ animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease"
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -319,73 +330,47 @@ class PolarAngleAxis(Recharts):
def create( # type: ignore
cls,
*children,
- data_key: Optional[Union[Var[Union[int, str]], str, int]] = None,
+ data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
cx: Optional[Union[Var[Union[int, str]], int, str]] = None,
cy: Optional[Union[Var[Union[int, str]], int, str]] = None,
radius: Optional[Union[Var[Union[int, str]], int, str]] = None,
axis_line: Optional[
- Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]]
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool]
+ ] = None,
+ axis_line_type: Optional[
+ Union[Literal["circle", "polygon"], Var[Literal["circle", "polygon"]]]
] = None,
- axis_line_type: Optional[Union[Var[str], str]] = None,
tick_line: Optional[
- Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]]
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool]
] = None,
- tick: Optional[Union[Var[Union[int, str]], int, str]] = None,
- ticks: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None,
- orient: Optional[Union[Var[str], str]] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ tick: Optional[
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool]
+ ] = None,
+ ticks: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
+ orientation: Optional[Union[Var[str], str]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
allow_duplicated_category: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "PolarAngleAxis":
"""Create the component.
@@ -396,14 +381,22 @@ class PolarAngleAxis(Recharts):
cx: The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width.
cy: The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height.
radius: The outer radius of circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy.
- axis_line: If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option.
- axis_line_type: The type of axis line.
- tick_line: If false set, tick lines will not be drawn. If true set, tick lines will be drawn which have the props calculated internally. If object set, tick lines will be drawn which have the props mergered by the internal calculated props and the option.
- tick: The width or height of tick.
+ axis_line: If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. Default: True
+ axis_line_type: The type of axis line. Default: "polygon"
+ tick_line: If false set, tick lines will not be drawn. If true set, tick lines will be drawn which have the props calculated internally. If object set, tick lines will be drawn which have the props mergered by the internal calculated props and the option. Default: False
+ tick: If false set, ticks will not be drawn. If true set, ticks will be drawn which have the props calculated internally. If object set, ticks will be drawn which have the props mergered by the internal calculated props and the option. Default: True
ticks: The array of every tick's value and angle.
- orient: The orientation of axis text.
- stroke: The stroke color of axis
- allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category".
+ orientation: The orientation of axis text. Default: "outer"
+ stroke: The stroke color of axis. Default: rx.color("gray", 10)
+ allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True
+ on_click: The customized event handler of click on the ticks of this axis.
+ on_mouse_down: The customized event handler of mousedown on the the ticks of this axis.
+ on_mouse_up: The customized event handler of mouseup on the ticks of this axis.
+ on_mouse_move: The customized event handler of mousemove on the ticks of this axis.
+ on_mouse_over: The customized event handler of mouseover on the ticks of this axis.
+ on_mouse_out: The customized event handler of mouseout on the ticks of this axis.
+ on_mouse_enter: The customized event handler of moustenter on the ticks of this axis.
+ on_mouse_leave: The customized event handler of mouseleave on the ticks of this axis.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -423,81 +416,51 @@ class PolarGrid(Recharts):
def create( # type: ignore
cls,
*children,
- cx: Optional[Union[Var[Union[int, str]], int, str]] = None,
- cy: Optional[Union[Var[Union[int, str]], int, str]] = None,
- inner_radius: Optional[Union[Var[Union[int, str]], int, str]] = None,
- outer_radius: Optional[Union[Var[Union[int, str]], int, str]] = None,
- polar_angles: Optional[Union[Var[List[int]], List[int]]] = None,
- polar_radius: Optional[Union[Var[List[int]], List[int]]] = None,
+ cx: Optional[Union[Var[int], int]] = None,
+ cy: Optional[Union[Var[int], int]] = None,
+ inner_radius: Optional[Union[Var[int], int]] = None,
+ outer_radius: Optional[Union[Var[int], int]] = None,
+ polar_angles: Optional[Union[List[int], Var[List[int]]]] = None,
+ polar_radius: Optional[Union[List[int], Var[List[int]]]] = None,
grid_type: Optional[
- Union[Var[Literal["polygon", "circle"]], Literal["polygon", "circle"]]
+ Union[Literal["circle", "polygon"], Var[Literal["circle", "polygon"]]]
] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "PolarGrid":
"""Create the component.
Args:
*children: The children of the component.
- cx: The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width.
- cy: The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height.
+ cx: The x-coordinate of center.
+ cy: The y-coordinate of center.
inner_radius: The radius of the inner polar grid.
outer_radius: The radius of the outer polar grid.
polar_angles: The array of every line grid's angle.
polar_radius: The array of every line grid's radius.
- grid_type: The type of polar grids. 'polygon' | 'circle'
- stroke: The stroke color of grid
+ grid_type: The type of polar grids. 'polygon' | 'circle'. Default: "polygon"
+ stroke: The stroke color of grid. Default: rx.color("gray", 10)
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@@ -520,103 +483,100 @@ class PolarRadiusAxis(Recharts):
*children,
angle: Optional[Union[Var[int], int]] = None,
type_: Optional[
- Union[Var[Literal["number", "category"]], Literal["number", "category"]]
+ Union[Literal["category", "number"], Var[Literal["category", "number"]]]
] = None,
allow_duplicated_category: Optional[Union[Var[bool], bool]] = None,
- cx: Optional[Union[Var[Union[int, str]], int, str]] = None,
- cy: Optional[Union[Var[Union[int, str]], int, str]] = None,
+ cx: Optional[Union[Var[int], int]] = None,
+ cy: Optional[Union[Var[int], int]] = None,
reversed: Optional[Union[Var[bool], bool]] = None,
- orientation: Optional[Union[Var[str], str]] = None,
- axis_line: Optional[
- Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]]
+ orientation: Optional[
+ Union[
+ Literal["left", "middle", "right"],
+ Var[Literal["left", "middle", "right"]],
+ ]
+ ] = None,
+ axis_line: Optional[
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool]
+ ] = None,
+ tick: Optional[
+ Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool]
] = None,
- tick: Optional[Union[Var[Union[int, str]], int, str]] = None,
tick_count: Optional[Union[Var[int], int]] = None,
scale: Optional[
Union[
+ Literal[
+ "auto",
+ "band",
+ "identity",
+ "linear",
+ "log",
+ "ordinal",
+ "point",
+ "pow",
+ "quantile",
+ "quantize",
+ "sequential",
+ "sqrt",
+ "threshold",
+ "time",
+ "utc",
+ ],
Var[
Literal[
"auto",
- "linear",
- "pow",
- "sqrt",
- "log",
- "identity",
- "time",
"band",
- "point",
+ "identity",
+ "linear",
+ "log",
"ordinal",
+ "point",
+ "pow",
"quantile",
"quantize",
- "utc",
"sequential",
+ "sqrt",
"threshold",
+ "time",
+ "utc",
]
],
- Literal[
- "auto",
- "linear",
- "pow",
- "sqrt",
- "log",
- "identity",
- "time",
- "band",
- "point",
- "ordinal",
- "quantile",
- "quantize",
- "utc",
- "sequential",
- "threshold",
- ],
]
] = None,
- domain: Optional[Union[Var[List[int]], List[int]]] = None,
- stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+ domain: Optional[
+ Union[List[Union[int, str]], Var[List[Union[int, str]]]]
+ ] = None,
+ stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "PolarRadiusAxis":
"""Create the component.
Args:
*children: The children of the component.
- angle: The angle of radial direction line to display axis text.
- type_: The type of axis line. 'number' | 'category'
- allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category".
+ angle: The angle of radial direction line to display axis text. Default: 0
+ type_: The type of axis line. 'number' | 'category'. Default: "category"
+ allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True
cx: The x-coordinate of center.
cy: The y-coordinate of center.
- reversed: If set to true, the ticks of this axis are reversed.
- orientation: The orientation of axis text.
- axis_line: If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option.
- tick: The width or height of tick.
- tick_count: The count of ticks.
- scale: If 'auto' set, the scale funtion is linear scale. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'
- domain: The domain of the polar radius axis, specifying the minimum and maximum values.
- stroke: The stroke color of axis
+ reversed: If set to true, the ticks of this axis are reversed. Default: False
+ orientation: The orientation of axis text. Default: "right"
+ axis_line: If false set, axis line will not be drawn. If true set, axis line will be drawn which have the props calculated internally. If object set, axis line will be drawn which have the props mergered by the internal calculated props and the option. Default: True
+ tick: If false set, ticks will not be drawn. If true set, ticks will be drawn which have the props calculated internally. If object set, ticks will be drawn which have the props mergered by the internal calculated props and the option. Default: True
+ tick_count: The count of axis ticks. Not used if 'type' is 'category'. Default: 5
+ scale: If 'auto' set, the scale function is linear scale. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto"
+ domain: The domain of the polar radius axis, specifying the minimum and maximum values. Default: [0, "auto"]
+ stroke: The stroke color of axis. Default: rx.color("gray", 10)
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/recharts/recharts.py b/reflex/components/recharts/recharts.py
index adb7bfdf9..b5a4ed113 100644
--- a/reflex/components/recharts/recharts.py
+++ b/reflex/components/recharts/recharts.py
@@ -3,33 +3,21 @@
from typing import Dict, Literal
from reflex.components.component import Component, MemoizationLeaf, NoSSRComponent
-from reflex.utils import console
class Recharts(Component):
"""A component that wraps a recharts lib."""
- library = "recharts@2.12.7"
+ library = "recharts@2.13.0"
- def render(self) -> Dict:
- """Render the tag.
-
- Returns:
- The rendered tag.
- """
- tag = super().render()
- if any(p.startswith("css") for p in tag["props"]):
- console.warn(
- f"CSS props do not work for {self.__class__.__name__}. Consult docs to style it with its own prop."
- )
- tag["props"] = [p for p in tag["props"] if not p.startswith("css")]
- return tag
+ def _get_style(self) -> Dict:
+ return {"wrapperStyle": self.style}
class RechartsCharts(NoSSRComponent, MemoizationLeaf):
"""A component that wraps a recharts lib."""
- library = "recharts@2.12.7"
+ library = "recharts@2.13.0"
LiteralAnimationEasing = Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]
@@ -60,6 +48,7 @@ LiteralScale = Literal[
"sequential",
"threshold",
]
+LiteralTextAnchor = Literal["start", "middle", "end"]
LiteralLayout = Literal["horizontal", "vertical"]
LiteralPolarRadiusType = Literal["number", "category"]
LiteralGridType = Literal["polygon", "circle"]
@@ -131,6 +120,9 @@ LiteralAreaType = Literal[
"stepBefore",
"stepAfter",
]
-LiteralDirection = Literal["x", "y", "both"]
+LiteralDirection = Literal["x", "y"]
LiteralInterval = Literal["preserveStart", "preserveEnd", "preserveStartEnd"]
+LiteralIntervalAxis = Literal[
+ "preserveStart", "preserveEnd", "preserveStartEnd", "equidistantPreserveStart"
+]
LiteralSyncMethod = Literal["index", "value"]
diff --git a/reflex/components/recharts/recharts.pyi b/reflex/components/recharts/recharts.pyi
index 409285eb5..65e65bce1 100644
--- a/reflex/components/recharts/recharts.pyi
+++ b/reflex/components/recharts/recharts.pyi
@@ -3,15 +3,14 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, Literal, Optional, Union, overload
+from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.components.component import Component, MemoizationLeaf, NoSSRComponent
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class Recharts(Component):
- def render(self) -> Dict: ...
@overload
@classmethod
def create( # type: ignore
@@ -22,52 +21,22 @@ class Recharts(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Recharts":
"""Create the component.
@@ -98,52 +67,22 @@ class RechartsCharts(NoSSRComponent, MemoizationLeaf):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "RechartsCharts":
"""Create a new memoization leaf component.
@@ -191,6 +130,7 @@ LiteralScale = Literal[
"sequential",
"threshold",
]
+LiteralTextAnchor = Literal["start", "middle", "end"]
LiteralLayout = Literal["horizontal", "vertical"]
LiteralPolarRadiusType = Literal["number", "category"]
LiteralGridType = Literal["polygon", "circle"]
@@ -262,6 +202,9 @@ LiteralAreaType = Literal[
"stepBefore",
"stepAfter",
]
-LiteralDirection = Literal["x", "y", "both"]
+LiteralDirection = Literal["x", "y"]
LiteralInterval = Literal["preserveStart", "preserveEnd", "preserveStartEnd"]
+LiteralIntervalAxis = Literal[
+ "preserveStart", "preserveEnd", "preserveStartEnd", "equidistantPreserveStart"
+]
LiteralSyncMethod = Literal["index", "value"]
diff --git a/reflex/components/sonner/toast.py b/reflex/components/sonner/toast.py
index e00eaad4e..836c19bf9 100644
--- a/reflex/components/sonner/toast.py
+++ b/reflex/components/sonner/toast.py
@@ -4,21 +4,19 @@ from __future__ import annotations
from typing import Any, ClassVar, Literal, Optional, Union
-from pydantic import ValidationError
-
from reflex.base import Base
from reflex.components.component import Component, ComponentNamespace
from reflex.components.lucide.icon import Icon
-from reflex.components.props import PropsBase
-from reflex.event import (
- EventSpec,
- call_script,
-)
+from reflex.components.props import NoExtrasAllowedProps, PropsBase
+from reflex.event import EventSpec, run_script
from reflex.style import Style, resolved_color_mode
from reflex.utils import format
from reflex.utils.imports import ImportVar
-from reflex.utils.serializers import serialize, serializer
-from reflex.vars import Var, VarData
+from reflex.utils.serializers import serializer
+from reflex.vars import VarData
+from reflex.vars.base import LiteralVar, Var
+from reflex.vars.function import FunctionVar
+from reflex.vars.object import ObjectVar
LiteralPosition = Literal[
"top-left",
@@ -29,7 +27,7 @@ LiteralPosition = Literal[
"bottom-right",
]
-toast_ref = Var.create_safe("refs['__toast']", _var_is_string=False)
+toast_ref = Var(_js_expr="refs['__toast']")
class ToastAction(Base):
@@ -65,16 +63,18 @@ def _toast_callback_signature(toast: Var) -> list[Var]:
A function call stripping non-serializable members of the toast object.
"""
return [
- Var.create_safe(
- f"(() => {{let {{action, cancel, onDismiss, onAutoClose, ...rest}} = {toast}; return rest}})()",
- _var_is_string=False,
+ Var(
+ _js_expr=f"(() => {{let {{action, cancel, onDismiss, onAutoClose, ...rest}} = {toast!s}; return rest}})()"
)
]
-class ToastProps(PropsBase):
+class ToastProps(PropsBase, NoExtrasAllowedProps):
"""Props for the toast component."""
+ # Toast's title, renders above the description.
+ title: Optional[Union[str, Var]]
+
# Toast's description, renders underneath the title.
description: Optional[Union[str, Var]]
@@ -98,7 +98,7 @@ class ToastProps(PropsBase):
# TODO: fix serialization of icons for toast? (might not be possible yet)
# Icon displayed in front of toast's text, aligned vertically.
- # icon: Optional[Icon] = None
+ # icon: Optional[Icon] = None # noqa: ERA001
# TODO: fix implementation for action / cancel buttons
# Renders a primary button, clicking it will close the toast.
@@ -116,6 +116,9 @@ class ToastProps(PropsBase):
# Custom style for the toast.
style: Optional[Style]
+ # Class name for the toast.
+ class_name: Optional[str]
+
# XXX: These still do not seem to work
# Custom style for the toast primary button.
action_button_styles: Optional[Style]
@@ -129,24 +132,6 @@ class ToastProps(PropsBase):
# Function that gets called when the toast disappears automatically after it's timeout (duration` prop).
on_auto_close: Optional[Any]
- def __init__(self, **kwargs):
- """Initialize the props.
-
- Args:
- kwargs: Kwargs to initialize the props.
-
- Raises:
- ValueError: If invalid props are passed on instantiation.
- """
- try:
- super().__init__(**kwargs)
- except ValidationError as e:
- invalid_fields = ", ".join([error["loc"][0] for error in e.errors()]) # type: ignore
- supported_props_str = ", ".join(f'"{field}"' for field in self.get_fields())
- raise ValueError(
- f"Invalid prop(s) {invalid_fields} for rx.toast. Supported props are {supported_props_str}"
- ) from None
-
def dict(self, *args, **kwargs) -> dict[str, Any]:
"""Convert the object to a dictionary.
@@ -168,28 +153,21 @@ class ToastProps(PropsBase):
d["cancel"] = self.cancel
if isinstance(self.cancel, dict):
d["cancel"] = ToastAction(**self.cancel)
- if "on_dismiss" in d:
- d["on_dismiss"] = format.format_queue_events(
+ if "onDismiss" in d:
+ d["onDismiss"] = format.format_queue_events(
self.on_dismiss, _toast_callback_signature
)
- if "on_auto_close" in d:
- d["on_auto_close"] = format.format_queue_events(
+ if "onAutoClose" in d:
+ d["onAutoClose"] = format.format_queue_events(
self.on_auto_close, _toast_callback_signature
)
return d
- class Config:
- """Pydantic config."""
-
- arbitrary_types_allowed = True
- use_enum_values = True
- extra = "forbid"
-
class Toaster(Component):
"""A Toaster Component for displaying toast notifications."""
- library: str = "sonner@1.4.41"
+ library: str = "sonner@1.5.0"
tag = "Toaster"
@@ -197,21 +175,19 @@ class Toaster(Component):
theme: Var[str] = resolved_color_mode
# whether to show rich colors
- rich_colors: Var[bool] = Var.create_safe(True)
+ rich_colors: Var[bool] = LiteralVar.create(True)
# whether to expand the toast
- expand: Var[bool] = Var.create_safe(True)
+ expand: Var[bool] = LiteralVar.create(True)
# the number of toasts that are currently visible
visible_toasts: Var[int]
# the position of the toast
- position: Var[LiteralPosition] = Var.create_safe(
- "bottom-right", _var_is_string=True
- )
+ position: Var[LiteralPosition] = LiteralVar.create("bottom-right")
# whether to show the close button
- close_button: Var[bool] = Var.create_safe(False)
+ close_button: Var[bool] = LiteralVar.create(False)
# offset of the toast
offset: Var[str]
@@ -246,13 +222,11 @@ class Toaster(Component):
Returns:
The hooks for the toaster component.
"""
- hook = Var.create_safe(
- f"{toast_ref} = toast",
- _var_is_local=True,
- _var_is_string=False,
+ hook = Var(
+ _js_expr=f"{toast_ref} = toast",
_var_data=VarData(
imports={
- "/utils/state": [ImportVar(tag="refs")],
+ "$/utils/state": [ImportVar(tag="refs")],
self.library: [ImportVar(tag="toast", install=False)],
}
),
@@ -260,7 +234,9 @@ class Toaster(Component):
return [hook]
@staticmethod
- def send_toast(message: str = "", level: str | None = None, **props) -> EventSpec:
+ def send_toast(
+ message: str | Var = "", level: str | None = None, **props
+ ) -> EventSpec:
"""Send a toast message.
Args:
@@ -278,20 +254,27 @@ class Toaster(Component):
raise ValueError(
"Toaster component must be created before sending a toast. (use `rx.toast.provider()`)"
)
- toast_command = f"{toast_ref}.{level}" if level is not None else toast_ref
- if message == "" and ("title" not in props or "description" not in props):
- raise ValueError("Toast message or title or description must be provided.")
- if props:
- args = serialize(ToastProps(**props)) # type: ignore
- toast = f"{toast_command}(`{message}`, {args})"
- else:
- toast = f"{toast_command}(`{message}`)"
- toast_action = Var.create_safe(toast, _var_is_string=False, _var_is_local=True)
- return call_script(toast_action)
+ toast_command = (
+ ObjectVar.__getattr__(toast_ref.to(dict), level) if level else toast_ref
+ ).to(FunctionVar)
+
+ if isinstance(message, Var):
+ props.setdefault("title", message)
+ message = ""
+ elif message == "" and "title" not in props and "description" not in props:
+ raise ValueError("Toast message or title or description must be provided.")
+
+ if props:
+ args = LiteralVar.create(ToastProps(component_name="rx.toast", **props)) # pyright: ignore [reportCallIssue, reportGeneralTypeIssues]
+ toast = toast_command.call(message, args)
+ else:
+ toast = toast_command.call(message)
+
+ return run_script(toast)
@staticmethod
- def toast_info(message: str, **kwargs):
+ def toast_info(message: str | Var = "", **kwargs):
"""Display an info toast message.
Args:
@@ -304,7 +287,7 @@ class Toaster(Component):
return Toaster.send_toast(message, level="info", **kwargs)
@staticmethod
- def toast_warning(message: str, **kwargs):
+ def toast_warning(message: str | Var = "", **kwargs):
"""Display a warning toast message.
Args:
@@ -317,7 +300,7 @@ class Toaster(Component):
return Toaster.send_toast(message, level="warning", **kwargs)
@staticmethod
- def toast_error(message: str, **kwargs):
+ def toast_error(message: str | Var = "", **kwargs):
"""Display an error toast message.
Args:
@@ -330,7 +313,7 @@ class Toaster(Component):
return Toaster.send_toast(message, level="error", **kwargs)
@staticmethod
- def toast_success(message: str, **kwargs):
+ def toast_success(message: str | Var = "", **kwargs):
"""Display a success toast message.
Args:
@@ -355,19 +338,16 @@ class Toaster(Component):
dismiss_var_data = None
if isinstance(id, Var):
- dismiss = f"{toast_ref}.dismiss({id._var_name_unwrapped})"
- dismiss_var_data = id._var_data
+ dismiss = f"{toast_ref}.dismiss({id!s})"
+ dismiss_var_data = id._get_all_var_data()
elif isinstance(id, str):
dismiss = f"{toast_ref}.dismiss('{id}')"
else:
dismiss = f"{toast_ref}.dismiss()"
- dismiss_action = Var.create_safe(
- dismiss,
- _var_is_string=False,
- _var_is_local=True,
- _var_data=dismiss_var_data,
+ dismiss_action = Var(
+ _js_expr=dismiss, _var_data=VarData.merge(dismiss_var_data)
)
- return call_script(dismiss_action)
+ return run_script(dismiss_action)
@classmethod
def create(cls, *children, **props) -> Component:
@@ -384,9 +364,7 @@ class Toaster(Component):
return super().create(*children, **props)
-# TODO: figure out why loading toast stay open forever
-# def toast_loading(message: str, **kwargs):
-# return _toast(message, level="loading", **kwargs)
+# TODO: figure out why loading toast stay open forever when using level="loading" in toast()
class ToastNamespace(ComponentNamespace):
@@ -399,7 +377,6 @@ class ToastNamespace(ComponentNamespace):
error = staticmethod(Toaster.toast_error)
success = staticmethod(Toaster.toast_success)
dismiss = staticmethod(Toaster.toast_dismiss)
- # loading = staticmethod(toast_loading)
__call__ = staticmethod(Toaster.send_toast)
diff --git a/reflex/components/sonner/toast.pyi b/reflex/components/sonner/toast.pyi
index c7e626915..7fd9fdf54 100644
--- a/reflex/components/sonner/toast.pyi
+++ b/reflex/components/sonner/toast.pyi
@@ -3,16 +3,16 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, ClassVar, Dict, Literal, Optional, Union, overload
+from typing import Any, ClassVar, Dict, Literal, Optional, Union, overload
from reflex.base import Base
from reflex.components.component import Component, ComponentNamespace
from reflex.components.lucide.icon import Icon
-from reflex.components.props import PropsBase
-from reflex.event import EventHandler, EventSpec
+from reflex.components.props import NoExtrasAllowedProps, PropsBase
+from reflex.event import BASE_STATE, EventSpec, EventType
from reflex.style import Style
from reflex.utils.serializers import serializer
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
LiteralPosition = Literal[
"top-left",
@@ -22,7 +22,7 @@ LiteralPosition = Literal[
"bottom-center",
"bottom-right",
]
-toast_ref = Var.create_safe("refs['__toast']", _var_is_string=False)
+toast_ref = Var(_js_expr="refs['__toast']")
class ToastAction(Base):
label: str
@@ -31,7 +31,8 @@ class ToastAction(Base):
@serializer
def serialize_action(action: ToastAction) -> dict: ...
-class ToastProps(PropsBase):
+class ToastProps(PropsBase, NoExtrasAllowedProps):
+ title: Optional[Union[str, Var]]
description: Optional[Union[str, Var]]
close_button: Optional[bool]
invert: Optional[bool]
@@ -44,6 +45,7 @@ class ToastProps(PropsBase):
id: Optional[Union[str, Var]]
unstyled: Optional[bool]
style: Optional[Style]
+ class_name: Optional[str]
action_button_styles: Optional[Style]
cancel_button_styles: Optional[Style]
on_dismiss: Optional[Any]
@@ -51,27 +53,22 @@ class ToastProps(PropsBase):
def dict(self, *args, **kwargs) -> dict[str, Any]: ...
- class Config:
- arbitrary_types_allowed = True
- use_enum_values = True
- extra = "forbid"
-
class Toaster(Component):
is_used: ClassVar[bool] = False
def add_hooks(self) -> list[Var | str]: ...
@staticmethod
def send_toast(
- message: str = "", level: str | None = None, **props
+ message: str | Var = "", level: str | None = None, **props
) -> EventSpec: ...
@staticmethod
- def toast_info(message: str, **kwargs): ...
+ def toast_info(message: str | Var = "", **kwargs): ...
@staticmethod
- def toast_warning(message: str, **kwargs): ...
+ def toast_warning(message: str | Var = "", **kwargs): ...
@staticmethod
- def toast_error(message: str, **kwargs): ...
+ def toast_error(message: str | Var = "", **kwargs): ...
@staticmethod
- def toast_success(message: str, **kwargs): ...
+ def toast_success(message: str | Var = "", **kwargs): ...
@staticmethod
def toast_dismiss(id: Var | str | None = None): ...
@overload
@@ -85,24 +82,24 @@ class Toaster(Component):
visible_toasts: Optional[Union[Var[int], int]] = None,
position: Optional[
Union[
+ Literal[
+ "bottom-center",
+ "bottom-left",
+ "bottom-right",
+ "top-center",
+ "top-left",
+ "top-right",
+ ],
Var[
Literal[
- "top-left",
- "top-center",
- "top-right",
- "bottom-left",
"bottom-center",
+ "bottom-left",
"bottom-right",
+ "top-center",
+ "top-left",
+ "top-right",
]
],
- Literal[
- "top-left",
- "top-center",
- "top-right",
- "bottom-left",
- "bottom-center",
- "bottom-right",
- ],
]
] = None,
close_button: Optional[Union[Var[bool], bool]] = None,
@@ -110,61 +107,31 @@ class Toaster(Component):
dir: Optional[Union[Var[str], str]] = None,
hotkey: Optional[Union[Var[str], str]] = None,
invert: Optional[Union[Var[bool], bool]] = None,
- toast_options: Optional[Union[Var[ToastProps], ToastProps]] = None,
+ toast_options: Optional[Union[ToastProps, Var[ToastProps]]] = None,
gap: Optional[Union[Var[int], int]] = None,
- loading_icon: Optional[Union[Var[Icon], Icon]] = None,
+ loading_icon: Optional[Union[Icon, Var[Icon]]] = None,
pause_when_page_is_hidden: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Toaster":
"""Create a toaster component.
@@ -209,7 +176,7 @@ class ToastNamespace(ComponentNamespace):
@staticmethod
def __call__(
- message: str = "", level: Optional[str] = None, **props
+ message: Union[str, Var] = "", level: Optional[str] = None, **props
) -> "Optional[EventSpec]":
"""Send a toast message.
diff --git a/reflex/components/suneditor/editor.py b/reflex/components/suneditor/editor.py
index 6e28b396a..d40f0e9ad 100644
--- a/reflex/components/suneditor/editor.py
+++ b/reflex/components/suneditor/editor.py
@@ -3,14 +3,14 @@
from __future__ import annotations
import enum
-from typing import Dict, List, Literal, Optional, Union
+from typing import Dict, List, Literal, Optional, Tuple, Union
from reflex.base import Base
from reflex.components.component import Component, NoSSRComponent
-from reflex.event import EventHandler
+from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec
from reflex.utils.format import to_camel_case
from reflex.utils.imports import ImportDict, ImportVar
-from reflex.vars import Var
+from reflex.vars.base import Var
class EditorButtonList(list, enum.Enum):
@@ -68,6 +68,35 @@ class EditorOptions(Base):
button_list: Optional[List[Union[List[str], str]]]
+def on_blur_spec(e: Var, content: Var[str]) -> Tuple[Var[str]]:
+ """A helper function to specify the on_blur event handler.
+
+ Args:
+ e: The event.
+ content: The content of the editor.
+
+ Returns:
+ A tuple containing the content of the editor.
+ """
+ return (content,)
+
+
+def on_paste_spec(
+ e: Var, clean_data: Var[str], max_char_count: Var[bool]
+) -> Tuple[Var[str], Var[bool]]:
+ """A helper function to specify the on_paste event handler.
+
+ Args:
+ e: The event.
+ clean_data: The clean data.
+ max_char_count: The maximum character count.
+
+ Returns:
+ A tuple containing the clean data and the maximum character count.
+ """
+ return (clean_data, max_char_count)
+
+
class Editor(NoSSRComponent):
"""A Rich Text Editor component based on SunEditor.
Not every JS prop is listed here (some are not easily usable from python),
@@ -87,7 +116,7 @@ class Editor(NoSSRComponent):
# Please refer to the library docs for this.
# options: "en" | "da" | "de" | "es" | "fr" | "ja" | "ko" | "pt_br" |
# "ru" | "zh_cn" | "ro" | "pl" | "ckb" | "lv" | "se" | "ua" | "he" | "it"
- # default : "en"
+ # default: "en".
lang: Var[
Union[
Literal[
@@ -143,7 +172,7 @@ class Editor(NoSSRComponent):
set_options: Var[Dict]
# Whether all SunEditor plugins should be loaded.
- # default: True
+ # default: True.
set_all_plugins: Var[bool]
# Set the content of the editor.
@@ -162,52 +191,47 @@ class Editor(NoSSRComponent):
set_default_style: Var[str]
# Disable the editor
- # default: False
+ # default: False.
disable: Var[bool]
# Hide the editor
- # default: False
+ # default: False.
hide: Var[bool]
# Hide the editor toolbar
- # default: False
+ # default: False.
hide_toolbar: Var[bool]
# Disable the editor toolbar
- # default: False
+ # default: False.
disable_toolbar: Var[bool]
# Fired when the editor content changes.
- on_change: EventHandler[lambda content: [content]]
+ on_change: EventHandler[passthrough_event_spec(str)]
# Fired when the something is inputted in the editor.
- on_input: EventHandler[lambda e: [e]]
+ on_input: EventHandler[no_args_event_spec]
# Fired when the editor loses focus.
- on_blur: EventHandler[lambda e, content: [content]]
+ on_blur: EventHandler[on_blur_spec]
# Fired when the editor is loaded.
- on_load: EventHandler[lambda reload: [reload]]
-
- # Fired when the editor is resized.
- on_resize_editor: EventHandler[lambda height, prev_height: [height, prev_height]]
+ on_load: EventHandler[passthrough_event_spec(bool)]
# Fired when the editor content is copied.
- on_copy: EventHandler[lambda e, clipboard_data: [clipboard_data]]
+ on_copy: EventHandler[no_args_event_spec]
# Fired when the editor content is cut.
- on_cut: EventHandler[lambda e, clipboard_data: [clipboard_data]]
+ on_cut: EventHandler[no_args_event_spec]
# Fired when the editor content is pasted.
- on_paste: EventHandler[
- lambda e, clean_data, max_char_count: [clean_data, max_char_count]
- ]
+ on_paste: EventHandler[on_paste_spec]
# Fired when the code view is toggled.
- toggle_code_view: EventHandler[lambda is_code_view: [is_code_view]]
+ toggle_code_view: EventHandler[passthrough_event_spec(bool)]
# Fired when the full screen mode is toggled.
- toggle_full_screen: EventHandler[lambda is_full_screen: [is_full_screen]]
+ toggle_full_screen: EventHandler[passthrough_event_spec(bool)]
def add_imports(self) -> ImportDict:
"""Add imports for the Editor component.
diff --git a/reflex/components/suneditor/editor.pyi b/reflex/components/suneditor/editor.pyi
index 8a86e0270..b52fd43da 100644
--- a/reflex/components/suneditor/editor.pyi
+++ b/reflex/components/suneditor/editor.pyi
@@ -4,14 +4,14 @@
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
import enum
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload
from reflex.base import Base
from reflex.components.component import NoSSRComponent
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.style import Style
from reflex.utils.imports import ImportDict
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class EditorButtonList(list, enum.Enum):
BASIC = [["font", "fontSize"], ["fontColor"], ["horizontalRule"], ["link", "image"]]
@@ -44,6 +44,11 @@ class EditorOptions(Base):
rtl: Optional[bool]
button_list: Optional[List[Union[List[str], str]]]
+def on_blur_spec(e: Var, content: Var[str]) -> Tuple[Var[str]]: ...
+def on_paste_spec(
+ e: Var, clean_data: Var[str], max_char_count: Var[bool]
+) -> Tuple[Var[str], Var[bool]]: ...
+
class Editor(NoSSRComponent):
def add_imports(self) -> ImportDict: ...
@overload
@@ -53,51 +58,51 @@ class Editor(NoSSRComponent):
*children,
lang: Optional[
Union[
+ Literal[
+ "ckb",
+ "da",
+ "de",
+ "en",
+ "es",
+ "fr",
+ "he",
+ "it",
+ "ja",
+ "ko",
+ "lv",
+ "pl",
+ "pt_br",
+ "ro",
+ "ru",
+ "se",
+ "ua",
+ "zh_cn",
+ ],
Var[
Union[
Literal[
- "en",
+ "ckb",
"da",
"de",
+ "en",
"es",
"fr",
- "ja",
- "ko",
- "pt_br",
- "ru",
- "zh_cn",
- "ro",
- "pl",
- "ckb",
- "lv",
- "se",
- "ua",
"he",
"it",
+ "ja",
+ "ko",
+ "lv",
+ "pl",
+ "pt_br",
+ "ro",
+ "ru",
+ "se",
+ "ua",
+ "zh_cn",
],
dict,
]
],
- Literal[
- "en",
- "da",
- "de",
- "es",
- "fr",
- "ja",
- "ko",
- "pt_br",
- "ru",
- "zh_cn",
- "ro",
- "pl",
- "ckb",
- "lv",
- "se",
- "ua",
- "he",
- "it",
- ],
dict,
]
] = None,
@@ -107,7 +112,7 @@ class Editor(NoSSRComponent):
height: Optional[Union[Var[str], str]] = None,
placeholder: Optional[Union[Var[str], str]] = None,
auto_focus: Optional[Union[Var[bool], bool]] = None,
- set_options: Optional[Union[Var[Dict], Dict]] = None,
+ set_options: Optional[Union[Dict, Var[Dict]]] = None,
set_all_plugins: Optional[Union[Var[bool], bool]] = None,
set_contents: Optional[Union[Var[str], str]] = None,
append_contents: Optional[Union[Var[str], str]] = None,
@@ -121,78 +126,45 @@ class Editor(NoSSRComponent):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
on_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_copy: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_cut: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_input: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]]
] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_copy: Optional[EventType[[], BASE_STATE]] = None,
+ on_cut: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_input: Optional[EventType[[], BASE_STATE]] = None,
on_load: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_paste: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_resize_editor: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[
+ EventType[[], BASE_STATE],
+ EventType[[str], BASE_STATE],
+ EventType[[str, bool], BASE_STATE],
+ ]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
toggle_code_view: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
toggle_full_screen: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
**props,
) -> "Editor":
@@ -200,7 +172,7 @@ class Editor(NoSSRComponent):
Args:
set_options(Optional[EditorOptions]): Configuration object to further configure the instance.
- lang: Language of the editor. Alternatively to a string, a dict of your language can be passed to this prop. Please refer to the library docs for this. options: "en" | "da" | "de" | "es" | "fr" | "ja" | "ko" | "pt_br" | "ru" | "zh_cn" | "ro" | "pl" | "ckb" | "lv" | "se" | "ua" | "he" | "it" default : "en"
+ lang: Language of the editor. Alternatively to a string, a dict of your language can be passed to this prop. Please refer to the library docs for this. options: "en" | "da" | "de" | "es" | "fr" | "ja" | "ko" | "pt_br" | "ru" | "zh_cn" | "ro" | "pl" | "ckb" | "lv" | "se" | "ua" | "he" | "it" default: "en".
name: This is used to set the HTML form name of the editor. This means on HTML form submission, it will be submitted together with contents of the editor by the name provided.
default_value: Sets the default value of the editor. This is useful if you don't want the on_change method to be called on render. If you want the on_change method to be called on render please use the set_contents prop
width: Sets the width of the editor. px and percentage values are accepted, eg width="100%" or width="500px" default: 100%
@@ -208,14 +180,23 @@ class Editor(NoSSRComponent):
placeholder: Sets the placeholder of the editor.
auto_focus: Should the editor receive focus when initialized?
set_options: Pass an EditorOptions instance to modify the behaviour of Editor even more.
- set_all_plugins: Whether all SunEditor plugins should be loaded. default: True
+ set_all_plugins: Whether all SunEditor plugins should be loaded. default: True.
set_contents: Set the content of the editor. Note: To set the initial contents of the editor without calling the on_change event, please use the default_value prop. set_contents is used to set the contents of the editor programmatically. You must be aware that, when the set_contents's prop changes, the on_change event is triggered.
append_contents: Append editor content
set_default_style: Sets the default style of the editor's edit area
- disable: Disable the editor default: False
- hide: Hide the editor default: False
- hide_toolbar: Hide the editor toolbar default: False
- disable_toolbar: Disable the editor toolbar default: False
+ disable: Disable the editor default: False.
+ hide: Hide the editor default: False.
+ hide_toolbar: Hide the editor toolbar default: False.
+ disable_toolbar: Disable the editor toolbar default: False.
+ on_change: Fired when the editor content changes.
+ on_input: Fired when the something is inputted in the editor.
+ on_blur: Fired when the editor loses focus.
+ on_load: Fired when the editor is loaded.
+ on_copy: Fired when the editor content is copied.
+ on_cut: Fired when the editor content is cut.
+ on_paste: Fired when the editor content is pasted.
+ toggle_code_view: Fired when the code view is toggled.
+ toggle_full_screen: Fired when the full screen mode is toggled.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
diff --git a/reflex/components/tags/cond_tag.py b/reflex/components/tags/cond_tag.py
index 3143890c4..b4d0fe469 100644
--- a/reflex/components/tags/cond_tag.py
+++ b/reflex/components/tags/cond_tag.py
@@ -1,19 +1,21 @@
"""Tag to conditionally render components."""
+import dataclasses
from typing import Any, Dict, Optional
from reflex.components.tags.tag import Tag
-from reflex.vars import Var
+from reflex.vars.base import Var
+@dataclasses.dataclass()
class CondTag(Tag):
"""A conditional tag."""
# The condition to determine which component to render.
- cond: Var[Any]
+ cond: Var[Any] = dataclasses.field(default_factory=lambda: Var.create(True))
# The code to render if the condition is true.
- true_value: Dict
+ true_value: Dict = dataclasses.field(default_factory=dict)
# The code to render if the condition is false.
- false_value: Optional[Dict]
+ false_value: Optional[Dict] = None
diff --git a/reflex/components/tags/iter_tag.py b/reflex/components/tags/iter_tag.py
index 95a496b71..38ecaf81c 100644
--- a/reflex/components/tags/iter_tag.py
+++ b/reflex/components/tags/iter_tag.py
@@ -2,30 +2,34 @@
from __future__ import annotations
+import dataclasses
import inspect
-from typing import TYPE_CHECKING, Any, Callable, List, Tuple, Type, Union, get_args
+from typing import TYPE_CHECKING, Any, Callable, Iterable, Tuple, Type, Union, get_args
from reflex.components.tags.tag import Tag
-from reflex.vars import BaseVar, Var
+from reflex.vars import LiteralArrayVar, Var, get_unique_variable_name
if TYPE_CHECKING:
from reflex.components.component import Component
+@dataclasses.dataclass()
class IterTag(Tag):
"""An iterator tag."""
# The var to iterate over.
- iterable: Var[List]
+ iterable: Var[Iterable] = dataclasses.field(
+ default_factory=lambda: LiteralArrayVar.create([])
+ )
# The component render function for each item in the iterable.
- render_fn: Callable
+ render_fn: Callable = dataclasses.field(default_factory=lambda: lambda x: x)
# The name of the arg var.
- arg_var_name: str
+ arg_var_name: str = dataclasses.field(default_factory=get_unique_variable_name)
# The name of the index var.
- index_var_name: str
+ index_var_name: str = dataclasses.field(default_factory=get_unique_variable_name)
def get_iterable_var_type(self) -> Type:
"""Get the type of the iterable var.
@@ -33,15 +37,16 @@ class IterTag(Tag):
Returns:
The type of the iterable var.
"""
+ iterable = self.iterable
try:
- if self.iterable._var_type.mro()[0] == dict:
+ if iterable._var_type.mro()[0] is dict:
# Arg is a tuple of (key, value).
- return Tuple[get_args(self.iterable._var_type)] # type: ignore
- elif self.iterable._var_type.mro()[0] == tuple:
+ return Tuple[get_args(iterable._var_type)] # type: ignore
+ elif iterable._var_type.mro()[0] is tuple:
# Arg is a union of any possible values in the tuple.
- return Union[get_args(self.iterable._var_type)] # type: ignore
+ return Union[get_args(iterable._var_type)] # type: ignore
else:
- return get_args(self.iterable._var_type)[0]
+ return get_args(iterable._var_type)[0]
except Exception:
return Any
@@ -53,10 +58,10 @@ class IterTag(Tag):
Returns:
The index var.
"""
- return BaseVar(
- _var_name=self.index_var_name,
+ return Var(
+ _js_expr=self.index_var_name,
_var_type=int,
- )
+ ).guess_type()
def get_arg_var(self) -> Var:
"""Get the arg var for the tag (with curly braces).
@@ -66,10 +71,10 @@ class IterTag(Tag):
Returns:
The arg var.
"""
- return BaseVar(
- _var_name=self.arg_var_name,
+ return Var(
+ _js_expr=self.arg_var_name,
_var_type=self.get_iterable_var_type(),
- )
+ ).guess_type()
def get_index_var_arg(self) -> Var:
"""Get the index var for the tag (without curly braces).
@@ -79,11 +84,10 @@ class IterTag(Tag):
Returns:
The index var.
"""
- return BaseVar(
- _var_name=self.index_var_name,
+ return Var(
+ _js_expr=self.index_var_name,
_var_type=int,
- _var_is_local=True,
- )
+ ).guess_type()
def get_arg_var_arg(self) -> Var:
"""Get the arg var for the tag (without curly braces).
@@ -93,15 +97,17 @@ class IterTag(Tag):
Returns:
The arg var.
"""
- return BaseVar(
- _var_name=self.arg_var_name,
+ return Var(
+ _js_expr=self.arg_var_name,
_var_type=self.get_iterable_var_type(),
- _var_is_local=True,
- )
+ ).guess_type()
def render_component(self) -> Component:
"""Render the component.
+ Raises:
+ ValueError: If the render function takes more than 2 arguments.
+
Returns:
The rendered component.
"""
@@ -120,7 +126,8 @@ class IterTag(Tag):
component = self.render_fn(arg)
else:
# If the render function takes the index as an argument.
- assert len(args) == 2
+ if len(args) != 2:
+ raise ValueError("The render function must take 2 arguments.")
component = self.render_fn(arg, index)
# Nested foreach components or cond must be wrapped in fragments.
diff --git a/reflex/components/tags/match_tag.py b/reflex/components/tags/match_tag.py
index c2f6649d5..01eedb296 100644
--- a/reflex/components/tags/match_tag.py
+++ b/reflex/components/tags/match_tag.py
@@ -1,19 +1,21 @@
"""Tag to conditionally match cases."""
+import dataclasses
from typing import Any, List
from reflex.components.tags.tag import Tag
-from reflex.vars import Var
+from reflex.vars.base import Var
+@dataclasses.dataclass()
class MatchTag(Tag):
"""A match tag."""
# The condition to determine which case to match.
- cond: Var[Any]
+ cond: Var[Any] = dataclasses.field(default_factory=lambda: Var.create(True))
# The list of match cases to be matched.
- match_cases: List[Any]
+ match_cases: List[Any] = dataclasses.field(default_factory=list)
# The catchall case to match.
- default: Any
+ default: Any = dataclasses.field(default=Var.create(None))
diff --git a/reflex/components/tags/tag.py b/reflex/components/tags/tag.py
index bacea6a41..0587c61ed 100644
--- a/reflex/components/tags/tag.py
+++ b/reflex/components/tags/tag.py
@@ -2,49 +2,40 @@
from __future__ import annotations
-from typing import Any, Dict, List, Optional, Set, Tuple, Union
+import dataclasses
+from typing import Any, Dict, List, Optional, Union
-from reflex.base import Base
from reflex.event import EventChain
from reflex.utils import format, types
-from reflex.vars import Var
+from reflex.vars.base import LiteralVar, Var
-class Tag(Base):
+@dataclasses.dataclass()
+class Tag:
"""A React tag."""
# The name of the tag.
name: str = ""
# The props of the tag.
- props: Dict[str, Any] = {}
+ props: Dict[str, Any] = dataclasses.field(default_factory=dict)
# The inner contents of the tag.
contents: str = ""
- # Args to pass to the tag.
- args: Optional[Tuple[str, ...]] = None
-
# Special props that aren't key value pairs.
- special_props: Set[Var] = set()
+ special_props: List[Var] = dataclasses.field(default_factory=list)
# The children components.
- children: List[Any] = []
+ children: List[Any] = dataclasses.field(default_factory=list)
- def __init__(self, *args, **kwargs):
- """Initialize the tag.
-
- Args:
- *args: Args to initialize the tag.
- **kwargs: Kwargs to initialize the tag.
- """
- # Convert any props to vars.
- if "props" in kwargs:
- kwargs["props"] = {
- name: Var.create(value, _var_is_string=False)
- for name, value in kwargs["props"].items()
- }
- super().__init__(*args, **kwargs)
+ def __post_init__(self):
+ """Post initialize the tag."""
+ object.__setattr__(
+ self,
+ "props",
+ {name: LiteralVar.create(value) for name, value in self.props.items()},
+ )
def format_props(self) -> List:
"""Format the tag's props.
@@ -54,6 +45,29 @@ class Tag(Base):
"""
return format.format_props(*self.special_props, **self.props)
+ def set(self, **kwargs: Any):
+ """Set the tag's fields.
+
+ Args:
+ kwargs: The fields to set.
+
+ Returns:
+ The tag with the fields
+ """
+ for name, value in kwargs.items():
+ setattr(self, name, value)
+
+ return self
+
+ def __iter__(self):
+ """Iterate over the tag's fields.
+
+ Yields:
+ Tuple[str, Any]: The field name and value.
+ """
+ for field in dataclasses.fields(self):
+ yield field.name, getattr(self, field.name)
+
def add_props(self, **kwargs: Optional[Any]) -> Tag:
"""Add props to the tag.
@@ -63,14 +77,12 @@ class Tag(Base):
Returns:
The tag with the props added.
"""
- from reflex.components.core.colors import Color
-
self.props.update(
{
- format.to_camel_case(name, allow_hyphens=True): prop
- if types._isinstance(prop, Union[EventChain, dict])
- else Var.create(
- prop, _var_is_string=isinstance(prop, Color)
+ format.to_camel_case(name, allow_hyphens=True): (
+ prop
+ if types._isinstance(prop, Union[EventChain, dict])
+ else LiteralVar.create(prop)
) # rx.color is always a string
for name, prop in kwargs.items()
if self.is_valid_prop(prop)
diff --git a/reflex/config.py b/reflex/config.py
index 06d8c2193..0579b019f 100644
--- a/reflex/config.py
+++ b/reflex/config.py
@@ -2,11 +2,32 @@
from __future__ import annotations
+import dataclasses
+import enum
import importlib
+import inspect
import os
import sys
+import threading
import urllib.parse
-from typing import Any, Dict, List, Optional, Set
+from importlib.util import find_spec
+from pathlib import Path
+from typing import (
+ TYPE_CHECKING,
+ Any,
+ Dict,
+ Generic,
+ List,
+ Optional,
+ Set,
+ TypeVar,
+ get_args,
+)
+
+from typing_extensions import Annotated, get_type_hints
+
+from reflex.utils.exceptions import ConfigError, EnvironmentVarValueError
+from reflex.utils.types import GenericType, is_union, value_inside_optional
try:
import pydantic.v1 as pydantic
@@ -61,7 +82,7 @@ class DBConfig(Base):
)
@classmethod
- def postgresql_psycopg2(
+ def postgresql_psycopg(
cls,
database: str,
username: str,
@@ -69,7 +90,7 @@ class DBConfig(Base):
host: str | None = None,
port: int | None = 5432,
) -> DBConfig:
- """Create an instance with postgresql+psycopg2 engine.
+ """Create an instance with postgresql+psycopg engine.
Args:
database: Database name.
@@ -82,7 +103,7 @@ class DBConfig(Base):
DBConfig instance.
"""
return cls(
- engine="postgresql+psycopg2",
+ engine="postgresql+psycopg",
username=username,
password=password,
host=host,
@@ -128,6 +149,432 @@ class DBConfig(Base):
return f"{self.engine}://{path}/{self.database}"
+def get_default_value_for_field(field: dataclasses.Field) -> Any:
+ """Get the default value for a field.
+
+ Args:
+ field: The field.
+
+ Returns:
+ The default value.
+
+ Raises:
+ ValueError: If no default value is found.
+ """
+ if field.default != dataclasses.MISSING:
+ return field.default
+ elif field.default_factory != dataclasses.MISSING:
+ return field.default_factory()
+ else:
+ raise ValueError(
+ f"Missing value for environment variable {field.name} and no default value found"
+ )
+
+
+# TODO: Change all interpret_.* signatures to value: str, field: dataclasses.Field once we migrate rx.Config to dataclasses
+def interpret_boolean_env(value: str, field_name: str) -> bool:
+ """Interpret a boolean environment variable value.
+
+ Args:
+ value: The environment variable value.
+ field_name: The field name.
+
+ Returns:
+ The interpreted value.
+
+ Raises:
+ EnvironmentVarValueError: If the value is invalid.
+ """
+ true_values = ["true", "1", "yes", "y"]
+ false_values = ["false", "0", "no", "n"]
+
+ if value.lower() in true_values:
+ return True
+ elif value.lower() in false_values:
+ return False
+ raise EnvironmentVarValueError(f"Invalid boolean value: {value} for {field_name}")
+
+
+def interpret_int_env(value: str, field_name: str) -> int:
+ """Interpret an integer environment variable value.
+
+ Args:
+ value: The environment variable value.
+ field_name: The field name.
+
+ Returns:
+ The interpreted value.
+
+ Raises:
+ EnvironmentVarValueError: If the value is invalid.
+ """
+ try:
+ return int(value)
+ except ValueError as ve:
+ raise EnvironmentVarValueError(
+ f"Invalid integer value: {value} for {field_name}"
+ ) from ve
+
+
+def interpret_existing_path_env(value: str, field_name: str) -> ExistingPath:
+ """Interpret a path environment variable value as an existing path.
+
+ Args:
+ value: The environment variable value.
+ field_name: The field name.
+
+ Returns:
+ The interpreted value.
+
+ Raises:
+ EnvironmentVarValueError: If the path does not exist.
+ """
+ path = Path(value)
+ if not path.exists():
+ raise EnvironmentVarValueError(f"Path does not exist: {path} for {field_name}")
+ return path
+
+
+def interpret_path_env(value: str, field_name: str) -> Path:
+ """Interpret a path environment variable value.
+
+ Args:
+ value: The environment variable value.
+ field_name: The field name.
+
+ Returns:
+ The interpreted value.
+ """
+ return Path(value)
+
+
+def interpret_enum_env(value: str, field_type: GenericType, field_name: str) -> Any:
+ """Interpret an enum environment variable value.
+
+ Args:
+ value: The environment variable value.
+ field_type: The field type.
+ field_name: The field name.
+
+ Returns:
+ The interpreted value.
+
+ Raises:
+ EnvironmentVarValueError: If the value is invalid.
+ """
+ try:
+ return field_type(value)
+ except ValueError as ve:
+ raise EnvironmentVarValueError(
+ f"Invalid enum value: {value} for {field_name}"
+ ) from ve
+
+
+def interpret_env_var_value(
+ value: str, field_type: GenericType, field_name: str
+) -> Any:
+ """Interpret an environment variable value based on the field type.
+
+ Args:
+ value: The environment variable value.
+ field_type: The field type.
+ field_name: The field name.
+
+ Returns:
+ The interpreted value.
+
+ Raises:
+ ValueError: If the value is invalid.
+ """
+ field_type = value_inside_optional(field_type)
+
+ if is_union(field_type):
+ raise ValueError(
+ f"Union types are not supported for environment variables: {field_name}."
+ )
+
+ if field_type is bool:
+ return interpret_boolean_env(value, field_name)
+ elif field_type is str:
+ return value
+ elif field_type is int:
+ return interpret_int_env(value, field_name)
+ elif field_type is Path:
+ return interpret_path_env(value, field_name)
+ elif field_type is ExistingPath:
+ return interpret_existing_path_env(value, field_name)
+ elif inspect.isclass(field_type) and issubclass(field_type, enum.Enum):
+ return interpret_enum_env(value, field_type, field_name)
+
+ else:
+ raise ValueError(
+ f"Invalid type for environment variable {field_name}: {field_type}. This is probably an issue in Reflex."
+ )
+
+
+T = TypeVar("T")
+
+
+class EnvVar(Generic[T]):
+ """Environment variable."""
+
+ name: str
+ default: Any
+ type_: T
+
+ def __init__(self, name: str, default: Any, type_: T) -> None:
+ """Initialize the environment variable.
+
+ Args:
+ name: The environment variable name.
+ default: The default value.
+ type_: The type of the value.
+ """
+ self.name = name
+ self.default = default
+ self.type_ = type_
+
+ def interpret(self, value: str) -> T:
+ """Interpret the environment variable value.
+
+ Args:
+ value: The environment variable value.
+
+ Returns:
+ The interpreted value.
+ """
+ return interpret_env_var_value(value, self.type_, self.name)
+
+ def getenv(self) -> Optional[T]:
+ """Get the interpreted environment variable value.
+
+ Returns:
+ The environment variable value.
+ """
+ env_value = os.getenv(self.name, None)
+ if env_value is not None:
+ return self.interpret(env_value)
+ return None
+
+ def is_set(self) -> bool:
+ """Check if the environment variable is set.
+
+ Returns:
+ True if the environment variable is set.
+ """
+ return self.name in os.environ
+
+ def get(self) -> T:
+ """Get the interpreted environment variable value or the default value if not set.
+
+ Returns:
+ The interpreted value.
+ """
+ env_value = self.getenv()
+ if env_value is not None:
+ return env_value
+ return self.default
+
+ def set(self, value: T | None) -> None:
+ """Set the environment variable. None unsets the variable.
+
+ Args:
+ value: The value to set.
+ """
+ if value is None:
+ _ = os.environ.pop(self.name, None)
+ else:
+ if isinstance(value, enum.Enum):
+ value = value.value
+ os.environ[self.name] = str(value)
+
+
+class env_var: # type: ignore
+ """Descriptor for environment variables."""
+
+ name: str
+ default: Any
+ internal: bool = False
+
+ def __init__(self, default: Any, internal: bool = False) -> None:
+ """Initialize the descriptor.
+
+ Args:
+ default: The default value.
+ internal: Whether the environment variable is reflex internal.
+ """
+ self.default = default
+ self.internal = internal
+
+ def __set_name__(self, owner, name):
+ """Set the name of the descriptor.
+
+ Args:
+ owner: The owner class.
+ name: The name of the descriptor.
+ """
+ self.name = name
+
+ def __get__(self, instance, owner):
+ """Get the EnvVar instance.
+
+ Args:
+ instance: The instance.
+ owner: The owner class.
+
+ Returns:
+ The EnvVar instance.
+ """
+ type_ = get_args(get_type_hints(owner)[self.name])[0]
+ env_name = self.name
+ if self.internal:
+ env_name = f"__{env_name}"
+ return EnvVar(name=env_name, default=self.default, type_=type_)
+
+
+if TYPE_CHECKING:
+
+ def env_var(default, internal=False) -> EnvVar:
+ """Typing helper for the env_var descriptor.
+
+ Args:
+ default: The default value.
+ internal: Whether the environment variable is reflex internal.
+
+ Returns:
+ The EnvVar instance.
+ """
+ return default
+
+
+class PathExistsFlag:
+ """Flag to indicate that a path must exist."""
+
+
+ExistingPath = Annotated[Path, PathExistsFlag]
+
+
+class PerformanceMode(enum.Enum):
+ """Performance mode for the app."""
+
+ WARN = "warn"
+ RAISE = "raise"
+ OFF = "off"
+
+
+class EnvironmentVariables:
+ """Environment variables class to instantiate environment variables."""
+
+ # Whether to use npm over bun to install frontend packages.
+ REFLEX_USE_NPM: EnvVar[bool] = env_var(False)
+
+ # The npm registry to use.
+ NPM_CONFIG_REGISTRY: EnvVar[Optional[str]] = env_var(None)
+
+ # Whether to use Granian for the backend. Otherwise, use Uvicorn.
+ REFLEX_USE_GRANIAN: EnvVar[bool] = env_var(False)
+
+ # The username to use for authentication on python package repository. Username and password must both be provided.
+ TWINE_USERNAME: EnvVar[Optional[str]] = env_var(None)
+
+ # The password to use for authentication on python package repository. Username and password must both be provided.
+ TWINE_PASSWORD: EnvVar[Optional[str]] = env_var(None)
+
+ # Whether to use the system installed bun. If set to false, bun will be bundled with the app.
+ REFLEX_USE_SYSTEM_BUN: EnvVar[bool] = env_var(False)
+
+ # Whether to use the system installed node and npm. If set to false, node and npm will be bundled with the app.
+ REFLEX_USE_SYSTEM_NODE: EnvVar[bool] = env_var(False)
+
+ # The working directory for the next.js commands.
+ REFLEX_WEB_WORKDIR: EnvVar[Path] = env_var(Path(constants.Dirs.WEB))
+
+ # Path to the alembic config file
+ ALEMBIC_CONFIG: EnvVar[ExistingPath] = env_var(Path(constants.ALEMBIC_CONFIG))
+
+ # Disable SSL verification for HTTPX requests.
+ SSL_NO_VERIFY: EnvVar[bool] = env_var(False)
+
+ # The directory to store uploaded files.
+ REFLEX_UPLOADED_FILES_DIR: EnvVar[Path] = env_var(
+ Path(constants.Dirs.UPLOADED_FILES)
+ )
+
+ # Whether to use separate processes to compile the frontend and how many. If not set, defaults to thread executor.
+ REFLEX_COMPILE_PROCESSES: EnvVar[Optional[int]] = env_var(None)
+
+ # Whether to use separate threads to compile the frontend and how many. Defaults to `min(32, os.cpu_count() + 4)`.
+ REFLEX_COMPILE_THREADS: EnvVar[Optional[int]] = env_var(None)
+
+ # The directory to store reflex dependencies.
+ REFLEX_DIR: EnvVar[Path] = env_var(Path(constants.Reflex.DIR))
+
+ # Whether to print the SQL queries if the log level is INFO or lower.
+ SQLALCHEMY_ECHO: EnvVar[bool] = env_var(False)
+
+ # Whether to check db connections before using them.
+ SQLALCHEMY_POOL_PRE_PING: EnvVar[bool] = env_var(True)
+
+ # Whether to ignore the redis config error. Some redis servers only allow out-of-band configuration.
+ REFLEX_IGNORE_REDIS_CONFIG_ERROR: EnvVar[bool] = env_var(False)
+
+ # Whether to skip purging the web directory in dev mode.
+ REFLEX_PERSIST_WEB_DIR: EnvVar[bool] = env_var(False)
+
+ # The reflex.build frontend host.
+ REFLEX_BUILD_FRONTEND: EnvVar[str] = env_var(
+ constants.Templates.REFLEX_BUILD_FRONTEND
+ )
+
+ # The reflex.build backend host.
+ REFLEX_BUILD_BACKEND: EnvVar[str] = env_var(
+ constants.Templates.REFLEX_BUILD_BACKEND
+ )
+
+ # This env var stores the execution mode of the app
+ REFLEX_ENV_MODE: EnvVar[constants.Env] = env_var(constants.Env.DEV)
+
+ # Whether to run the backend only. Exclusive with REFLEX_FRONTEND_ONLY.
+ REFLEX_BACKEND_ONLY: EnvVar[bool] = env_var(False)
+
+ # Whether to run the frontend only. Exclusive with REFLEX_BACKEND_ONLY.
+ REFLEX_FRONTEND_ONLY: EnvVar[bool] = env_var(False)
+
+ # Reflex internal env to reload the config.
+ RELOAD_CONFIG: EnvVar[bool] = env_var(False, internal=True)
+
+ # If this env var is set to "yes", App.compile will be a no-op
+ REFLEX_SKIP_COMPILE: EnvVar[bool] = env_var(False, internal=True)
+
+ # Whether to run app harness tests in headless mode.
+ APP_HARNESS_HEADLESS: EnvVar[bool] = env_var(False)
+
+ # Which app harness driver to use.
+ APP_HARNESS_DRIVER: EnvVar[str] = env_var("Chrome")
+
+ # Arguments to pass to the app harness driver.
+ APP_HARNESS_DRIVER_ARGS: EnvVar[str] = env_var("")
+
+ # Where to save screenshots when tests fail.
+ SCREENSHOT_DIR: EnvVar[Optional[Path]] = env_var(None)
+
+ # Whether to check for outdated package versions.
+ REFLEX_CHECK_LATEST_VERSION: EnvVar[bool] = env_var(True)
+
+ # In which performance mode to run the app.
+ REFLEX_PERF_MODE: EnvVar[Optional[PerformanceMode]] = env_var(PerformanceMode.WARN)
+
+ # The maximum size of the reflex state in kilobytes.
+ REFLEX_STATE_SIZE_LIMIT: EnvVar[int] = env_var(1000)
+
+
+environment = EnvironmentVariables()
+
+
+# These vars are not logged because they may contain sensitive information.
+_sensitive_env_vars = {"DB_URL", "ASYNC_DB_URL", "REDIS_URL"}
+
+
class Config(Base):
"""The config defines runtime settings for the app.
@@ -158,7 +605,7 @@ class Config(Base):
app_name: str
# The log level to use.
- loglevel: constants.LogLevel = constants.LogLevel.INFO
+ loglevel: constants.LogLevel = constants.LogLevel.DEFAULT
# The port to run the frontend on. NOTE: When running in dev mode, the next available port will be used if this is taken.
frontend_port: int = constants.DefaultPorts.FRONTEND_PORT
@@ -181,6 +628,9 @@ class Config(Base):
# The database url used by rx.Model.
db_url: Optional[str] = "sqlite:///reflex.db"
+ # The async database url used by rx.Model.
+ async_db_url: Optional[str] = None
+
# The redis url
redis_url: Optional[str] = None
@@ -188,13 +638,16 @@ class Config(Base):
telemetry_enabled: bool = True
# The bun path
- bun_path: str = constants.Bun.DEFAULT_PATH
+ bun_path: ExistingPath = constants.Bun.DEFAULT_PATH
+
+ # Timeout to do a production build of a frontend page.
+ static_page_generation_timeout: int = 60
# List of origins that are allowed to connect to the backend API.
cors_allowed_origins: List[str] = ["*"]
# Tailwind config.
- tailwind: Optional[Dict[str, Any]] = {}
+ tailwind: Optional[Dict[str, Any]] = {"plugins": ["@tailwindcss/typography"]}
# Timeout when launching the gunicorn server. TODO(rename this to backend_timeout?)
timeout: int = 120
@@ -209,9 +662,9 @@ class Config(Base):
frontend_packages: List[str] = []
# The hosting service backend URL.
- cp_backend_url: str = Hosting.CP_BACKEND_URL
+ cp_backend_url: str = Hosting.HOSTING_SERVICE
# The hosting service frontend URL.
- cp_web_url: str = Hosting.CP_WEB_URL
+ cp_web_url: str = Hosting.HOSTING_SERVICE_UI
# The worker class used in production mode
gunicorn_worker_class: str = "uvicorn.workers.UvicornH11Worker"
@@ -219,21 +672,39 @@ class Config(Base):
# Number of gunicorn workers from user
gunicorn_workers: Optional[int] = None
+ # Number of requests before a worker is restarted
+ gunicorn_max_requests: int = 100
+
+ # Variance limit for max requests; gunicorn only
+ gunicorn_max_requests_jitter: int = 25
+
+ # Indicate which type of state manager to use
+ state_manager_mode: constants.StateManagerMode = constants.StateManagerMode.DISK
+
# Maximum expiration lock time for redis state manager
redis_lock_expiration: int = constants.Expiration.LOCK
+ # Maximum lock time before warning for redis state manager.
+ redis_lock_warning_threshold: int = constants.Expiration.LOCK_WARNING_THRESHOLD
+
# Token expiration time for redis state manager
redis_token_expiration: int = constants.Expiration.TOKEN
# Attributes that were explicitly set by the user.
_non_default_attributes: Set[str] = pydantic.PrivateAttr(set())
+ # Path to file containing key-values pairs to override in the environment; Dotenv format.
+ env_file: Optional[str] = None
+
def __init__(self, *args, **kwargs):
"""Initialize the config values.
Args:
*args: The args to pass to the Pydantic init method.
**kwargs: The kwargs to pass to the Pydantic init method.
+
+ Raises:
+ ConfigError: If some values in the config are invalid.
"""
super().__init__(*args, **kwargs)
@@ -247,6 +718,14 @@ class Config(Base):
self._non_default_attributes.update(kwargs)
self._replace_defaults(**kwargs)
+ if (
+ self.state_manager_mode == constants.StateManagerMode.REDIS
+ and not self.redis_url
+ ):
+ raise ConfigError(
+ "REDIS_URL is required when using the redis state manager."
+ )
+
@property
def module(self) -> str:
"""Get the module name of the app.
@@ -258,14 +737,21 @@ class Config(Base):
def update_from_env(self) -> dict[str, Any]:
"""Update the config values based on set environment variables.
+ If there is a set env_file, it is loaded first.
Returns:
The updated config values.
-
- Raises:
- EnvVarValueError: If an environment variable is set to an invalid type.
"""
- from reflex.utils.exceptions import EnvVarValueError
+ if self.env_file:
+ try:
+ from dotenv import load_dotenv # type: ignore
+
+ # load env file if exists
+ load_dotenv(self.env_file, override=True)
+ except ImportError:
+ console.error(
+ """The `python-dotenv` package is required to load environment variables from a file. Run `pip install "python-dotenv>=1.0.1"`."""
+ )
updated_values = {}
# Iterate over the fields.
@@ -275,27 +761,19 @@ class Config(Base):
# If the env var is set, override the config value.
if env_var is not None:
- if key.upper() != "DB_URL":
- console.info(
- f"Overriding config value {key} with env var {key.upper()}={env_var}",
- dedupe=True,
- )
-
- # Convert the env var to the expected type.
- try:
- if issubclass(field.type_, bool):
- # special handling for bool values
- env_var = env_var.lower() in ["true", "1", "yes"]
- else:
- env_var = field.type_(env_var)
- except ValueError as ve:
- console.error(
- f"Could not convert {key.upper()}={env_var} to type {field.type_}"
- )
- raise EnvVarValueError from ve
+ # Interpret the value.
+ value = interpret_env_var_value(env_var, field.outer_type_, field.name)
# Set the value.
- updated_values[key] = env_var
+ updated_values[key] = value
+
+ if key.upper() in _sensitive_env_vars:
+ env_var = "***"
+
+ console.info(
+ f"Overriding config value {key} with env var {key.upper()}={env_var}",
+ dedupe=True,
+ )
return updated_values
@@ -354,6 +832,27 @@ class Config(Base):
self._replace_defaults(**kwargs)
+def _get_config() -> Config:
+ """Get the app config.
+
+ Returns:
+ The app config.
+ """
+ # only import the module if it exists. If a module spec exists then
+ # the module exists.
+ spec = find_spec(constants.Config.MODULE)
+ if not spec:
+ # we need this condition to ensure that a ModuleNotFound error is not thrown when
+ # running unit/integration tests or during `reflex init`.
+ return Config(app_name="")
+ rxconfig = importlib.import_module(constants.Config.MODULE)
+ return rxconfig.config
+
+
+# Protect sys.path from concurrent modification
+_config_lock = threading.RLock()
+
+
def get_config(reload: bool = False) -> Config:
"""Get the app config.
@@ -363,15 +862,26 @@ def get_config(reload: bool = False) -> Config:
Returns:
The app config.
"""
- sys.path.insert(0, os.getcwd())
- # only import the module if it exists. If a module spec exists then
- # the module exists.
- spec = importlib.util.find_spec(constants.Config.MODULE) # type: ignore
- if not spec:
- # we need this condition to ensure that a ModuleNotFound error is not thrown when
- # running unit/integration tests.
- return Config(app_name="")
- rxconfig = importlib.import_module(constants.Config.MODULE)
- if reload:
- importlib.reload(rxconfig)
- return rxconfig.config
+ cached_rxconfig = sys.modules.get(constants.Config.MODULE, None)
+ if cached_rxconfig is not None:
+ if reload:
+ # Remove any cached module when `reload` is requested.
+ del sys.modules[constants.Config.MODULE]
+ else:
+ return cached_rxconfig.config
+
+ with _config_lock:
+ sys_path = sys.path.copy()
+ sys.path.clear()
+ sys.path.append(str(Path.cwd()))
+ try:
+ # Try to import the module with only the current directory in the path.
+ return _get_config()
+ except Exception:
+ # If the module import fails, try to import with the original sys.path.
+ sys.path.extend(sys_path)
+ return _get_config()
+ finally:
+ # Restore the original sys.path.
+ sys.path.clear()
+ sys.path.extend(sys_path)
diff --git a/reflex/constants/__init__.py b/reflex/constants/__init__.py
index e974ab915..e816da0f7 100644
--- a/reflex/constants/__init__.py
+++ b/reflex/constants/__init__.py
@@ -2,16 +2,15 @@
from .base import (
COOKIES,
- ENV_MODE_ENV_VAR,
+ IS_LINUX,
+ IS_MACOS,
IS_WINDOWS,
LOCAL_STORAGE,
POLLING_MAX_HTTP_BUFFER_SIZE,
PYTEST_CURRENT_TEST,
REFLEX_VAR_CLOSING_TAG,
REFLEX_VAR_OPENING_TAG,
- RELOAD_CONFIG,
SESSION_STORAGE,
- SKIP_COMPILE_ENV_VAR,
ColorMode,
Dirs,
Env,
@@ -42,16 +41,9 @@ from .config import (
GitIgnore,
RequirementsTxt,
)
-from .custom_components import (
- CustomComponents,
-)
+from .custom_components import CustomComponents
from .event import Endpoint, EventTriggers, SocketEvent
-from .installer import (
- Bun,
- Fnm,
- Node,
- PackageJson,
-)
+from .installer import Bun, Fnm, Node, PackageJson
from .route import (
ROUTE_NOT_FOUND,
ROUTER,
@@ -63,6 +55,7 @@ from .route import (
RouteRegex,
RouteVar,
)
+from .state import StateManagerMode
from .style import Tailwind
__ALL__ = [
@@ -103,7 +96,6 @@ __ALL__ = [
POLLING_MAX_HTTP_BUFFER_SIZE,
PYTEST_CURRENT_TEST,
Reflex,
- RELOAD_CONFIG,
RequirementsTxt,
RouteArgType,
RouteRegex,
@@ -113,8 +105,8 @@ __ALL__ = [
ROUTER_DATA_INCLUDE,
ROUTE_NOT_FOUND,
SETTER_PREFIX,
- SKIP_COMPILE_ENV_VAR,
SocketEvent,
+ StateManagerMode,
Tailwind,
Templates,
CompileVars,
diff --git a/reflex/constants/base.py b/reflex/constants/base.py
index a858a69b1..af96583ad 100644
--- a/reflex/constants/base.py
+++ b/reflex/constants/base.py
@@ -2,15 +2,19 @@
from __future__ import annotations
-import os
import platform
from enum import Enum
from importlib import metadata
+from pathlib import Path
from types import SimpleNamespace
from platformdirs import PlatformDirs
+from .utils import classproperty
+
IS_WINDOWS = platform.system() == "Windows"
+IS_MACOS = platform.system() == "Darwin"
+IS_LINUX = platform.system() == "Linux"
class Dirs(SimpleNamespace):
@@ -19,9 +23,11 @@ class Dirs(SimpleNamespace):
# The frontend directories in a project.
# The web folder where the NextJS app is compiled to.
WEB = ".web"
+ # The directory where uploaded files are stored.
+ UPLOADED_FILES = "uploaded_files"
# The name of the assets directory.
APP_ASSETS = "assets"
- # The name of the assets directory for external ressource (a subfolder of APP_ASSETS).
+ # The name of the assets directory for external resources (a subfolder of APP_ASSETS).
EXTERNAL_APP_ASSETS = "external"
# The name of the utils file.
UTILS = "utils"
@@ -45,6 +51,8 @@ class Dirs(SimpleNamespace):
REFLEX_JSON = "reflex.json"
# The name of the postcss config file.
POSTCSS_JS = "postcss.config.js"
+ # The name of the states directory.
+ STATES = "states"
class Reflex(SimpleNamespace):
@@ -61,23 +69,16 @@ class Reflex(SimpleNamespace):
# Files and directories used to init a new project.
# The directory to store reflex dependencies.
- # Get directory value from enviroment variables if it exists.
- _dir = os.environ.get("REFLEX_DIR", "")
+ # on windows, we use C:/Users//AppData/Local/reflex.
+ # on macOS, we use ~/Library/Application Support/reflex.
+ # on linux, we use ~/.local/share/reflex.
+ # If user sets REFLEX_DIR envroment variable use that instead.
+ DIR = PlatformDirs(MODULE_NAME, False).user_data_path
- DIR = _dir or (
- # on windows, we use C:/Users//AppData/Local/reflex.
- # on macOS, we use ~/Library/Application Support/reflex.
- # on linux, we use ~/.local/share/reflex.
- # If user sets REFLEX_DIR envroment variable use that instead.
- PlatformDirs(MODULE_NAME, False).user_data_dir
- )
# The root directory of the reflex library.
+ ROOT_DIR = Path(__file__).parents[2]
- ROOT_DIR = os.path.dirname(
- os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- )
-
- RELEASES_URL = f"https://api.github.com/repos/reflex-dev/templates/releases"
+ RELEASES_URL = "https://api.github.com/repos/reflex-dev/templates/releases"
class ReflexHostingCLI(SimpleNamespace):
@@ -96,36 +97,75 @@ class Templates(SimpleNamespace):
# The default template
DEFAULT = "blank"
+ # The AI template
+ AI = "ai"
+
+ # The option for the user to choose a remote template.
+ CHOOSE_TEMPLATES = "choose-templates"
+
+ # The URL to find reflex templates.
+ REFLEX_TEMPLATES_URL = "https://reflex.dev/templates"
+
+ # Demo url for the default template.
+ DEFAULT_TEMPLATE_URL = "https://blank-template.reflex.run"
+
# The reflex.build frontend host
- REFLEX_BUILD_FRONTEND = os.environ.get(
- "REFLEX_BUILD_FRONTEND", "https://flexgen.reflex.run"
- )
+ REFLEX_BUILD_FRONTEND = "https://flexgen.reflex.run"
# The reflex.build backend host
- REFLEX_BUILD_BACKEND = os.environ.get(
- "REFLEX_BUILD_BACKEND", "https://rxh-prod-flexgen.fly.dev"
- )
+ REFLEX_BUILD_BACKEND = "https://flexgen-prod-flexgen.fly.dev"
- # The URL to redirect to reflex.build
- REFLEX_BUILD_URL = (
- REFLEX_BUILD_FRONTEND + "/gen?reflex_init_token={reflex_init_token}"
- )
+ @classproperty
+ @classmethod
+ def REFLEX_BUILD_URL(cls):
+ """The URL to redirect to reflex.build.
- # The URL to poll waiting for the user to select a generation.
- REFLEX_BUILD_POLL_URL = REFLEX_BUILD_BACKEND + "/api/init/{reflex_init_token}"
+ Returns:
+ The URL to redirect to reflex.build.
+ """
+ from reflex.config import environment
- # The URL to fetch the generation's reflex code
- REFLEX_BUILD_CODE_URL = REFLEX_BUILD_BACKEND + "/api/gen/{generation_hash}"
+ return (
+ environment.REFLEX_BUILD_FRONTEND.get()
+ + "/gen?reflex_init_token={reflex_init_token}"
+ )
+
+ @classproperty
+ @classmethod
+ def REFLEX_BUILD_POLL_URL(cls):
+ """The URL to poll waiting for the user to select a generation.
+
+ Returns:
+ The URL to poll waiting for the user to select a generation.
+ """
+ from reflex.config import environment
+
+ return environment.REFLEX_BUILD_BACKEND.get() + "/api/init/{reflex_init_token}"
+
+ @classproperty
+ @classmethod
+ def REFLEX_BUILD_CODE_URL(cls):
+ """The URL to fetch the generation's reflex code.
+
+ Returns:
+ The URL to fetch the generation's reflex code.
+ """
+ from reflex.config import environment
+
+ return (
+ environment.REFLEX_BUILD_BACKEND.get()
+ + "/api/gen/{generation_hash}/refactored"
+ )
class Dirs(SimpleNamespace):
"""Folders used by the template system of Reflex."""
# The template directory used during reflex init.
- BASE = os.path.join(Reflex.ROOT_DIR, Reflex.MODULE_NAME, ".templates")
+ BASE = Reflex.ROOT_DIR / Reflex.MODULE_NAME / ".templates"
# The web subdirectory of the template directory.
- WEB_TEMPLATE = os.path.join(BASE, "web")
+ WEB_TEMPLATE = BASE / "web"
# The jinja template directory.
- JINJA_TEMPLATE = os.path.join(BASE, "jinja")
+ JINJA_TEMPLATE = BASE / "jinja"
# Where the code for the templates is stored.
CODE = "code"
@@ -169,6 +209,7 @@ class LogLevel(str, Enum):
"""The log levels."""
DEBUG = "debug"
+ DEFAULT = "default"
INFO = "info"
WARNING = "warning"
ERROR = "error"
@@ -186,6 +227,14 @@ class LogLevel(str, Enum):
levels = list(LogLevel)
return levels.index(self) <= levels.index(other)
+ def subprocess_level(self):
+ """Return the log level for the subprocess.
+
+ Returns:
+ The log level for the subprocess
+ """
+ return self if self != LogLevel.DEFAULT else LogLevel.WARNING
+
# Server socket configuration variables
POLLING_MAX_HTTP_BUFFER_SIZE = 1000 * 1000
@@ -205,16 +254,9 @@ COOKIES = "cookies"
LOCAL_STORAGE = "local_storage"
SESSION_STORAGE = "session_storage"
-# If this env var is set to "yes", App.compile will be a no-op
-SKIP_COMPILE_ENV_VAR = "__REFLEX_SKIP_COMPILE"
-
-# This env var stores the execution mode of the app
-ENV_MODE_ENV_VAR = "REFLEX_ENV_MODE"
-
# Testing variables.
# Testing os env set by pytest when running a test case.
PYTEST_CURRENT_TEST = "PYTEST_CURRENT_TEST"
-RELOAD_CONFIG = "__REFLEX_RELOAD_CONFIG"
REFLEX_VAR_OPENING_TAG = ""
REFLEX_VAR_CLOSING_TAG = " "
diff --git a/reflex/constants/colors.py b/reflex/constants/colors.py
index ddd093f25..60942c775 100644
--- a/reflex/constants/colors.py
+++ b/reflex/constants/colors.py
@@ -35,7 +35,6 @@ ColorType = Literal[
"amber",
"gold",
"bronze",
- "gray",
"accent",
"black",
"white",
diff --git a/reflex/constants/compiler.py b/reflex/constants/compiler.py
index 1de3fc263..7ca55f4dd 100644
--- a/reflex/constants/compiler.py
+++ b/reflex/constants/compiler.py
@@ -114,8 +114,8 @@ class Imports(SimpleNamespace):
EVENTS = {
"react": [ImportVar(tag="useContext")],
- f"/{Dirs.CONTEXTS_PATH}": [ImportVar(tag="EventLoopContext")],
- f"/{Dirs.STATE_PATH}": [ImportVar(tag=CompileVars.TO_EVENT)],
+ f"$/{Dirs.CONTEXTS_PATH}": [ImportVar(tag="EventLoopContext")],
+ f"$/{Dirs.STATE_PATH}": [ImportVar(tag=CompileVars.TO_EVENT)],
}
@@ -132,15 +132,11 @@ class Hooks(SimpleNamespace):
}
})"""
- FRONTEND_ERRORS = f"""
- const logFrontendError = (error, info) => {{
- if (process.env.NODE_ENV === "production") {{
- addEvents([Event("{CompileVars.FRONTEND_EXCEPTION_STATE_FULL}.handle_frontend_exception", {{
- stack: error.stack,
- }})])
- }}
- }}
- """
+ class HookPosition(enum.Enum):
+ """The position of the hook in the component."""
+
+ PRE_TRIGGER = "pre_trigger"
+ POST_TRIGGER = "post_trigger"
class MemoizationDisposition(enum.Enum):
@@ -160,3 +156,28 @@ class MemoizationMode(Base):
# Whether children of this component should be memoized first.
recursive: bool = True
+
+
+class SpecialAttributes(enum.Enum):
+ """Special attributes for components.
+
+ These are placed in custom_attrs and rendered as-is rather than converting
+ to a style prop.
+ """
+
+ DATA_UNDERSCORE = "data_"
+ DATA_DASH = "data-"
+ ARIA_UNDERSCORE = "aria_"
+ ARIA_DASH = "aria-"
+
+ @classmethod
+ def is_special(cls, attr: str) -> bool:
+ """Check if the attribute is special.
+
+ Args:
+ attr: the attribute to check
+
+ Returns:
+ True if the attribute is special.
+ """
+ return any(attr.startswith(value.value) for value in cls)
diff --git a/reflex/constants/config.py b/reflex/constants/config.py
index 966727426..7425fd864 100644
--- a/reflex/constants/config.py
+++ b/reflex/constants/config.py
@@ -1,6 +1,6 @@
"""Config constants."""
-import os
+from pathlib import Path
from types import SimpleNamespace
from reflex.constants.base import Dirs, Reflex
@@ -8,7 +8,7 @@ from reflex.constants.base import Dirs, Reflex
from .compiler import Ext
# Alembic migrations
-ALEMBIC_CONFIG = os.environ.get("ALEMBIC_CONFIG", "alembic.ini")
+ALEMBIC_CONFIG = "alembic.ini"
class Config(SimpleNamespace):
@@ -17,9 +17,7 @@ class Config(SimpleNamespace):
# The name of the reflex config module.
MODULE = "rxconfig"
# The python config file.
- FILE = f"{MODULE}{Ext.PY}"
- # The previous config file.
- PREVIOUS_FILE = f"pcconfig{Ext.PY}"
+ FILE = Path(f"{MODULE}{Ext.PY}")
class Expiration(SimpleNamespace):
@@ -31,13 +29,15 @@ class Expiration(SimpleNamespace):
LOCK = 10000
# The PING timeout
PING = 120
+ # The maximum time in milliseconds to hold a lock before throwing a warning.
+ LOCK_WARNING_THRESHOLD = 1000
class GitIgnore(SimpleNamespace):
"""Gitignore constants."""
# The gitignore file.
- FILE = ".gitignore"
+ FILE = Path(".gitignore")
# Files to gitignore.
DEFAULTS = {Dirs.WEB, "*.db", "__pycache__/", "*.py[cod]", "assets/external/"}
diff --git a/reflex/constants/custom_components.py b/reflex/constants/custom_components.py
index 3ea9cf6ed..a499327b1 100644
--- a/reflex/constants/custom_components.py
+++ b/reflex/constants/custom_components.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+from pathlib import Path
from types import SimpleNamespace
@@ -9,11 +10,11 @@ class CustomComponents(SimpleNamespace):
"""Constants for the custom components."""
# The name of the custom components source directory.
- SRC_DIR = "custom_components"
+ SRC_DIR = Path("custom_components")
# The name of the custom components pyproject.toml file.
- PYPROJECT_TOML = "pyproject.toml"
+ PYPROJECT_TOML = Path("pyproject.toml")
# The name of the custom components package README file.
- PACKAGE_README = "README.md"
+ PACKAGE_README = Path("README.md")
# The name of the custom components package .gitignore file.
PACKAGE_GITIGNORE = ".gitignore"
# The name of the distribution directory as result of a build.
@@ -29,6 +30,6 @@ class CustomComponents(SimpleNamespace):
"testpypi": "https://test.pypi.org/legacy/",
}
# The .gitignore file for the custom component project.
- FILE = ".gitignore"
+ FILE = Path(".gitignore")
# Files to gitignore.
DEFAULTS = {"__pycache__/", "*.py[cod]", "*.egg-info/", "dist/"}
diff --git a/reflex/constants/event.py b/reflex/constants/event.py
index 351a1ac52..d454e6ea8 100644
--- a/reflex/constants/event.py
+++ b/reflex/constants/event.py
@@ -11,6 +11,7 @@ class Endpoint(Enum):
EVENT = "_event"
UPLOAD = "_upload"
AUTH_CODESPACE = "auth-codespace"
+ HEALTH = "_health"
def __str__(self) -> str:
"""Get the string representation of the endpoint.
diff --git a/reflex/constants/installer.py b/reflex/constants/installer.py
index 4a7027ee8..0b45586dd 100644
--- a/reflex/constants/installer.py
+++ b/reflex/constants/installer.py
@@ -2,11 +2,12 @@
from __future__ import annotations
-import os
import platform
+from pathlib import Path
from types import SimpleNamespace
-from .base import IS_WINDOWS, Reflex
+from .base import IS_WINDOWS
+from .utils import classproperty
def get_fnm_name() -> str | None:
@@ -36,24 +37,49 @@ class Bun(SimpleNamespace):
"""Bun constants."""
# The Bun version.
- VERSION = "1.1.10"
+ VERSION = "1.1.29"
+
# Min Bun Version
MIN_VERSION = "0.7.0"
- # The directory to store the bun.
- ROOT_PATH = os.path.join(Reflex.DIR, "bun")
- # Default bun path.
- DEFAULT_PATH = os.path.join(
- ROOT_PATH, "bin", "bun" if not IS_WINDOWS else "bun.exe"
- )
+
# URL to bun install script.
- INSTALL_URL = "https://bun.sh/install"
+ INSTALL_URL = "https://raw.githubusercontent.com/reflex-dev/reflex/main/scripts/bun_install.sh"
+
# URL to windows install script.
WINDOWS_INSTALL_URL = (
"https://raw.githubusercontent.com/reflex-dev/reflex/main/scripts/install.ps1"
)
+
# Path of the bunfig file
CONFIG_PATH = "bunfig.toml"
+ @classproperty
+ @classmethod
+ def ROOT_PATH(cls):
+ """The directory to store the bun.
+
+ Returns:
+ The directory to store the bun.
+ """
+ from reflex.config import environment
+
+ return environment.REFLEX_DIR.get() / "bun"
+
+ @classproperty
+ @classmethod
+ def DEFAULT_PATH(cls):
+ """Default bun path.
+
+ Returns:
+ The default bun path.
+ """
+ return cls.ROOT_PATH / "bin" / ("bun" if not IS_WINDOWS else "bun.exe")
+
+ DEFAULT_CONFIG = """
+[install]
+registry = "{registry}"
+"""
+
# FNM config.
class Fnm(SimpleNamespace):
@@ -61,40 +87,81 @@ class Fnm(SimpleNamespace):
# The FNM version.
VERSION = "1.35.1"
- # The directory to store fnm.
- DIR = os.path.join(Reflex.DIR, "fnm")
+
FILENAME = get_fnm_name()
- # The fnm executable binary.
- EXE = os.path.join(DIR, "fnm.exe" if IS_WINDOWS else "fnm")
# The URL to the fnm release binary
INSTALL_URL = (
f"https://github.com/Schniz/fnm/releases/download/v{VERSION}/{FILENAME}.zip"
)
+ @classproperty
+ @classmethod
+ def DIR(cls) -> Path:
+ """The directory to store fnm.
+
+ Returns:
+ The directory to store fnm.
+ """
+ from reflex.config import environment
+
+ return environment.REFLEX_DIR.get() / "fnm"
+
+ @classproperty
+ @classmethod
+ def EXE(cls):
+ """The fnm executable binary.
+
+ Returns:
+ The fnm executable binary.
+ """
+ return cls.DIR / ("fnm.exe" if IS_WINDOWS else "fnm")
+
# Node / NPM config
class Node(SimpleNamespace):
"""Node/ NPM constants."""
# The Node version.
- VERSION = "18.17.0"
+ VERSION = "22.11.0"
# The minimum required node version.
- MIN_VERSION = "18.17.0"
+ MIN_VERSION = "18.18.0"
- # The node bin path.
- BIN_PATH = os.path.join(
- Fnm.DIR,
- "node-versions",
- f"v{VERSION}",
- "installation",
- "bin" if not IS_WINDOWS else "",
- )
- # The default path where node is installed.
- PATH = os.path.join(BIN_PATH, "node.exe" if IS_WINDOWS else "node")
+ @classproperty
+ @classmethod
+ def BIN_PATH(cls):
+ """The node bin path.
- # The default path where npm is installed.
- NPM_PATH = os.path.join(BIN_PATH, "npm")
+ Returns:
+ The node bin path.
+ """
+ return (
+ Fnm.DIR
+ / "node-versions"
+ / f"v{cls.VERSION}"
+ / "installation"
+ / ("bin" if not IS_WINDOWS else "")
+ )
+
+ @classproperty
+ @classmethod
+ def PATH(cls):
+ """The default path where node is installed.
+
+ Returns:
+ The default path where node is installed.
+ """
+ return cls.BIN_PATH / ("node.exe" if IS_WINDOWS else "node")
+
+ @classproperty
+ @classmethod
+ def NPM_PATH(cls):
+ """The default path where npm is installed.
+
+ Returns:
+ The default path where npm is installed.
+ """
+ return cls.BIN_PATH / "npm"
class PackageJson(SimpleNamespace):
@@ -111,20 +178,21 @@ class PackageJson(SimpleNamespace):
PATH = "package.json"
DEPENDENCIES = {
- "@emotion/react": "11.11.1",
- "axios": "1.6.0",
+ "@babel/standalone": "7.26.0",
+ "@emotion/react": "11.13.3",
+ "axios": "1.7.7",
"json5": "2.2.3",
- "next": "14.0.1",
- "next-sitemap": "4.1.8",
- "next-themes": "0.2.1",
- "react": "18.2.0",
- "react-dom": "18.2.0",
- "react-focus-lock": "2.11.3",
- "socket.io-client": "4.6.1",
- "universal-cookie": "4.0.4",
+ "next": "14.2.16",
+ "next-sitemap": "4.2.3",
+ "next-themes": "0.4.3",
+ "react": "18.3.1",
+ "react-dom": "18.3.1",
+ "react-focus-lock": "2.13.2",
+ "socket.io-client": "4.8.1",
+ "universal-cookie": "7.2.2",
}
DEV_DEPENDENCIES = {
- "autoprefixer": "10.4.14",
- "postcss": "8.4.31",
+ "autoprefixer": "10.4.20",
+ "postcss": "8.4.49",
"postcss-import": "16.1.0",
}
diff --git a/reflex/constants/route.py b/reflex/constants/route.py
index 2af2f33c6..ab00fab15 100644
--- a/reflex/constants/route.py
+++ b/reflex/constants/route.py
@@ -31,7 +31,7 @@ class RouteVar(SimpleNamespace):
# This subset of router_data is included in chained on_load events.
-ROUTER_DATA_INCLUDE = set((RouteVar.PATH, RouteVar.ORIGIN, RouteVar.QUERY))
+ROUTER_DATA_INCLUDE = {RouteVar.PATH, RouteVar.ORIGIN, RouteVar.QUERY}
class RouteRegex(SimpleNamespace):
diff --git a/reflex/constants/state.py b/reflex/constants/state.py
new file mode 100644
index 000000000..5ce7cd62a
--- /dev/null
+++ b/reflex/constants/state.py
@@ -0,0 +1,15 @@
+"""State-related constants."""
+
+from enum import Enum
+
+
+class StateManagerMode(str, Enum):
+ """State manager constants."""
+
+ DISK = "disk"
+ MEMORY = "memory"
+ REDIS = "redis"
+
+
+# Used for things like console_log, etc.
+FRONTEND_EVENT_STATE = "__reflex_internal_frontend_event_state"
diff --git a/reflex/constants/style.py b/reflex/constants/style.py
index 2130ab4e0..a1d30bcca 100644
--- a/reflex/constants/style.py
+++ b/reflex/constants/style.py
@@ -7,7 +7,7 @@ class Tailwind(SimpleNamespace):
"""Tailwind constants."""
# The Tailwindcss version
- VERSION = "tailwindcss@3.3.2"
+ VERSION = "tailwindcss@3.4.15"
# The Tailwind config.
CONFIG = "tailwind.config.js"
# Default Tailwind content paths
diff --git a/reflex/constants/utils.py b/reflex/constants/utils.py
new file mode 100644
index 000000000..48797afbf
--- /dev/null
+++ b/reflex/constants/utils.py
@@ -0,0 +1,32 @@
+"""Utility functions for constants."""
+
+from typing import Any, Callable, Generic, Type
+
+from typing_extensions import TypeVar
+
+T = TypeVar("T")
+V = TypeVar("V")
+
+
+class classproperty(Generic[T, V]):
+ """A class property decorator."""
+
+ def __init__(self, getter: Callable[[Type[T]], V]) -> None:
+ """Initialize the class property.
+
+ Args:
+ getter: The getter function.
+ """
+ self.getter = getattr(getter, "__func__", getter)
+
+ def __get__(self, instance: Any, owner: Type[T]) -> V:
+ """Get the value of the class property.
+
+ Args:
+ instance: The instance of the class.
+ owner: The class itself.
+
+ Returns:
+ The value of the class property.
+ """
+ return self.getter(owner)
diff --git a/reflex/custom_components/custom_components.py b/reflex/custom_components/custom_components.py
index a47de6feb..4a169802f 100644
--- a/reflex/custom_components/custom_components.py
+++ b/reflex/custom_components/custom_components.py
@@ -17,7 +17,7 @@ import typer
from tomlkit.exceptions import TOMLKitError
from reflex import constants
-from reflex.config import get_config
+from reflex.config import environment, get_config
from reflex.constants import CustomComponents
from reflex.utils import console
@@ -36,7 +36,7 @@ POST_CUSTOM_COMPONENTS_GALLERY_TIMEOUT = 15
@contextmanager
-def set_directory(working_directory: str):
+def set_directory(working_directory: str | Path):
"""Context manager that sets the working directory.
Args:
@@ -45,7 +45,8 @@ def set_directory(working_directory: str):
Yields:
Yield to the caller to perform operations in the working directory.
"""
- current_directory = os.getcwd()
+ current_directory = Path.cwd()
+ working_directory = Path(working_directory)
try:
os.chdir(working_directory)
yield
@@ -62,12 +63,14 @@ def _create_package_config(module_name: str, package_name: str):
"""
from reflex.compiler import templates
- with open(CustomComponents.PYPROJECT_TOML, "w") as f:
- f.write(
- templates.CUSTOM_COMPONENTS_PYPROJECT_TOML.render(
- module_name=module_name, package_name=package_name
- )
+ pyproject = Path(CustomComponents.PYPROJECT_TOML)
+ pyproject.write_text(
+ templates.CUSTOM_COMPONENTS_PYPROJECT_TOML.render(
+ module_name=module_name,
+ package_name=package_name,
+ reflex_version=constants.Reflex.VERSION,
)
+ )
def _get_package_config(exit_on_fail: bool = True) -> dict:
@@ -82,11 +85,11 @@ def _get_package_config(exit_on_fail: bool = True) -> dict:
Raises:
Exit: If the pyproject.toml file is not found.
"""
+ pyproject = Path(CustomComponents.PYPROJECT_TOML)
try:
- with open(CustomComponents.PYPROJECT_TOML, "rb") as f:
- return dict(tomlkit.load(f))
+ return dict(tomlkit.loads(pyproject.read_bytes()))
except (OSError, TOMLKitError) as ex:
- console.error(f"Unable to read from pyproject.toml due to {ex}")
+ console.error(f"Unable to read from {pyproject} due to {ex}")
if exit_on_fail:
raise typer.Exit(code=1) from ex
raise
@@ -101,17 +104,17 @@ def _create_readme(module_name: str, package_name: str):
"""
from reflex.compiler import templates
- with open(CustomComponents.PACKAGE_README, "w") as f:
- f.write(
- templates.CUSTOM_COMPONENTS_README.render(
- module_name=module_name,
- package_name=package_name,
- )
+ readme = Path(CustomComponents.PACKAGE_README)
+ readme.write_text(
+ templates.CUSTOM_COMPONENTS_README.render(
+ module_name=module_name,
+ package_name=package_name,
)
+ )
def _write_source_and_init_py(
- custom_component_src_dir: str,
+ custom_component_src_dir: Path,
component_class_name: str,
module_name: str,
):
@@ -124,27 +127,17 @@ def _write_source_and_init_py(
"""
from reflex.compiler import templates
- with open(
- os.path.join(
- custom_component_src_dir,
- f"{module_name}.py",
- ),
- "w",
- ) as f:
- f.write(
- templates.CUSTOM_COMPONENTS_SOURCE.render(
- component_class_name=component_class_name, module_name=module_name
- )
+ module_path = custom_component_src_dir / f"{module_name}.py"
+ module_path.write_text(
+ templates.CUSTOM_COMPONENTS_SOURCE.render(
+ component_class_name=component_class_name, module_name=module_name
)
+ )
- with open(
- os.path.join(
- custom_component_src_dir,
- CustomComponents.INIT_FILE,
- ),
- "w",
- ) as f:
- f.write(templates.CUSTOM_COMPONENTS_INIT_FILE.render(module_name=module_name))
+ init_path = custom_component_src_dir / CustomComponents.INIT_FILE
+ init_path.write_text(
+ templates.CUSTOM_COMPONENTS_INIT_FILE.render(module_name=module_name)
+ )
def _populate_demo_app(name_variants: NameVariants):
@@ -157,27 +150,27 @@ def _populate_demo_app(name_variants: NameVariants):
from reflex.compiler import templates
from reflex.reflex import _init
- demo_app_dir = name_variants.demo_app_dir
+ demo_app_dir = Path(name_variants.demo_app_dir)
demo_app_name = name_variants.demo_app_name
- console.info(f"Creating app for testing: {demo_app_dir}")
+ console.info(f"Creating app for testing: {demo_app_dir!s}")
- os.makedirs(demo_app_dir)
+ demo_app_dir.mkdir(exist_ok=True)
with set_directory(demo_app_dir):
# We start with the blank template as basis.
_init(name=demo_app_name, template=constants.Templates.DEFAULT)
# Then overwrite the app source file with the one we want for testing custom components.
# This source file is rendered using jinja template file.
- with open(f"{demo_app_name}/{demo_app_name}.py", "w") as f:
- f.write(
- templates.CUSTOM_COMPONENTS_DEMO_APP.render(
- custom_component_module_dir=name_variants.custom_component_module_dir,
- module_name=name_variants.module_name,
- )
+ demo_file = Path(f"{demo_app_name}/{demo_app_name}.py")
+ demo_file.write_text(
+ templates.CUSTOM_COMPONENTS_DEMO_APP.render(
+ custom_component_module_dir=name_variants.custom_component_module_dir,
+ module_name=name_variants.module_name,
)
+ )
# Append the custom component package to the requirements.txt file.
- with open(f"{constants.RequirementsTxt.FILE}", "a") as f:
+ with Path(f"{constants.RequirementsTxt.FILE}").open(mode="a") as f:
f.write(f"{name_variants.package_name}\n")
@@ -190,7 +183,7 @@ def _get_default_library_name_parts() -> list[str]:
Returns:
The parts of default library name.
"""
- current_dir_name = os.getcwd().split(os.path.sep)[-1]
+ current_dir_name = Path.cwd().name
cleaned_dir_name = re.sub("[^0-9a-zA-Z-_]+", "", current_dir_name).lower()
parts = [part for part in re.split("-|_", cleaned_dir_name) if part]
@@ -267,7 +260,7 @@ def _validate_library_name(library_name: str | None) -> NameVariants:
# Module name is the snake case.
module_name = "_".join(name_parts)
- custom_component_module_dir = f"reflex_{module_name}"
+ custom_component_module_dir = Path(f"reflex_{module_name}")
console.debug(f"Custom component source directory: {custom_component_module_dir}")
# Use the same name for the directory and the app.
@@ -303,13 +296,14 @@ def _populate_custom_component_project(name_variants: NameVariants):
)
console.info(
- f"Initializing the component directory: {CustomComponents.SRC_DIR}/{name_variants.custom_component_module_dir}"
+ f"Initializing the component directory: {CustomComponents.SRC_DIR / name_variants.custom_component_module_dir}"
)
- os.makedirs(CustomComponents.SRC_DIR)
+ CustomComponents.SRC_DIR.mkdir(exist_ok=True)
with set_directory(CustomComponents.SRC_DIR):
- os.makedirs(name_variants.custom_component_module_dir)
+ module_dir = Path(name_variants.custom_component_module_dir)
+ module_dir.mkdir(exist_ok=True, parents=True)
_write_source_and_init_py(
- custom_component_src_dir=name_variants.custom_component_module_dir,
+ custom_component_src_dir=module_dir,
component_class_name=name_variants.component_class_name,
module_name=name_variants.module_name,
)
@@ -343,7 +337,7 @@ def init(
console.set_log_level(loglevel)
- if os.path.exists(CustomComponents.PYPROJECT_TOML):
+ if CustomComponents.PYPROJECT_TOML.exists():
console.error(f"A {CustomComponents.PYPROJECT_TOML} already exists. Aborting.")
typer.Exit(code=1)
@@ -616,14 +610,14 @@ def publish(
help="The API token to use for authentication on python package repository. If token is provided, no username/password should be provided at the same time",
),
username: Optional[str] = typer.Option(
- os.getenv("TWINE_USERNAME"),
+ environment.TWINE_USERNAME.get(),
"-u",
"--username",
show_default="TWINE_USERNAME environment variable value if set",
help="The username to use for authentication on python package repository. Username and password must both be provided.",
),
password: Optional[str] = typer.Option(
- os.getenv("TWINE_PASSWORD"),
+ environment.TWINE_PASSWORD.get(),
"-p",
"--password",
show_default="TWINE_PASSWORD environment variable value if set",
@@ -786,8 +780,8 @@ def _validate_project_info():
)
# PyPI only shows the first author.
author = project.get("authors", [{}])[0]
- author["name"] = console.ask(f"Author Name", default=author.get("name", ""))
- author["email"] = console.ask(f"Author Email", default=author.get("email", ""))
+ author["name"] = console.ask("Author Name", default=author.get("name", ""))
+ author["email"] = console.ask("Author Email", default=author.get("email", ""))
console.print(f'Current keywords are: {project.get("keywords") or []}')
keyword_action = console.ask(
@@ -821,7 +815,7 @@ def _validate_project_info():
)
pyproject_toml["project"] = project
try:
- with open(CustomComponents.PYPROJECT_TOML, "w") as f:
+ with CustomComponents.PYPROJECT_TOML.open("w") as f:
tomlkit.dump(pyproject_toml, f)
except (OSError, TOMLKitError) as ex:
console.error(f"Unable to write to pyproject.toml due to {ex}")
@@ -834,11 +828,11 @@ def _collect_details_for_gallery():
Raises:
Exit: If pyproject.toml file is ill-formed or the request to the backend services fails.
"""
- from reflex.reflex import _login
+ from reflex_cli.utils import hosting
console.rule("[bold]Authentication with Reflex Services")
console.print("First let's log in to Reflex backend services.")
- access_token = _login()
+ access_token, _ = hosting.authenticated_token()
console.rule("[bold]Custom Component Information")
params = {}
@@ -929,16 +923,15 @@ def _validate_url_with_protocol_prefix(url: str | None) -> bool:
def _get_file_from_prompt_in_loop() -> Tuple[bytes, str] | None:
image_file = file_extension = None
while image_file is None:
- image_filepath = console.ask(
- f"Upload a preview image of your demo app (enter to skip)"
+ image_filepath = Path(
+ console.ask("Upload a preview image of your demo app (enter to skip)")
)
if not image_filepath:
break
- file_extension = image_filepath.split(".")[-1]
+ file_extension = image_filepath.suffix
try:
- with open(image_filepath, "rb") as f:
- image_file = f.read()
- return image_file, file_extension
+ image_file = image_filepath.read_bytes()
+ return image_file, file_extension
except OSError as ose:
console.error(f"Unable to read the {file_extension} file due to {ose}")
raise typer.Exit(code=1) from ose
@@ -980,6 +973,6 @@ def install(
console.set_log_level(loglevel)
if _pip_install_on_demand(package_name=".", install_args=["-e"]):
- console.info(f"Package installed successfully!")
+ console.info("Package installed successfully!")
else:
raise typer.Exit(code=1)
diff --git a/reflex/event.py b/reflex/event.py
index 7e98ade38..e4ca55c70 100644
--- a/reflex/event.py
+++ b/reflex/event.py
@@ -2,25 +2,58 @@
from __future__ import annotations
+import dataclasses
import inspect
+import sys
+import types
import urllib.parse
from base64 import b64encode
+from functools import partial
from typing import (
+ TYPE_CHECKING,
Any,
Callable,
Dict,
+ Generic,
List,
Optional,
+ Sequence,
Tuple,
+ Type,
Union,
get_type_hints,
+ overload,
+)
+
+import typing_extensions
+from typing_extensions import (
+ Concatenate,
+ ParamSpec,
+ Protocol,
+ TypeAliasType,
+ TypedDict,
+ TypeVar,
+ get_args,
+ get_origin,
)
from reflex import constants
-from reflex.base import Base
-from reflex.utils import format
-from reflex.utils.types import ArgsSpec
-from reflex.vars import BaseVar, Var
+from reflex.constants.state import FRONTEND_EVENT_STATE
+from reflex.utils import console, format
+from reflex.utils.exceptions import EventFnArgMismatch, EventHandlerArgTypeMismatch
+from reflex.utils.types import ArgsSpec, GenericType, typehint_issubclass
+from reflex.vars import VarData
+from reflex.vars.base import LiteralVar, Var
+from reflex.vars.function import (
+ ArgsFunctionOperation,
+ ArgsFunctionOperationBuilder,
+ BuilderFunctionVar,
+ FunctionArgs,
+ FunctionStringVar,
+ FunctionVar,
+ VarOperationCall,
+)
+from reflex.vars.object import ObjectVar
try:
from typing import Annotated
@@ -28,7 +61,11 @@ except ImportError:
from typing_extensions import Annotated
-class Event(Base):
+@dataclasses.dataclass(
+ init=True,
+ frozen=True,
+)
+class Event:
"""An event that describes any state change in the app."""
# The token to specify the client that the event is for.
@@ -38,10 +75,10 @@ class Event(Base):
name: str
# The routing data where event occurred
- router_data: Dict[str, Any] = {}
+ router_data: Dict[str, Any] = dataclasses.field(default_factory=dict)
# The event payload.
- payload: Dict[str, Any] = {}
+ payload: Dict[str, Any] = dataclasses.field(default_factory=dict)
@property
def substate_token(self) -> str:
@@ -57,7 +94,7 @@ class Event(Base):
BACKGROUND_TASK_MARKER = "_reflex_background_task"
-def background(fn):
+def background(fn, *, __internal_reflex_call: bool = False):
"""Decorator to mark event handler as running in the background.
Args:
@@ -70,17 +107,28 @@ def background(fn):
Raises:
TypeError: If the function is not a coroutine function or async generator.
"""
+ if not __internal_reflex_call:
+ console.deprecate(
+ "background-decorator",
+ "Use `rx.event(background=True)` instead.",
+ "0.6.5",
+ "0.7.0",
+ )
if not inspect.iscoroutinefunction(fn) and not inspect.isasyncgenfunction(fn):
raise TypeError("Background task must be async function or generator.")
setattr(fn, BACKGROUND_TASK_MARKER, True)
return fn
-class EventActionsMixin(Base):
+@dataclasses.dataclass(
+ init=True,
+ frozen=True,
+)
+class EventActionsMixin:
"""Mixin for DOM event actions."""
# Whether to `preventDefault` or `stopPropagation` on the event.
- event_actions: Dict[str, Union[bool, int]] = {}
+ event_actions: Dict[str, Union[bool, int]] = dataclasses.field(default_factory=dict)
@property
def stop_propagation(self):
@@ -89,8 +137,9 @@ class EventActionsMixin(Base):
Returns:
New EventHandler-like with stopPropagation set to True.
"""
- return self.copy(
- update={"event_actions": {"stopPropagation": True, **self.event_actions}},
+ return dataclasses.replace(
+ self,
+ event_actions={"stopPropagation": True, **self.event_actions},
)
@property
@@ -100,8 +149,9 @@ class EventActionsMixin(Base):
Returns:
New EventHandler-like with preventDefault set to True.
"""
- return self.copy(
- update={"event_actions": {"preventDefault": True, **self.event_actions}},
+ return dataclasses.replace(
+ self,
+ event_actions={"preventDefault": True, **self.event_actions},
)
def throttle(self, limit_ms: int):
@@ -113,8 +163,9 @@ class EventActionsMixin(Base):
Returns:
New EventHandler-like with throttle set to limit_ms.
"""
- return self.copy(
- update={"event_actions": {"throttle": limit_ms, **self.event_actions}},
+ return dataclasses.replace(
+ self,
+ event_actions={"throttle": limit_ms, **self.event_actions},
)
def debounce(self, delay_ms: int):
@@ -126,26 +177,37 @@ class EventActionsMixin(Base):
Returns:
New EventHandler-like with debounce set to delay_ms.
"""
- return self.copy(
- update={"event_actions": {"debounce": delay_ms, **self.event_actions}},
+ return dataclasses.replace(
+ self,
+ event_actions={"debounce": delay_ms, **self.event_actions},
+ )
+
+ @property
+ def temporal(self):
+ """Do not queue the event if the backend is down.
+
+ Returns:
+ New EventHandler-like with temporal set to True.
+ """
+ return dataclasses.replace(
+ self,
+ event_actions={"temporal": True, **self.event_actions},
)
+@dataclasses.dataclass(
+ init=True,
+ frozen=True,
+)
class EventHandler(EventActionsMixin):
"""An event handler responds to an event to update the state."""
# The function to call in response to the event.
- fn: Any
+ fn: Any = dataclasses.field(default=None)
# The full name of the state class this event handler is attached to.
# Empty string means this event handler is a server side event.
- state_full_name: str = ""
-
- class Config:
- """The Pydantic config."""
-
- # Needed to allow serialization of Callable.
- frozen = True
+ state_full_name: str = dataclasses.field(default="")
@classmethod
def __class_getitem__(cls, args_spec: str) -> Annotated:
@@ -186,7 +248,7 @@ class EventHandler(EventActionsMixin):
# Get the function args.
fn_args = inspect.getfullargspec(self.fn).args[1:]
- fn_args = (Var.create_safe(arg, _var_is_string=False) for arg in fn_args)
+ fn_args = (Var(_js_expr=arg) for arg in fn_args)
# Construct the payload.
values = []
@@ -197,7 +259,7 @@ class EventHandler(EventActionsMixin):
# Otherwise, convert to JSON.
try:
- values.append(Var.create(arg, _var_is_string=isinstance(arg, str)))
+ values.append(LiteralVar.create(arg))
except TypeError as e:
raise EventHandlerTypeError(
f"Arguments to event handlers must be Vars or JSON-serializable. Got {arg} of type {type(arg)}."
@@ -210,6 +272,10 @@ class EventHandler(EventActionsMixin):
)
+@dataclasses.dataclass(
+ init=True,
+ frozen=True,
+)
class EventSpec(EventActionsMixin):
"""An event specification.
@@ -218,19 +284,35 @@ class EventSpec(EventActionsMixin):
"""
# The event handler.
- handler: EventHandler
+ handler: EventHandler = dataclasses.field(default=None) # type: ignore
# The handler on the client to process event.
- client_handler_name: str = ""
+ client_handler_name: str = dataclasses.field(default="")
# The arguments to pass to the function.
- args: Tuple[Tuple[Var, Var], ...] = ()
+ args: Tuple[Tuple[Var, Var], ...] = dataclasses.field(default_factory=tuple)
- class Config:
- """The Pydantic config."""
+ def __init__(
+ self,
+ handler: EventHandler,
+ event_actions: Dict[str, Union[bool, int]] | None = None,
+ client_handler_name: str = "",
+ args: Tuple[Tuple[Var, Var], ...] = (),
+ ):
+ """Initialize an EventSpec.
- # Required to allow tuple fields.
- frozen = True
+ Args:
+ event_actions: The event actions.
+ handler: The event handler.
+ client_handler_name: The client handler name.
+ args: The arguments to pass to the function.
+ """
+ if event_actions is None:
+ event_actions = {}
+ object.__setattr__(self, "event_actions", event_actions)
+ object.__setattr__(self, "handler", handler)
+ object.__setattr__(self, "client_handler_name", client_handler_name)
+ object.__setattr__(self, "args", args or ())
def with_args(self, args: Tuple[Tuple[Var, Var], ...]) -> EventSpec:
"""Copy the event spec, with updated args.
@@ -264,21 +346,25 @@ class EventSpec(EventActionsMixin):
# Get the remaining unfilled function args.
fn_args = inspect.getfullargspec(self.handler.fn).args[1 + len(self.args) :]
- fn_args = (Var.create_safe(arg, _var_is_string=False) for arg in fn_args)
+ fn_args = (Var(_js_expr=arg) for arg in fn_args)
# Construct the payload.
values = []
- for arg in args:
- try:
- values.append(Var.create(arg, _var_is_string=isinstance(arg, str)))
- except TypeError as e:
- raise EventHandlerTypeError(
- f"Arguments to event handlers must be Vars or JSON-serializable. Got {arg} of type {type(arg)}."
- ) from e
+ arg = None
+ try:
+ for arg in args:
+ values.append(LiteralVar.create(value=arg)) # noqa: PERF401
+ except TypeError as e:
+ raise EventHandlerTypeError(
+ f"Arguments to event handlers must be Vars or JSON-serializable. Got {arg} of type {type(arg)}."
+ ) from e
new_payload = tuple(zip(fn_args, values))
return self.with_args(self.args + new_payload)
+@dataclasses.dataclass(
+ frozen=True,
+)
class CallableEventSpec(EventSpec):
"""Decorate an EventSpec-returning function to act as both a EventSpec and a function.
@@ -298,10 +384,13 @@ class CallableEventSpec(EventSpec):
if fn is not None:
default_event_spec = fn()
super().__init__(
- fn=fn, # type: ignore
- **default_event_spec.dict(),
+ event_actions=default_event_spec.event_actions,
+ client_handler_name=default_event_spec.client_handler_name,
+ args=default_event_spec.args,
+ handler=default_event_spec.handler,
**kwargs,
)
+ object.__setattr__(self, "fn", fn)
else:
super().__init__(**kwargs)
@@ -325,42 +414,196 @@ class CallableEventSpec(EventSpec):
return self.fn(*args, **kwargs)
+@dataclasses.dataclass(
+ init=True,
+ frozen=True,
+)
class EventChain(EventActionsMixin):
"""Container for a chain of events that will be executed in order."""
- events: List[EventSpec]
+ events: Sequence[Union[EventSpec, EventVar, EventCallback]] = dataclasses.field(
+ default_factory=list
+ )
- args_spec: Optional[Callable]
+ args_spec: Optional[Union[Callable, Sequence[Callable]]] = dataclasses.field(
+ default=None
+ )
+
+ invocation: Optional[Var] = dataclasses.field(default=None)
+
+
+@dataclasses.dataclass(
+ init=True,
+ frozen=True,
+)
+class JavascriptHTMLInputElement:
+ """Interface for a Javascript HTMLInputElement https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement."""
+
+ value: str = ""
+
+
+@dataclasses.dataclass(
+ init=True,
+ frozen=True,
+)
+class JavascriptInputEvent:
+ """Interface for a Javascript InputEvent https://developer.mozilla.org/en-US/docs/Web/API/InputEvent."""
+
+ target: JavascriptHTMLInputElement = JavascriptHTMLInputElement() # noqa: RUF009
+
+
+@dataclasses.dataclass(
+ init=True,
+ frozen=True,
+)
+class JavasciptKeyboardEvent:
+ """Interface for a Javascript KeyboardEvent https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent."""
+
+ key: str = ""
+ altKey: bool = False
+ ctrlKey: bool = False
+ metaKey: bool = False
+ shiftKey: bool = False
+
+
+def input_event(e: Var[JavascriptInputEvent]) -> Tuple[Var[str]]:
+ """Get the value from an input event.
+
+ Args:
+ e: The input event.
+
+ Returns:
+ The value from the input event.
+ """
+ return (e.target.value,)
+
+
+class KeyInputInfo(TypedDict):
+ """Information about a key input event."""
+
+ alt_key: bool
+ ctrl_key: bool
+ meta_key: bool
+ shift_key: bool
+
+
+def key_event(e: Var[JavasciptKeyboardEvent]) -> Tuple[Var[str], Var[KeyInputInfo]]:
+ """Get the key from a keyboard event.
+
+ Args:
+ e: The keyboard event.
+
+ Returns:
+ The key from the keyboard event.
+ """
+ return (
+ e.key,
+ Var.create(
+ {
+ "alt_key": e.altKey,
+ "ctrl_key": e.ctrlKey,
+ "meta_key": e.metaKey,
+ "shift_key": e.shiftKey,
+ },
+ ),
+ )
+
+
+def no_args_event_spec() -> Tuple[()]:
+ """Empty event handler.
+
+ Returns:
+ An empty tuple.
+ """
+ return () # type: ignore
# These chains can be used for their side effects when no other events are desired.
-stop_propagation = EventChain(events=[], args_spec=lambda: []).stop_propagation
-prevent_default = EventChain(events=[], args_spec=lambda: []).prevent_default
+stop_propagation = EventChain(events=[], args_spec=no_args_event_spec).stop_propagation
+prevent_default = EventChain(events=[], args_spec=no_args_event_spec).prevent_default
-class Target(Base):
- """A Javascript event target."""
-
- checked: bool = False
- value: Any = None
+T = TypeVar("T")
+U = TypeVar("U")
-class FrontendEvent(Base):
- """A Javascript event."""
+class IdentityEventReturn(Generic[T], Protocol):
+ """Protocol for an identity event return."""
- target: Target = Target()
- key: str = ""
- value: Any = None
+ def __call__(self, *values: Var[T]) -> Tuple[Var[T], ...]:
+ """Return the input values.
+
+ Args:
+ *values: The values to return.
+
+ Returns:
+ The input values.
+ """
+ return values
-class FileUpload(Base):
+@overload
+def passthrough_event_spec(
+ event_type: Type[T], /
+) -> Callable[[Var[T]], Tuple[Var[T]]]: ... # type: ignore
+
+
+@overload
+def passthrough_event_spec(
+ event_type_1: Type[T], event_type2: Type[U], /
+) -> Callable[[Var[T], Var[U]], Tuple[Var[T], Var[U]]]: ...
+
+
+@overload
+def passthrough_event_spec(*event_types: Type[T]) -> IdentityEventReturn[T]: ...
+
+
+def passthrough_event_spec(*event_types: Type[T]) -> IdentityEventReturn[T]: # type: ignore
+ """A helper function that returns the input event as output.
+
+ Args:
+ *event_types: The types of the events.
+
+ Returns:
+ A function that returns the input event as output.
+ """
+
+ def inner(*values: Var[T]) -> Tuple[Var[T], ...]:
+ return values
+
+ inner_type = tuple(Var[event_type] for event_type in event_types)
+ return_annotation = Tuple[inner_type] # type: ignore
+
+ inner.__signature__ = inspect.signature(inner).replace( # type: ignore
+ parameters=[
+ inspect.Parameter(
+ f"ev_{i}",
+ kind=inspect.Parameter.POSITIONAL_OR_KEYWORD,
+ annotation=Var[event_type],
+ )
+ for i, event_type in enumerate(event_types)
+ ],
+ return_annotation=return_annotation,
+ )
+ for i, event_type in enumerate(event_types):
+ inner.__annotations__[f"ev_{i}"] = Var[event_type]
+ inner.__annotations__["return"] = return_annotation
+
+ return inner
+
+
+@dataclasses.dataclass(
+ init=True,
+ frozen=True,
+)
+class FileUpload:
"""Class to represent a file upload."""
upload_id: Optional[str] = None
on_upload_progress: Optional[Union[EventHandler, Callable]] = None
@staticmethod
- def on_upload_progress_args_spec(_prog: Dict[str, Union[int, float, bool]]):
+ def on_upload_progress_args_spec(_prog: Var[Dict[str, Union[int, float, bool]]]):
"""Args spec for on_upload_progress event handler.
Returns:
@@ -388,15 +631,16 @@ class FileUpload(Base):
upload_id = self.upload_id or DEFAULT_UPLOAD_ID
spec_args = [
(
- Var.create_safe("files", _var_is_string=False),
- Var.create_safe(
- f"filesById[{Var.create_safe(upload_id, _var_is_string=True)._var_name_unwrapped}]",
- _var_is_string=False,
- )._replace(_var_data=upload_files_context_var_data),
+ Var(_js_expr="files"),
+ Var(
+ _js_expr="filesById",
+ _var_type=Dict[str, Any],
+ _var_data=VarData.merge(upload_files_context_var_data),
+ ).to(ObjectVar)[LiteralVar.create(upload_id)],
),
(
- Var.create_safe("upload_id", _var_is_string=False),
- Var.create_safe(upload_id, _var_is_string=True),
+ Var(_js_expr="upload_id"),
+ LiteralVar.create(upload_id),
),
]
if self.on_upload_progress is not None:
@@ -418,17 +662,16 @@ class FileUpload(Base):
if isinstance(events, Var):
raise ValueError(f"{on_upload_progress} cannot return a var {events}.")
on_upload_progress_chain = EventChain(
- events=events,
+ events=[*events],
args_spec=self.on_upload_progress_args_spec,
)
formatted_chain = str(format.format_prop(on_upload_progress_chain))
spec_args.append(
(
- Var.create_safe("on_upload_progress", _var_is_string=False),
- BaseVar(
- _var_name=formatted_chain.strip("{}"),
- _var_type=EventChain,
- ),
+ Var(_js_expr="on_upload_progress"),
+ FunctionStringVar(
+ formatted_chain.strip("{}"),
+ ).to(FunctionVar, EventChain),
),
)
return EventSpec(
@@ -462,37 +705,72 @@ def server_side(name: str, sig: inspect.Signature, **kwargs) -> EventSpec:
fn.__qualname__ = name
fn.__signature__ = sig
return EventSpec(
- handler=EventHandler(fn=fn),
+ handler=EventHandler(fn=fn, state_full_name=FRONTEND_EVENT_STATE),
args=tuple(
(
- Var.create_safe(k, _var_is_string=False),
- Var.create_safe(v, _var_is_string=isinstance(v, str)),
+ Var(_js_expr=k),
+ LiteralVar.create(v),
)
for k, v in kwargs.items()
),
)
+@overload
def redirect(
path: str | Var[str],
- external: Optional[bool] = False,
- replace: Optional[bool] = False,
+ is_external: Optional[bool] = None,
+ replace: bool = False,
+) -> EventSpec: ...
+
+
+@overload
+@typing_extensions.deprecated("`external` is deprecated use `is_external` instead")
+def redirect(
+ path: str | Var[str],
+ is_external: Optional[bool] = None,
+ replace: bool = False,
+ external: Optional[bool] = None,
+) -> EventSpec: ...
+
+
+def redirect(
+ path: str | Var[str],
+ is_external: Optional[bool] = None,
+ replace: bool = False,
+ external: Optional[bool] = None,
) -> EventSpec:
"""Redirect to a new path.
Args:
path: The path to redirect to.
- external: Whether to open in new tab or not.
+ is_external: Whether to open in new tab or not.
replace: If True, the current page will not create a new history entry.
+ external(Deprecated): Whether to open in new tab or not.
Returns:
An event to redirect to the path.
"""
+ if external is not None:
+ console.deprecate(
+ "The `external` prop in `rx.redirect`",
+ "use `is_external` instead.",
+ "0.6.6",
+ "0.7.0",
+ )
+
+ # is_external should take precedence over external.
+ is_external = (
+ (False if external is None else external)
+ if is_external is None
+ else is_external
+ )
+
return server_side(
"_redirect",
get_fn_signature(redirect),
path=path,
- external=external,
+ external=is_external,
replace=replace,
)
@@ -506,7 +784,16 @@ def console_log(message: str | Var[str]) -> EventSpec:
Returns:
An event to log the message.
"""
- return server_side("_console", get_fn_signature(console_log), message=message)
+ return run_script(Var("console").to(dict).log.to(FunctionVar).call(message))
+
+
+def noop() -> EventSpec:
+ """Do nothing.
+
+ Returns:
+ An event to do nothing.
+ """
+ return run_script(Var.create(None))
def back() -> EventSpec:
@@ -515,7 +802,9 @@ def back() -> EventSpec:
Returns:
An event to go back one page.
"""
- return call_script("window.history.back()")
+ return run_script(
+ Var("window").to(dict).history.to(dict).back.to(FunctionVar).call()
+ )
def window_alert(message: str | Var[str]) -> EventSpec:
@@ -527,7 +816,7 @@ def window_alert(message: str | Var[str]) -> EventSpec:
Returns:
An event to alert the message.
"""
- return server_side("_alert", get_fn_signature(window_alert), message=message)
+ return run_script(Var("window").to(dict).alert.to(FunctionVar).call(message))
def set_focus(ref: str) -> EventSpec:
@@ -542,22 +831,28 @@ def set_focus(ref: str) -> EventSpec:
return server_side(
"_set_focus",
get_fn_signature(set_focus),
- ref=Var.create_safe(format.format_ref(ref), _var_is_string=True),
+ ref=LiteralVar.create(format.format_ref(ref)),
)
-def scroll_to(elem_id: str) -> EventSpec:
+def scroll_to(elem_id: str, align_to_top: bool | Var[bool] = True) -> EventSpec:
"""Select the id of a html element for scrolling into view.
Args:
- elem_id: the id of the element
+ elem_id: The id of the element to scroll to.
+ align_to_top: Whether to scroll to the top (True) or bottom (False) of the element.
Returns:
An EventSpec to scroll the page to the selected element.
"""
- js_code = f"document.getElementById('{elem_id}').scrollIntoView();"
+ get_element_by_id = FunctionStringVar.create("document.getElementById")
- return call_script(js_code)
+ return run_script(
+ get_element_by_id.call(elem_id)
+ .to(ObjectVar)
+ .scrollIntoView.to(FunctionVar)
+ .call(align_to_top),
+ )
def set_value(ref: str, value: Any) -> EventSpec:
@@ -573,7 +868,7 @@ def set_value(ref: str, value: Any) -> EventSpec:
return server_side(
"_set_value",
get_fn_signature(set_value),
- ref=Var.create_safe(format.format_ref(ref), _var_is_string=True),
+ ref=LiteralVar.create(format.format_ref(ref)),
value=value,
)
@@ -654,7 +949,7 @@ def remove_session_storage(key: str) -> EventSpec:
)
-def set_clipboard(content: str) -> EventSpec:
+def set_clipboard(content: Union[str, Var[str]]) -> EventSpec:
"""Set the text in content in the clipboard.
Args:
@@ -663,10 +958,12 @@ def set_clipboard(content: str) -> EventSpec:
Returns:
EventSpec: An event to set some content in the clipboard.
"""
- return server_side(
- "_set_clipboard",
- get_fn_signature(set_clipboard),
- content=content,
+ return run_script(
+ Var("navigator")
+ .to(dict)
+ .clipboard.to(dict)
+ .writeText.to(FunctionVar)
+ .call(content)
)
@@ -711,19 +1008,15 @@ def download(
url = "data:text/plain," + urllib.parse.quote(data)
elif isinstance(data, Var):
# Need to check on the frontend if the Var already looks like a data: URI.
- is_data_url = data._replace(
- _var_name=(
- f"typeof {data._var_full_name} == 'string' && "
- f"{data._var_full_name}.startsWith('data:')"
- ),
- _var_type=bool,
- _var_is_string=False,
- _var_full_name_needs_state_prefix=False,
- )
+
+ is_data_url = (data.js_type() == "string") & (
+ data.to(str).startswith("data:")
+ ) # type: ignore
+
# If it's a data: URI, use it as is, otherwise convert the Var to JSON in a data: URI.
url = cond( # type: ignore
is_data_url,
- data,
+ data.to(str),
"data:text/plain," + data.to_string(), # type: ignore
)
elif isinstance(data, bytes):
@@ -757,11 +1050,7 @@ def _callback_arg_spec(eval_result):
def call_script(
javascript_code: str | Var[str],
- callback: EventSpec
- | EventHandler
- | Callable
- | List[EventSpec | EventHandler | Callable]
- | None = None,
+ callback: EventType | None = None,
) -> EventSpec:
"""Create an event handler that executes arbitrary javascript code.
@@ -775,13 +1064,21 @@ def call_script(
callback_kwargs = {}
if callback is not None:
callback_kwargs = {
- "callback": str(
- format.format_queue_events(
- callback,
- args_spec=lambda result: [result],
- ),
- ),
+ "callback": format.format_queue_events(
+ callback,
+ args_spec=lambda result: [result],
+ )._js_expr,
}
+ if isinstance(javascript_code, str):
+ # When there is VarData, include it and eval the JS code inline on the client.
+ javascript_code, original_code = (
+ LiteralVar.create(javascript_code),
+ javascript_code,
+ )
+ if not javascript_code._get_all_var_data():
+ # Without VarData, cast to string and eval the code in the event loop.
+ javascript_code = str(Var(_js_expr=original_code))
+
return server_side(
"_call_script",
get_fn_signature(call_script),
@@ -790,6 +1087,60 @@ def call_script(
)
+def call_function(
+ javascript_code: str | Var,
+ callback: EventType | None = None,
+) -> EventSpec:
+ """Create an event handler that executes arbitrary javascript code.
+
+ Args:
+ javascript_code: The code to execute.
+ callback: EventHandler that will receive the result of evaluating the javascript code.
+
+ Returns:
+ EventSpec: An event that will execute the client side javascript.
+ """
+ callback_kwargs = {}
+ if callback is not None:
+ callback_kwargs = {
+ "callback": format.format_queue_events(
+ callback,
+ args_spec=lambda result: [result],
+ ),
+ }
+
+ javascript_code = (
+ Var(javascript_code) if isinstance(javascript_code, str) else javascript_code
+ )
+
+ return server_side(
+ "_call_function",
+ get_fn_signature(call_function),
+ function=javascript_code,
+ **callback_kwargs,
+ )
+
+
+def run_script(
+ javascript_code: str | Var,
+ callback: EventType | None = None,
+) -> EventSpec:
+ """Create an event handler that executes arbitrary javascript code.
+
+ Args:
+ javascript_code: The code to execute.
+ callback: EventHandler that will receive the result of evaluating the javascript code.
+
+ Returns:
+ EventSpec: An event that will execute the client side javascript.
+ """
+ javascript_code = (
+ Var(javascript_code) if isinstance(javascript_code, str) else javascript_code
+ )
+
+ return call_function(ArgsFunctionOperation.create((), javascript_code), callback)
+
+
def get_event(state, event):
"""Get the event from the given state.
@@ -816,8 +1167,9 @@ def get_hydrate_event(state) -> str:
def call_event_handler(
- event_handler: EventHandler | EventSpec,
- arg_spec: ArgsSpec,
+ event_callback: EventHandler | EventSpec,
+ event_spec: ArgsSpec | Sequence[ArgsSpec],
+ key: Optional[str] = None,
) -> EventSpec:
"""Call an event handler to get the event spec.
@@ -826,33 +1178,175 @@ def call_event_handler(
Otherwise, the event handler will be called with no args.
Args:
- event_handler: The event handler.
- arg_spec: The lambda that define the argument(s) to pass to the event handler.
-
- Raises:
- ValueError: if number of arguments expected by event_handler doesn't match the spec.
+ event_callback: The event handler.
+ event_spec: The lambda that define the argument(s) to pass to the event handler.
+ key: The key to pass to the event handler.
Returns:
The event spec from calling the event handler.
+
+ # noqa: DAR401 failure
+
"""
- parsed_args = parse_args_spec(arg_spec) # type: ignore
+ event_spec_args = parse_args_spec(event_spec) # type: ignore
- if isinstance(event_handler, EventSpec):
- # Handle partial application of EventSpec args
- return event_handler.add_args(*parsed_args)
-
- args = inspect.getfullargspec(event_handler.fn).args
- if len(args) == len(["self", *parsed_args]):
- return event_handler(*parsed_args) # type: ignore
- else:
- source = inspect.getsource(arg_spec) # type: ignore
- raise ValueError(
- f"number of arguments in {event_handler.fn.__qualname__} "
- f"doesn't match the definition of the event trigger '{source.strip().strip(',')}'"
+ if isinstance(event_callback, EventSpec):
+ check_fn_match_arg_spec(
+ event_callback.handler.fn,
+ event_spec,
+ key,
+ bool(event_callback.handler.state_full_name) + len(event_callback.args),
+ event_callback.handler.fn.__qualname__,
)
+ # Handle partial application of EventSpec args
+ return event_callback.add_args(*event_spec_args)
+
+ check_fn_match_arg_spec(
+ event_callback.fn,
+ event_spec,
+ key,
+ bool(event_callback.state_full_name),
+ event_callback.fn.__qualname__,
+ )
+
+ all_acceptable_specs = (
+ [event_spec] if not isinstance(event_spec, Sequence) else event_spec
+ )
+
+ event_spec_return_types = list(
+ filter(
+ lambda event_spec_return_type: event_spec_return_type is not None
+ and get_origin(event_spec_return_type) is tuple,
+ (
+ get_type_hints(arg_spec).get("return", None)
+ for arg_spec in all_acceptable_specs
+ ),
+ )
+ )
+
+ if event_spec_return_types:
+ failures = []
+
+ event_callback_spec = inspect.getfullargspec(event_callback.fn)
+
+ for event_spec_index, event_spec_return_type in enumerate(
+ event_spec_return_types
+ ):
+ args = get_args(event_spec_return_type)
+
+ args_types_without_vars = [
+ arg if get_origin(arg) is not Var else get_args(arg)[0] for arg in args
+ ]
+
+ try:
+ type_hints_of_provided_callback = get_type_hints(event_callback.fn)
+ except NameError:
+ type_hints_of_provided_callback = {}
+
+ failed_type_check = False
+
+ # check that args of event handler are matching the spec if type hints are provided
+ for i, arg in enumerate(event_callback_spec.args[1:]):
+ if arg not in type_hints_of_provided_callback:
+ continue
+
+ try:
+ compare_result = typehint_issubclass(
+ args_types_without_vars[i], type_hints_of_provided_callback[arg]
+ )
+ except TypeError:
+ # TODO: In 0.7.0, remove this block and raise the exception
+ # raise TypeError(
+ # f"Could not compare types {args_types_without_vars[i]} and {type_hints_of_provided_callback[arg]} for argument {arg} of {event_handler.fn.__qualname__} provided for {key}." # noqa: ERA001
+ # ) from e
+ console.warn(
+ f"Could not compare types {args_types_without_vars[i]} and {type_hints_of_provided_callback[arg]} for argument {arg} of {event_callback.fn.__qualname__} provided for {key}."
+ )
+ compare_result = False
+
+ if compare_result:
+ continue
+ else:
+ failure = EventHandlerArgTypeMismatch(
+ f"Event handler {key} expects {args_types_without_vars[i]} for argument {arg} but got {type_hints_of_provided_callback[arg]} as annotated in {event_callback.fn.__qualname__} instead."
+ )
+ failures.append(failure)
+ failed_type_check = True
+ break
+
+ if not failed_type_check:
+ if event_spec_index:
+ args = get_args(event_spec_return_types[0])
+
+ args_types_without_vars = [
+ arg if get_origin(arg) is not Var else get_args(arg)[0]
+ for arg in args
+ ]
+
+ expect_string = ", ".join(
+ repr(arg) for arg in args_types_without_vars
+ ).replace("[", "\\[")
+
+ given_string = ", ".join(
+ repr(type_hints_of_provided_callback.get(arg, Any))
+ for arg in event_callback_spec.args[1:]
+ ).replace("[", "\\[")
+
+ console.warn(
+ f"Event handler {key} expects ({expect_string}) -> () but got ({given_string}) -> () as annotated in {event_callback.fn.__qualname__} instead. "
+ f"This may lead to unexpected behavior but is intentionally ignored for {key}."
+ )
+ return event_callback(*event_spec_args)
+
+ if failures:
+ console.deprecate(
+ "Mismatched event handler argument types",
+ "\n".join([str(f) for f in failures]),
+ "0.6.5",
+ "0.7.0",
+ )
+
+ return event_callback(*event_spec_args) # type: ignore
-def parse_args_spec(arg_spec: ArgsSpec):
+def unwrap_var_annotation(annotation: GenericType):
+ """Unwrap a Var annotation or return it as is if it's not Var[X].
+
+ Args:
+ annotation: The annotation to unwrap.
+
+ Returns:
+ The unwrapped annotation.
+ """
+ if get_origin(annotation) is Var and (args := get_args(annotation)):
+ return args[0]
+ return annotation
+
+
+def resolve_annotation(annotations: dict[str, Any], arg_name: str):
+ """Resolve the annotation for the given argument name.
+
+ Args:
+ annotations: The annotations.
+ arg_name: The argument name.
+
+ Returns:
+ The resolved annotation.
+ """
+ annotation = annotations.get(arg_name)
+ if annotation is None:
+ console.deprecate(
+ feature_name="Unannotated event handler arguments",
+ reason="Provide type annotations for event handler arguments.",
+ deprecation_version="0.6.3",
+ removal_version="0.7.0",
+ )
+ # Allow arbitrary attribute access two levels deep until removed.
+ return Dict[str, dict]
+ return annotation
+
+
+def parse_args_spec(arg_spec: ArgsSpec | Sequence[ArgsSpec]):
"""Parse the args provided in the ArgsSpec of an event trigger.
Args:
@@ -861,72 +1355,114 @@ def parse_args_spec(arg_spec: ArgsSpec):
Returns:
The parsed args.
"""
+ # if there's multiple, the first is the default
+ arg_spec = arg_spec[0] if isinstance(arg_spec, Sequence) else arg_spec
spec = inspect.getfullargspec(arg_spec)
annotations = get_type_hints(arg_spec)
- return arg_spec(
- *[
- BaseVar(
- _var_name=f"_{l_arg}",
- _var_type=annotations.get(l_arg, FrontendEvent),
- _var_is_local=True,
- )
- for l_arg in spec.args
- ]
+
+ return list(
+ arg_spec(
+ *[
+ Var(f"_{l_arg}").to(
+ unwrap_var_annotation(resolve_annotation(annotations, l_arg))
+ )
+ for l_arg in spec.args
+ ]
+ )
)
-def call_event_fn(fn: Callable, arg: Union[Var, ArgsSpec]) -> list[EventSpec] | Var:
+def check_fn_match_arg_spec(
+ user_func: Callable,
+ arg_spec: ArgsSpec | Sequence[ArgsSpec],
+ key: str | None = None,
+ number_of_bound_args: int = 0,
+ func_name: str | None = None,
+):
+ """Ensures that the function signature matches the passed argument specification
+ or raises an EventFnArgMismatch if they do not.
+
+ Args:
+ user_func: The function to be validated.
+ arg_spec: The argument specification for the event trigger.
+ key: The key of the event trigger.
+ number_of_bound_args: The number of bound arguments to the function.
+ func_name: The name of the function to be validated.
+
+ Raises:
+ EventFnArgMismatch: Raised if the number of mandatory arguments do not match
+ """
+ user_args = inspect.getfullargspec(user_func).args
+ # Drop the first argument if it's a bound method
+ if inspect.ismethod(user_func) and user_func.__self__ is not None:
+ user_args = user_args[1:]
+
+ user_default_args = inspect.getfullargspec(user_func).defaults
+ number_of_user_args = len(user_args) - number_of_bound_args
+ number_of_user_default_args = len(user_default_args) if user_default_args else 0
+
+ parsed_event_args = parse_args_spec(arg_spec)
+
+ number_of_event_args = len(parsed_event_args)
+
+ if number_of_user_args - number_of_user_default_args > number_of_event_args:
+ raise EventFnArgMismatch(
+ f"Event {key} only provides {number_of_event_args} arguments, but "
+ f"{func_name or user_func} requires at least {number_of_user_args - number_of_user_default_args} "
+ "arguments to be passed to the event handler.\n"
+ "See https://reflex.dev/docs/events/event-arguments/"
+ )
+
+
+def call_event_fn(
+ fn: Callable,
+ arg_spec: ArgsSpec | Sequence[ArgsSpec],
+ key: Optional[str] = None,
+) -> list[EventSpec] | Var:
"""Call a function to a list of event specs.
The function should return a single EventSpec, a list of EventSpecs, or a
- single Var. If the function takes in an arg, the arg will be passed to the
- function. Otherwise, the function will be called with no args.
+ single Var.
Args:
fn: The function to call.
- arg: The argument to pass to the function.
+ arg_spec: The argument spec for the event trigger.
+ key: The key to pass to the event handler.
Returns:
The event specs from calling the function or a Var.
Raises:
- EventHandlerValueError: If the lambda has an invalid signature.
+ EventHandlerValueError: If the lambda returns an unusable value.
"""
# Import here to avoid circular imports.
from reflex.event import EventHandler, EventSpec
from reflex.utils.exceptions import EventHandlerValueError
- # Get the args of the lambda.
- args = inspect.getfullargspec(fn).args
+ # Check that fn signature matches arg_spec
+ check_fn_match_arg_spec(fn, arg_spec, key=key)
- if isinstance(arg, ArgsSpec):
- out = fn(*parse_args_spec(arg)) # type: ignore
- else:
- # Call the lambda.
- if len(args) == 0:
- out = fn()
- elif len(args) == 1:
- out = fn(arg)
- else:
- raise EventHandlerValueError(f"Lambda {fn} must have 0 or 1 arguments.")
+ parsed_args = parse_args_spec(arg_spec)
+
+ number_of_fn_args = len(inspect.getfullargspec(fn).args)
+
+ # Call the function with the parsed args.
+ out = fn(*[*parsed_args][:number_of_fn_args])
# If the function returns a Var, assume it's an EventChain and render it directly.
if isinstance(out, Var):
return out
# Convert the output to a list.
- if not isinstance(out, List):
+ if not isinstance(out, list):
out = [out]
# Convert any event specs to event specs.
events = []
for e in out:
- # Convert handlers to event specs.
if isinstance(e, EventHandler):
- if len(args) == 0:
- e = e()
- elif len(args) == 1:
- e = e(arg) # type: ignore
+ # An un-called EventHandler gets all of the args of the event trigger.
+ e = call_event_handler(e, arg_spec, key=key)
# Make sure the event spec is valid.
if not isinstance(e, EventSpec):
@@ -941,7 +1477,9 @@ def call_event_fn(fn: Callable, arg: Union[Var, ArgsSpec]) -> list[EventSpec] |
return events
-def get_handler_args(event_spec: EventSpec) -> tuple[tuple[Var, Var], ...]:
+def get_handler_args(
+ event_spec: EventSpec,
+) -> tuple[tuple[Var, Var], ...]:
"""Get the handler args for the given event spec.
Args:
@@ -952,7 +1490,7 @@ def get_handler_args(event_spec: EventSpec) -> tuple[tuple[Var, Var], ...]:
"""
args = inspect.getfullargspec(event_spec.handler.fn).args
- return event_spec.args if len(args) > 1 else tuple()
+ return event_spec.args if len(args) > 1 else ()
def fix_events(
@@ -967,6 +1505,9 @@ def fix_events(
token: The user token.
router_data: The optional router data to set in the event.
+ Raises:
+ ValueError: If the event type is not what was expected.
+
Returns:
The fixed events.
"""
@@ -990,9 +1531,10 @@ def fix_events(
# Otherwise, create an event from the event spec.
if isinstance(e, EventHandler):
e = e()
- assert isinstance(e, EventSpec), f"Unexpected event type, {type(e)}."
+ if not isinstance(e, EventSpec):
+ raise ValueError(f"Unexpected event type, {type(e)}.")
name = format.format_event_handler(e.handler)
- payload = {k._var_name: v._decode() for k, v in e.args} # type: ignore
+ payload = {k._js_expr: v._decode() for k, v in e.args} # type: ignore
# Filter router_data to reduce payload size
event_router_data = {
@@ -1024,6 +1566,376 @@ def get_fn_signature(fn: Callable) -> inspect.Signature:
"""
signature = inspect.signature(fn)
new_param = inspect.Parameter(
- "state", inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=Any
+ FRONTEND_EVENT_STATE, inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=Any
)
return signature.replace(parameters=(new_param, *signature.parameters.values()))
+
+
+class EventVar(ObjectVar, python_types=EventSpec):
+ """Base class for event vars."""
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class LiteralEventVar(VarOperationCall, LiteralVar, EventVar):
+ """A literal event var."""
+
+ _var_value: EventSpec = dataclasses.field(default=None) # type: ignore
+
+ def __hash__(self) -> int:
+ """Get the hash of the var.
+
+ Returns:
+ The hash of the var.
+ """
+ return hash((type(self).__name__, self._js_expr))
+
+ @classmethod
+ def create(
+ cls,
+ value: EventSpec,
+ _var_data: VarData | None = None,
+ ) -> LiteralEventVar:
+ """Create a new LiteralEventVar instance.
+
+ Args:
+ value: The value of the var.
+ _var_data: The data of the var.
+
+ Returns:
+ The created LiteralEventVar instance.
+ """
+ return cls(
+ _js_expr="",
+ _var_type=EventSpec,
+ _var_data=_var_data,
+ _var_value=value,
+ _func=FunctionStringVar("Event"),
+ _args=(
+ # event handler name
+ ".".join(
+ filter(
+ None,
+ format.get_event_handler_parts(value.handler),
+ )
+ ),
+ # event handler args
+ {str(name): value for name, value in value.args},
+ # event actions
+ value.event_actions,
+ # client handler name
+ *([value.client_handler_name] if value.client_handler_name else []),
+ ),
+ )
+
+
+class EventChainVar(BuilderFunctionVar, python_types=EventChain):
+ """Base class for event chain vars."""
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+# Note: LiteralVar is second in the inheritance list allowing it act like a
+# CachedVarOperation (ArgsFunctionOperation) and get the _js_expr from the
+# _cached_var_name property.
+class LiteralEventChainVar(ArgsFunctionOperationBuilder, LiteralVar, EventChainVar):
+ """A literal event chain var."""
+
+ _var_value: EventChain = dataclasses.field(default=None) # type: ignore
+
+ def __hash__(self) -> int:
+ """Get the hash of the var.
+
+ Returns:
+ The hash of the var.
+ """
+ return hash((type(self).__name__, self._js_expr))
+
+ @classmethod
+ def create(
+ cls,
+ value: EventChain,
+ _var_data: VarData | None = None,
+ ) -> LiteralEventChainVar:
+ """Create a new LiteralEventChainVar instance.
+
+ Args:
+ value: The value of the var.
+ _var_data: The data of the var.
+
+ Returns:
+ The created LiteralEventChainVar instance.
+ """
+ arg_spec = (
+ value.args_spec[0]
+ if isinstance(value.args_spec, Sequence)
+ else value.args_spec
+ )
+ sig = inspect.signature(arg_spec) # type: ignore
+ if sig.parameters:
+ arg_def = tuple((f"_{p}" for p in sig.parameters))
+ arg_def_expr = LiteralVar.create([Var(_js_expr=arg) for arg in arg_def])
+ else:
+ # add a default argument for addEvents if none were specified in value.args_spec
+ # used to trigger the preventDefault() on the event.
+ arg_def = ("...args",)
+ arg_def_expr = Var(_js_expr="args")
+
+ if value.invocation is None:
+ invocation = FunctionStringVar.create("addEvents")
+ else:
+ invocation = value.invocation
+
+ return cls(
+ _js_expr="",
+ _var_type=EventChain,
+ _var_data=_var_data,
+ _args=FunctionArgs(arg_def),
+ _return_expr=invocation.call(
+ LiteralVar.create([LiteralVar.create(event) for event in value.events]),
+ arg_def_expr,
+ value.event_actions,
+ ),
+ _var_value=value,
+ )
+
+
+P = ParamSpec("P")
+Q = ParamSpec("Q")
+T = TypeVar("T")
+V = TypeVar("V")
+V2 = TypeVar("V2")
+V3 = TypeVar("V3")
+V4 = TypeVar("V4")
+V5 = TypeVar("V5")
+
+background_event_decorator = background
+
+
+class EventCallback(Generic[P, T]):
+ """A descriptor that wraps a function to be used as an event."""
+
+ def __init__(self, func: Callable[Concatenate[Any, P], T]):
+ """Initialize the descriptor with the function to be wrapped.
+
+ Args:
+ func: The function to be wrapped.
+ """
+ self.func = func
+
+ @property
+ def prevent_default(self):
+ """Prevent default behavior.
+
+ Returns:
+ The event callback with prevent default behavior.
+ """
+ return self
+
+ @property
+ def stop_propagation(self):
+ """Stop event propagation.
+
+ Returns:
+ The event callback with stop propagation behavior.
+ """
+ return self
+
+ @overload
+ def __call__(
+ self: EventCallback[Q, T],
+ ) -> EventCallback[Q, T]: ...
+
+ @overload
+ def __call__(
+ self: EventCallback[Concatenate[V, Q], T], value: V | Var[V]
+ ) -> EventCallback[Q, T]: ...
+
+ @overload
+ def __call__(
+ self: EventCallback[Concatenate[V, V2, Q], T],
+ value: V | Var[V],
+ value2: V2 | Var[V2],
+ ) -> EventCallback[Q, T]: ...
+
+ @overload
+ def __call__(
+ self: EventCallback[Concatenate[V, V2, V3, Q], T],
+ value: V | Var[V],
+ value2: V2 | Var[V2],
+ value3: V3 | Var[V3],
+ ) -> EventCallback[Q, T]: ...
+
+ @overload
+ def __call__(
+ self: EventCallback[Concatenate[V, V2, V3, V4, Q], T],
+ value: V | Var[V],
+ value2: V2 | Var[V2],
+ value3: V3 | Var[V3],
+ value4: V4 | Var[V4],
+ ) -> EventCallback[Q, T]: ...
+
+ def __call__(self, *values) -> EventCallback: # type: ignore
+ """Call the function with the values.
+
+ Args:
+ *values: The values to call the function with.
+
+ Returns:
+ The function with the values.
+ """
+ return self.func(*values) # type: ignore
+
+ @overload
+ def __get__(
+ self: EventCallback[P, T], instance: None, owner
+ ) -> EventCallback[P, T]: ...
+
+ @overload
+ def __get__(self, instance, owner) -> Callable[P, T]: ...
+
+ def __get__(self, instance, owner) -> Callable: # type: ignore
+ """Get the function with the instance bound to it.
+
+ Args:
+ instance: The instance to bind to the function.
+ owner: The owner of the function.
+
+ Returns:
+ The function with the instance bound to it
+ """
+ if instance is None:
+ return self.func # type: ignore
+
+ return partial(self.func, instance) # type: ignore
+
+
+G = ParamSpec("G")
+
+if TYPE_CHECKING:
+ from reflex.state import BaseState
+
+ BASE_STATE = TypeVar("BASE_STATE", bound=BaseState)
+else:
+ BASE_STATE = TypeVar("BASE_STATE")
+
+StateCallable = TypeAliasType(
+ "StateCallable",
+ Callable[Concatenate[BASE_STATE, G], Any],
+ type_params=(G, BASE_STATE),
+)
+
+IndividualEventType = Union[
+ EventSpec,
+ EventHandler,
+ Callable[G, Any],
+ StateCallable[G, BASE_STATE],
+ EventCallback[G, Any],
+ Var[Any],
+]
+
+ItemOrList = Union[V, List[V]]
+
+EventType = ItemOrList[IndividualEventType[G, BASE_STATE]]
+
+
+class EventNamespace(types.SimpleNamespace):
+ """A namespace for event related classes."""
+
+ Event = Event
+ EventHandler = EventHandler
+ EventSpec = EventSpec
+ CallableEventSpec = CallableEventSpec
+ EventChain = EventChain
+ EventVar = EventVar
+ LiteralEventVar = LiteralEventVar
+ EventChainVar = EventChainVar
+ LiteralEventChainVar = LiteralEventChainVar
+ EventType = EventType
+ EventCallback = EventCallback
+
+ @overload
+ @staticmethod
+ def __call__(
+ func: None = None, *, background: bool | None = None
+ ) -> Callable[[Callable[Concatenate[BASE_STATE, P], T]], EventCallback[P, T]]: ...
+
+ @overload
+ @staticmethod
+ def __call__(
+ func: Callable[Concatenate[BASE_STATE, P], T],
+ *,
+ background: bool | None = None,
+ ) -> EventCallback[P, T]: ...
+
+ @staticmethod
+ def __call__(
+ func: Callable[Concatenate[BASE_STATE, P], T] | None = None,
+ *,
+ background: bool | None = None,
+ ) -> Union[
+ EventCallback[P, T],
+ Callable[[Callable[Concatenate[BASE_STATE, P], T]], EventCallback[P, T]],
+ ]:
+ """Wrap a function to be used as an event.
+
+ Args:
+ func: The function to wrap.
+ background: Whether the event should be run in the background. Defaults to False.
+
+ Returns:
+ The wrapped function.
+ """
+
+ def wrapper(
+ func: Callable[Concatenate[BASE_STATE, P], T],
+ ) -> EventCallback[P, T]:
+ if background is True:
+ return background_event_decorator(func, __internal_reflex_call=True) # type: ignore
+ return func # type: ignore
+
+ if func is not None:
+ return wrapper(func)
+ return wrapper
+
+ get_event = staticmethod(get_event)
+ get_hydrate_event = staticmethod(get_hydrate_event)
+ fix_events = staticmethod(fix_events)
+ call_event_handler = staticmethod(call_event_handler)
+ call_event_fn = staticmethod(call_event_fn)
+ get_handler_args = staticmethod(get_handler_args)
+ check_fn_match_arg_spec = staticmethod(check_fn_match_arg_spec)
+ resolve_annotation = staticmethod(resolve_annotation)
+ parse_args_spec = staticmethod(parse_args_spec)
+ passthrough_event_spec = staticmethod(passthrough_event_spec)
+ input_event = staticmethod(input_event)
+ key_event = staticmethod(key_event)
+ no_args_event_spec = staticmethod(no_args_event_spec)
+ server_side = staticmethod(server_side)
+ redirect = staticmethod(redirect)
+ console_log = staticmethod(console_log)
+ noop = staticmethod(noop)
+ back = staticmethod(back)
+ window_alert = staticmethod(window_alert)
+ set_focus = staticmethod(set_focus)
+ scroll_to = staticmethod(scroll_to)
+ set_value = staticmethod(set_value)
+ remove_cookie = staticmethod(remove_cookie)
+ clear_local_storage = staticmethod(clear_local_storage)
+ remove_local_storage = staticmethod(remove_local_storage)
+ clear_session_storage = staticmethod(clear_session_storage)
+ remove_session_storage = staticmethod(remove_session_storage)
+ set_clipboard = staticmethod(set_clipboard)
+ download = staticmethod(download)
+ call_script = staticmethod(call_script)
+ call_function = staticmethod(call_function)
+ run_script = staticmethod(run_script)
+
+
+event = EventNamespace()
diff --git a/reflex/experimental/__init__.py b/reflex/experimental/__init__.py
index 060f7e7f1..164790fe5 100644
--- a/reflex/experimental/__init__.py
+++ b/reflex/experimental/__init__.py
@@ -2,13 +2,13 @@
from types import SimpleNamespace
+from reflex.components.datadisplay.shiki_code_block import code_block as code_block
from reflex.components.props import PropsBase
from reflex.components.radix.themes.components.progress import progress as progress
from reflex.components.sonner.toast import toast as toast
from ..utils.console import warn
from . import hooks as hooks
-from . import vars as vars
from .assets import asset as asset
from .client_state import ClientStateVar as ClientStateVar
from .layout import layout as layout
@@ -33,19 +33,40 @@ class ExperimentalNamespace(SimpleNamespace):
Returns:
The toast namespace.
"""
- if "toast" not in _EMITTED_PROMOTION_WARNINGS:
- _EMITTED_PROMOTION_WARNINGS.add("toast")
- warn(f"`rx._x.toast` was promoted to `rx.toast`.")
+ self.register_component_warning("toast")
return toast
+ @property
+ def progress(self):
+ """Temporary property returning the toast namespace.
+
+ Remove this property when toast is fully promoted.
+
+ Returns:
+ The toast namespace.
+ """
+ self.register_component_warning("progress")
+ return progress
+
+ @staticmethod
+ def register_component_warning(component_name: str):
+ """Add component to emitted warnings and throw a warning if it
+ doesn't exist.
+
+ Args:
+ component_name: name of the component.
+ """
+ if component_name not in _EMITTED_PROMOTION_WARNINGS:
+ _EMITTED_PROMOTION_WARNINGS.add(component_name)
+ warn(f"`rx._x.{component_name}` was promoted to `rx.{component_name}`.")
+
_x = ExperimentalNamespace(
asset=asset,
client_state=ClientStateVar.create,
hooks=hooks,
- vars=vars,
layout=layout,
- progress=progress,
PropsBase=PropsBase,
run_in_thread=run_in_thread,
+ code_block=code_block,
)
diff --git a/reflex/experimental/assets.py b/reflex/experimental/assets.py
index c18ac1e84..e9be19aaf 100644
--- a/reflex/experimental/assets.py
+++ b/reflex/experimental/assets.py
@@ -1,14 +1,15 @@
"""Helper functions for adding assets to the app."""
-import inspect
-from pathlib import Path
from typing import Optional
-from reflex import constants
+from reflex import assets
+from reflex.utils import console
def asset(relative_filename: str, subfolder: Optional[str] = None) -> str:
- """Add an asset to the app.
+ """DEPRECATED: use `rx.asset` with `shared=True` instead.
+
+ Add an asset to the app.
Place the file next to your including python file.
Copies the file to the app's external assets directory.
@@ -22,36 +23,15 @@ def asset(relative_filename: str, subfolder: Optional[str] = None) -> str:
relative_filename: The relative filename of the asset.
subfolder: The directory to place the asset in.
- Raises:
- FileNotFoundError: If the file does not exist.
-
Returns:
The relative URL to the copied asset.
"""
- # Determine the file by which the asset is exposed.
- calling_file = inspect.stack()[1].filename
- module = inspect.getmodule(inspect.stack()[1][0])
- assert module is not None
- caller_module_path = module.__name__.replace(".", "/")
-
- subfolder = f"{caller_module_path}/{subfolder}" if subfolder else caller_module_path
-
- src_file = Path(calling_file).parent / relative_filename
-
- assets = constants.Dirs.APP_ASSETS
- external = constants.Dirs.EXTERNAL_APP_ASSETS
-
- if not src_file.exists():
- raise FileNotFoundError(f"File not found: {src_file}")
-
- # Create the asset folder in the currently compiling app.
- asset_folder = Path.cwd() / assets / external / subfolder
- asset_folder.mkdir(parents=True, exist_ok=True)
-
- dst_file = asset_folder / relative_filename
-
- if not dst_file.exists():
- dst_file.symlink_to(src_file)
-
- asset_url = f"/{external}/{subfolder}/{relative_filename}"
- return asset_url
+ console.deprecate(
+ feature_name="rx._x.asset",
+ reason="Use `rx.asset` with `shared=True` instead of `rx._x.asset`.",
+ deprecation_version="0.6.6",
+ removal_version="0.7.0",
+ )
+ return assets.asset(
+ relative_filename, shared=True, subfolder=subfolder, _stack_level=2
+ )
diff --git a/reflex/experimental/client_state.py b/reflex/experimental/client_state.py
index 3033b94dd..1982b3dfe 100644
--- a/reflex/experimental/client_state.py
+++ b/reflex/experimental/client_state.py
@@ -3,19 +3,22 @@
from __future__ import annotations
import dataclasses
+import re
import sys
-from typing import Any, Callable, Optional, Type, Union
+from typing import Any, Callable, Union
from reflex import constants
-from reflex.event import EventChain, EventHandler, EventSpec, call_script
+from reflex.event import EventChain, EventHandler, EventSpec, run_script
from reflex.utils.imports import ImportVar
-from reflex.vars import Var, VarData, get_unique_variable_name
+from reflex.vars import VarData, get_unique_variable_name
+from reflex.vars.base import LiteralVar, Var
+from reflex.vars.function import FunctionVar
NoValue = object()
_refs_import = {
- f"/{constants.Dirs.STATE_PATH}": [ImportVar(tag="refs")],
+ f"$/{constants.Dirs.STATE_PATH}": [ImportVar(tag="refs")],
}
@@ -33,36 +36,19 @@ def _client_state_ref(var_name: str) -> str:
@dataclasses.dataclass(
eq=False,
+ frozen=True,
**{"slots": True} if sys.version_info >= (3, 10) else {},
)
class ClientStateVar(Var):
"""A Var that exists on the client via useState."""
- # The name of the var.
- _var_name: str = dataclasses.field()
-
# Track the names of the getters and setters
- _setter_name: str = dataclasses.field()
- _getter_name: str = dataclasses.field()
+ _setter_name: str = dataclasses.field(default="")
+ _getter_name: str = dataclasses.field(default="")
# Whether to add the var and setter to the global `refs` object for use in any Component.
_global_ref: bool = dataclasses.field(default=True)
- # The type of the var.
- _var_type: Type = dataclasses.field(default=Any)
-
- # Whether this is a local javascript variable.
- _var_is_local: bool = dataclasses.field(default=False)
-
- # Whether the var is a string literal.
- _var_is_string: bool = dataclasses.field(default=False)
-
- # _var_full_name should be prefixed with _var_state
- _var_full_name_needs_state_prefix: bool = dataclasses.field(default=False)
-
- # Extra metadata associated with the Var
- _var_data: Optional[VarData] = dataclasses.field(default=None)
-
def __hash__(self) -> int:
"""Define a hash function for a var.
@@ -70,7 +56,7 @@ class ClientStateVar(Var):
The hash of the var.
"""
return hash(
- (self._var_name, str(self._var_type), self._getter_name, self._setter_name)
+ (self._js_expr, str(self._var_type), self._getter_name, self._setter_name)
)
@classmethod
@@ -102,24 +88,25 @@ class ClientStateVar(Var):
default: The default value of the variable.
global_ref: Whether the state should be accessible in any Component and on the backend.
+ Raises:
+ ValueError: If the var_name is not a string.
+
Returns:
ClientStateVar
"""
if var_name is None:
var_name = get_unique_variable_name()
- assert isinstance(var_name, str), "var_name must be a string."
+ if not isinstance(var_name, str):
+ raise ValueError("var_name must be a string.")
if default is NoValue:
- default_var = Var.create_safe("", _var_is_local=False, _var_is_string=False)
+ default_var = Var(_js_expr="")
elif not isinstance(default, Var):
- default_var = Var.create_safe(
- default,
- _var_is_string=isinstance(default, str),
- )
+ default_var = LiteralVar.create(default)
else:
default_var = default
setter_name = f"set{var_name.capitalize()}"
hooks = {
- f"const [{var_name}, {setter_name}] = useState({default_var._var_name_unwrapped})": None,
+ f"const [{var_name}, {setter_name}] = useState({default_var!s})": None,
}
imports = {
"react": [ImportVar(tag="useState")],
@@ -129,16 +116,14 @@ class ClientStateVar(Var):
hooks[f"{_client_state_ref(setter_name)} = {setter_name}"] = None
imports.update(_refs_import)
return cls(
- _var_name="",
+ _js_expr="",
_setter_name=setter_name,
_getter_name=var_name,
_global_ref=global_ref,
- _var_is_local=False,
- _var_is_string=False,
_var_type=default_var._var_type,
_var_data=VarData.merge(
default_var._var_data,
- VarData( # type: ignore
+ VarData(
hooks=hooks,
imports=imports,
),
@@ -157,12 +142,12 @@ class ClientStateVar(Var):
an accessor for the client state variable.
"""
return (
- Var.create_safe(
- _client_state_ref(self._getter_name)
- if self._global_ref
- else self._getter_name,
- _var_is_local=False,
- _var_is_string=False,
+ Var(
+ _js_expr=(
+ _client_state_ref(self._getter_name)
+ if self._global_ref
+ else self._getter_name
+ )
)
.to(self._var_type)
._replace(
@@ -190,27 +175,23 @@ class ClientStateVar(Var):
if self._global_ref
else self._setter_name
)
+ _var_data = VarData(imports=_refs_import if self._global_ref else {})
if value is not NoValue:
# This is a hack to make it work like an EventSpec taking an arg
- value = Var.create_safe(value, _var_is_string=isinstance(value, str))
- if not value._var_is_string and value._var_full_name.startswith("_"):
- arg = value._var_name_unwrapped.partition(".")[0]
+ value_var = LiteralVar.create(value)
+ _var_data = VarData.merge(_var_data, value_var._get_all_var_data())
+ value_str = str(value_var)
+
+ if value_str.startswith("_"):
+ # remove patterns of ["*"] from the value_str using regex
+ arg = re.sub(r"\[\".*\"\]", "", value_str)
+ setter = f"(({arg}) => {setter}({value_str}))"
else:
- arg = ""
- setter = f"({arg}) => {setter}({value._var_name_unwrapped})"
- return (
- Var.create_safe(
- setter,
- _var_is_local=False,
- _var_is_string=False,
- )
- .to(EventChain)
- ._replace(
- merge_var_data=VarData( # type: ignore
- imports=_refs_import if self._global_ref else {}
- )
- )
- )
+ setter = f"(() => {setter}({value_str}))"
+ return Var(
+ _js_expr=setter,
+ _var_data=_var_data,
+ ).to(FunctionVar, EventChain)
@property
def set(self) -> Var:
@@ -243,7 +224,7 @@ class ClientStateVar(Var):
"""
if not self._global_ref:
raise ValueError("ClientStateVar must be global to retrieve the value.")
- return call_script(_client_state_ref(self._getter_name), callback=callback)
+ return run_script(_client_state_ref(self._getter_name), callback=callback)
def push(self, value: Any) -> EventSpec:
"""Push a value to the client state variable from the backend.
@@ -261,4 +242,5 @@ class ClientStateVar(Var):
"""
if not self._global_ref:
raise ValueError("ClientStateVar must be global to push the value.")
- return call_script(f"{_client_state_ref(self._setter_name)}({value})")
+ value = Var.create(value)
+ return run_script(f"{_client_state_ref(self._setter_name)}({value})")
diff --git a/reflex/experimental/hooks.py b/reflex/experimental/hooks.py
index 848ad7fb7..7d648225a 100644
--- a/reflex/experimental/hooks.py
+++ b/reflex/experimental/hooks.py
@@ -3,7 +3,8 @@
from __future__ import annotations
from reflex.utils.imports import ImportVar
-from reflex.vars import Var, VarData
+from reflex.vars import VarData
+from reflex.vars.base import Var
def _compose_react_imports(tags: list[str]) -> dict[str, list[ImportVar]]:
@@ -21,10 +22,8 @@ def const(name, value) -> Var:
The constant Var.
"""
if isinstance(name, list):
- return Var.create_safe(
- f"const [{', '.join(name)}] = {value}", _var_is_string=False
- )
- return Var.create_safe(f"const {name} = {value}", _var_is_string=False)
+ return Var(_js_expr=f"const [{', '.join(name)}] = {value}")
+ return Var(_js_expr=f"const {name} = {value}")
def useCallback(func, deps) -> Var:
@@ -37,9 +36,8 @@ def useCallback(func, deps) -> Var:
Returns:
The useCallback hook.
"""
- return Var.create_safe(
- f"useCallback({func}, {deps})" if deps else f"useCallback({func})",
- _var_is_string=False,
+ return Var(
+ _js_expr=f"useCallback({func}, {deps})" if deps else f"useCallback({func})",
_var_data=VarData(imports=_compose_react_imports(["useCallback"])),
)
@@ -53,9 +51,8 @@ def useContext(context) -> Var:
Returns:
The useContext hook.
"""
- return Var.create_safe(
- f"useContext({context})",
- _var_is_string=False,
+ return Var(
+ _js_expr=f"useContext({context})",
_var_data=VarData(imports=_compose_react_imports(["useContext"])),
)
@@ -69,9 +66,8 @@ def useRef(default) -> Var:
Returns:
The useRef hook.
"""
- return Var.create_safe(
- f"useRef({default})",
- _var_is_string=False,
+ return Var(
+ _js_expr=f"useRef({default})",
_var_data=VarData(imports=_compose_react_imports(["useRef"])),
)
@@ -88,9 +84,8 @@ def useState(var_name, default=None) -> Var:
"""
return const(
[var_name, f"set{var_name.capitalize()}"],
- Var.create_safe(
- f"useState({default})",
- _var_is_string=False,
+ Var(
+ _js_expr=f"useState({default})",
_var_data=VarData(imports=_compose_react_imports(["useState"])),
),
)
diff --git a/reflex/experimental/layout.py b/reflex/experimental/layout.py
index cf39ccb6c..e5a1bab04 100644
--- a/reflex/experimental/layout.py
+++ b/reflex/experimental/layout.py
@@ -12,11 +12,11 @@ from reflex.components.radix.themes.components.icon_button import IconButton
from reflex.components.radix.themes.layout.box import Box
from reflex.components.radix.themes.layout.container import Container
from reflex.components.radix.themes.layout.stack import HStack
-from reflex.event import call_script
+from reflex.event import run_script
from reflex.experimental import hooks
from reflex.state import ComponentState
from reflex.style import Style
-from reflex.vars import Var
+from reflex.vars.base import Var
class Sidebar(Box, MemoizationLeaf):
@@ -33,12 +33,6 @@ class Sidebar(Box, MemoizationLeaf):
Returns:
The sidebar component.
"""
- # props.setdefault("border_right", f"1px solid {color('accent', 12)}")
- # props.setdefault("background_color", color("accent", 1))
- # props.setdefault("width", "20vw")
- # props.setdefault("height", "100vh")
- # props.setdefault("position", "fixed")
-
return super().create(
Box.create(*children, **props), # sidebar for content
Box.create(width=props.get("width")), # spacer for layout
@@ -55,7 +49,7 @@ class Sidebar(Box, MemoizationLeaf):
open = (
self.State.open # type: ignore
if self.State
- else Var.create_safe("open", _var_is_string=False)
+ else Var(_js_expr="open")
)
sidebar.style["display"] = spacer.style["display"] = cond(open, "block", "none")
@@ -172,8 +166,8 @@ class SidebarTrigger(Fragment):
open, toggle = sidebar.State.open, sidebar.State.toggle # type: ignore
else:
open, toggle = (
- Var.create_safe("open", _var_is_string=False),
- call_script(Var.create_safe("setOpen(!open)", _var_is_string=False)),
+ Var(_js_expr="open"),
+ run_script("setOpen(!open)"),
)
trigger_props["left"] = cond(open, f"calc({sidebar_width} - 32px)", "0")
diff --git a/reflex/experimental/layout.pyi b/reflex/experimental/layout.pyi
index 68e7e1ecd..4c7fc8d47 100644
--- a/reflex/experimental/layout.pyi
+++ b/reflex/experimental/layout.pyi
@@ -3,17 +3,17 @@
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
-from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload
+from typing import Any, Dict, List, Literal, Optional, Union, overload
from reflex import color
from reflex.components.base.fragment import Fragment
from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
from reflex.components.radix.primitives.drawer import DrawerRoot
from reflex.components.radix.themes.layout.box import Box
-from reflex.event import EventHandler, EventSpec
+from reflex.event import BASE_STATE, EventType
from reflex.state import ComponentState
from reflex.style import Style
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import Var
class Sidebar(Box, MemoizationLeaf):
@overload
@@ -21,81 +21,51 @@ class Sidebar(Box, MemoizationLeaf):
def create( # type: ignore
cls,
*children,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Sidebar":
"""Create the sidebar component.
@@ -125,75 +95,51 @@ class DrawerSidebar(DrawerRoot):
def create( # type: ignore
cls,
*children,
+ default_open: Optional[Union[Var[bool], bool]] = None,
open: Optional[Union[Var[bool], bool]] = None,
- should_scale_background: Optional[Union[Var[bool], bool]] = None,
- close_threshold: Optional[Union[Var[float], float]] = None,
- snap_points: Optional[List[Union[float, str]]] = None,
- fade_from_index: Optional[Union[Var[int], int]] = None,
- scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
modal: Optional[Union[Var[bool], bool]] = None,
direction: Optional[
Union[
- Var[Literal["top", "bottom", "left", "right"]],
- Literal["top", "bottom", "left", "right"],
+ Literal["bottom", "left", "right", "top"],
+ Var[Literal["bottom", "left", "right", "top"]],
]
] = None,
+ dismissible: Optional[Union[Var[bool], bool]] = None,
+ handle_only: Optional[Union[Var[bool], bool]] = None,
+ snap_points: Optional[List[Union[float, str]]] = None,
+ fade_from_index: Optional[Union[Var[int], int]] = None,
+ scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
preventScrollRestoration: Optional[Union[Var[bool], bool]] = None,
+ should_scale_background: Optional[Union[Var[bool], bool]] = None,
+ close_threshold: Optional[Union[Var[float], float]] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_animation_end: Optional[
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_open_change: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
+ Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "DrawerSidebar":
"""Create the sidebar component.
@@ -226,52 +172,22 @@ class SidebarTrigger(Fragment):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "SidebarTrigger":
"""Create the sidebar trigger component.
@@ -292,81 +208,51 @@ class Layout(Box):
cls,
*children,
sidebar: Optional[Component] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Layout":
"""Create the layout component.
@@ -390,81 +276,51 @@ class LayoutNamespace(ComponentNamespace):
def __call__(
*children,
sidebar: Optional[Component] = None,
- access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
content_editable: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
context_menu: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
enter_key_hint: Optional[
- Union[Var[Union[bool, int, str]], str, int, bool]
+ Union[Var[Union[bool, int, str]], bool, int, str]
] = None,
- hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
- title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None,
+ hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
+ title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
- custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
- on_blur: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_context_menu: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_double_click: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_focus: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_down: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_enter: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_leave: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_move: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_out: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_over: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_mouse_up: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_scroll: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
- on_unmount: Optional[
- Union[EventHandler, EventSpec, list, Callable, BaseVar]
- ] = None,
+ custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
+ on_blur: Optional[EventType[[], BASE_STATE]] = None,
+ on_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
+ on_double_click: Optional[EventType[[], BASE_STATE]] = None,
+ on_focus: Optional[EventType[[], BASE_STATE]] = None,
+ on_mount: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
+ on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
+ on_scroll: Optional[EventType[[], BASE_STATE]] = None,
+ on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "Layout":
"""Create the layout component.
diff --git a/reflex/experimental/misc.py b/reflex/experimental/misc.py
index 716d081b8..a2a5a0615 100644
--- a/reflex/experimental/misc.py
+++ b/reflex/experimental/misc.py
@@ -7,15 +7,17 @@ from typing import Any
async def run_in_thread(func) -> Any:
"""Run a function in a separate thread.
- To not block the UI event queue, run_in_thread must be inside inside a rx.background() decorated method.
+ To not block the UI event queue, run_in_thread must be inside inside a rx.event(background=True) decorated method.
Args:
func (callable): The non-async function to run.
+ Raises:
+ ValueError: If the function is an async function.
+
Returns:
Any: The return value of the function.
"""
- assert not asyncio.coroutines.iscoroutinefunction(
- func
- ), "func must be a non-async function"
+ if asyncio.coroutines.iscoroutinefunction(func):
+ raise ValueError("func must be a non-async function")
return await asyncio.get_event_loop().run_in_executor(None, func)
diff --git a/reflex/experimental/vars/base.py b/reflex/experimental/vars/base.py
deleted file mode 100644
index 7da1e6537..000000000
--- a/reflex/experimental/vars/base.py
+++ /dev/null
@@ -1,583 +0,0 @@
-"""Collection of base classes."""
-
-from __future__ import annotations
-
-import dataclasses
-import functools
-import inspect
-import sys
-from typing import (
- TYPE_CHECKING,
- Any,
- Callable,
- Dict,
- Generic,
- List,
- Optional,
- Set,
- Tuple,
- Type,
- TypeVar,
- Union,
- overload,
-)
-
-from typing_extensions import ParamSpec, get_origin
-
-from reflex import constants
-from reflex.base import Base
-from reflex.utils import serializers, types
-from reflex.utils.exceptions import VarTypeError
-from reflex.vars import (
- ImmutableVarData,
- Var,
- VarData,
- _decode_var_immutable,
- _extract_var_data,
- _global_vars,
-)
-
-if TYPE_CHECKING:
- from .function import FunctionVar, ToFunctionOperation
- from .number import (
- BooleanVar,
- NumberVar,
- ToBooleanVarOperation,
- ToNumberVarOperation,
- )
- from .object import ObjectVar, ToObjectOperation
- from .sequence import ArrayVar, StringVar, ToArrayOperation, ToStringOperation
-
-VAR_TYPE = TypeVar("VAR_TYPE")
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ImmutableVar(Var, Generic[VAR_TYPE]):
- """Base class for immutable vars."""
-
- # The name of the var.
- _var_name: str = dataclasses.field()
-
- # The type of the var.
- _var_type: types.GenericType = dataclasses.field(default=Any)
-
- # Extra metadata associated with the Var
- _var_data: Optional[ImmutableVarData] = dataclasses.field(default=None)
-
- def __str__(self) -> str:
- """String representation of the var. Guaranteed to be a valid Javascript expression.
-
- Returns:
- The name of the var.
- """
- return self._var_name
-
- @property
- def _var_is_local(self) -> bool:
- """Whether this is a local javascript variable.
-
- Returns:
- False
- """
- return False
-
- @property
- def _var_is_string(self) -> bool:
- """Whether the var is a string literal.
-
- Returns:
- False
- """
- return False
-
- @property
- def _var_full_name_needs_state_prefix(self) -> bool:
- """Whether the full name of the var needs a _var_state prefix.
-
- Returns:
- False
- """
- return False
-
- def __post_init__(self):
- """Post-initialize the var."""
- # Decode any inline Var markup and apply it to the instance
- _var_data, _var_name = _decode_var_immutable(self._var_name)
-
- if _var_data or _var_name != self._var_name:
- self.__init__(
- _var_name=_var_name,
- _var_type=self._var_type,
- _var_data=ImmutableVarData.merge(self._var_data, _var_data),
- )
-
- def __hash__(self) -> int:
- """Define a hash function for the var.
-
- Returns:
- The hash of the var.
- """
- return hash((self._var_name, self._var_type, self._var_data))
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return self._var_data
-
- def _replace(self, merge_var_data=None, **kwargs: Any):
- """Make a copy of this Var with updated fields.
-
- Args:
- merge_var_data: VarData to merge into the existing VarData.
- **kwargs: Var fields to update.
-
- Returns:
- A new ImmutableVar with the updated fields overwriting the corresponding fields in this Var.
-
- Raises:
- TypeError: If _var_is_local, _var_is_string, or _var_full_name_needs_state_prefix is not None.
- """
- if kwargs.get("_var_is_local", False) is not False:
- raise TypeError(
- "The _var_is_local argument is not supported for ImmutableVar."
- )
-
- if kwargs.get("_var_is_string", False) is not False:
- raise TypeError(
- "The _var_is_string argument is not supported for ImmutableVar."
- )
-
- if kwargs.get("_var_full_name_needs_state_prefix", False) is not False:
- raise TypeError(
- "The _var_full_name_needs_state_prefix argument is not supported for ImmutableVar."
- )
-
- field_values = dict(
- _var_name=kwargs.pop("_var_name", self._var_name),
- _var_type=kwargs.pop("_var_type", self._var_type),
- _var_data=ImmutableVarData.merge(
- kwargs.get("_var_data", self._var_data), merge_var_data
- ),
- )
- return type(self)(**field_values)
-
- @classmethod
- def create(
- cls,
- value: Any,
- _var_is_local: bool | None = None,
- _var_is_string: bool | None = None,
- _var_data: VarData | None = None,
- ) -> ImmutableVar | Var | None:
- """Create a var from a value.
-
- Args:
- value: The value to create the var from.
- _var_is_local: Whether the var is local. Deprecated.
- _var_is_string: Whether the var is a string literal. Deprecated.
- _var_data: Additional hooks and imports associated with the Var.
-
- Returns:
- The var.
-
- Raises:
- VarTypeError: If the value is JSON-unserializable.
- TypeError: If _var_is_local or _var_is_string is not None.
- """
- if _var_is_local is not None:
- raise TypeError(
- "The _var_is_local argument is not supported for ImmutableVar."
- )
-
- if _var_is_string is not None:
- raise TypeError(
- "The _var_is_string argument is not supported for ImmutableVar."
- )
-
- from reflex.utils import format
-
- # Check for none values.
- if value is None:
- return None
-
- # If the value is already a var, do nothing.
- if isinstance(value, Var):
- return value
-
- # Try to pull the imports and hooks from contained values.
- if not isinstance(value, str):
- _var_data = VarData.merge(*_extract_var_data(value), _var_data)
-
- # Try to serialize the value.
- type_ = type(value)
- if type_ in types.JSONType:
- name = value
- else:
- name, _serialized_type = serializers.serialize(value, get_type=True)
- if name is None:
- raise VarTypeError(
- f"No JSON serializer found for var {value} of type {type_}."
- )
- name = name if isinstance(name, str) else format.json_dumps(name)
-
- return cls(
- _var_name=name,
- _var_type=type_,
- _var_data=(
- ImmutableVarData(
- state=_var_data.state,
- imports=_var_data.imports,
- hooks=_var_data.hooks,
- )
- if _var_data
- else None
- ),
- )
-
- @classmethod
- def create_safe(
- cls,
- value: Any,
- _var_is_local: bool | None = None,
- _var_is_string: bool | None = None,
- _var_data: VarData | None = None,
- ) -> Var | ImmutableVar:
- """Create a var from a value, asserting that it is not None.
-
- Args:
- value: The value to create the var from.
- _var_is_local: Whether the var is local. Deprecated.
- _var_is_string: Whether the var is a string literal. Deprecated.
- _var_data: Additional hooks and imports associated with the Var.
-
- Returns:
- The var.
- """
- var = cls.create(
- value,
- _var_is_local=_var_is_local,
- _var_is_string=_var_is_string,
- _var_data=_var_data,
- )
- assert var is not None
- return var
-
- def __format__(self, format_spec: str) -> str:
- """Format the var into a Javascript equivalent to an f-string.
-
- Args:
- format_spec: The format specifier (Ignored for now).
-
- Returns:
- The formatted var.
- """
- hashed_var = hash(self)
-
- _global_vars[hashed_var] = self
-
- # Encode the _var_data into the formatted output for tracking purposes.
- return f"{constants.REFLEX_VAR_OPENING_TAG}{hashed_var}{constants.REFLEX_VAR_CLOSING_TAG}{self._var_name}"
-
- @overload
- def to(
- self, output: Type[NumberVar], var_type: type[int] | type[float] = float
- ) -> ToNumberVarOperation: ...
-
- @overload
- def to(self, output: Type[BooleanVar]) -> ToBooleanVarOperation: ...
-
- @overload
- def to(
- self,
- output: Type[ArrayVar],
- var_type: type[list] | type[tuple] | type[set] = list,
- ) -> ToArrayOperation: ...
-
- @overload
- def to(self, output: Type[StringVar]) -> ToStringOperation: ...
-
- @overload
- def to(
- self, output: Type[ObjectVar], var_type: types.GenericType = dict
- ) -> ToObjectOperation: ...
-
- @overload
- def to(
- self, output: Type[FunctionVar], var_type: Type[Callable] = Callable
- ) -> ToFunctionOperation: ...
-
- @overload
- def to(
- self, output: Type[OUTPUT], var_type: types.GenericType | None = None
- ) -> OUTPUT: ...
-
- def to(
- self, output: Type[OUTPUT], var_type: types.GenericType | None = None
- ) -> Var:
- """Convert the var to a different type.
-
- Args:
- output: The output type.
- var_type: The type of the var.
-
- Raises:
- TypeError: If the var_type is not a supported type for the output.
-
- Returns:
- The converted var.
- """
- from .number import (
- BooleanVar,
- NumberVar,
- ToBooleanVarOperation,
- ToNumberVarOperation,
- )
-
- fixed_type = (
- var_type
- if var_type is None or inspect.isclass(var_type)
- else get_origin(var_type)
- )
-
- if issubclass(output, NumberVar):
- if fixed_type is not None and not issubclass(fixed_type, (int, float)):
- raise TypeError(
- f"Unsupported type {var_type} for NumberVar. Must be int or float."
- )
- return ToNumberVarOperation(self, var_type or float)
- if issubclass(output, BooleanVar):
- return ToBooleanVarOperation(self)
-
- from .sequence import ArrayVar, StringVar, ToArrayOperation, ToStringOperation
-
- if issubclass(output, ArrayVar):
- if fixed_type is not None and not issubclass(
- fixed_type, (list, tuple, set)
- ):
- raise TypeError(
- f"Unsupported type {var_type} for ArrayVar. Must be list, tuple, or set."
- )
- return ToArrayOperation(self, var_type or list)
- if issubclass(output, StringVar):
- return ToStringOperation(self)
-
- from .object import ObjectVar, ToObjectOperation
-
- if issubclass(output, ObjectVar):
- return ToObjectOperation(self, var_type or dict)
-
- from .function import FunctionVar, ToFunctionOperation
-
- if issubclass(output, FunctionVar):
- if fixed_type is not None and not issubclass(fixed_type, Callable):
- raise TypeError(
- f"Unsupported type {var_type} for FunctionVar. Must be Callable."
- )
- return ToFunctionOperation(self, var_type or Callable)
-
- return output(
- _var_name=self._var_name,
- _var_type=self._var_type if var_type is None else var_type,
- _var_data=self._var_data,
- )
-
- def guess_type(self) -> ImmutableVar:
- """Guess the type of the var.
-
- Returns:
- The guessed type.
- """
- from .number import NumberVar
- from .object import ObjectVar
- from .sequence import ArrayVar, StringVar
-
- if self._var_type is Any:
- return self
-
- var_type = self._var_type
-
- fixed_type = var_type if inspect.isclass(var_type) else get_origin(var_type)
-
- if issubclass(fixed_type, (int, float)):
- return self.to(NumberVar, var_type)
- if issubclass(fixed_type, dict):
- return self.to(ObjectVar, var_type)
- if issubclass(fixed_type, (list, tuple, set)):
- return self.to(ArrayVar, var_type)
- if issubclass(fixed_type, str):
- return self.to(StringVar)
- if issubclass(fixed_type, Base):
- return self.to(ObjectVar, var_type)
- return self
-
-
-OUTPUT = TypeVar("OUTPUT", bound=ImmutableVar)
-
-
-class LiteralVar(ImmutableVar):
- """Base class for immutable literal vars."""
-
- @classmethod
- def create(
- cls,
- value: Any,
- _var_data: VarData | None = None,
- ) -> Var:
- """Create a var from a value.
-
- Args:
- value: The value to create the var from.
- _var_data: Additional hooks and imports associated with the Var.
-
- Returns:
- The var.
-
- Raises:
- TypeError: If the value is not a supported type for LiteralVar.
- """
- if isinstance(value, Var):
- if _var_data is None:
- return value
- return value._replace(merge_var_data=_var_data)
-
- if value is None:
- return ImmutableVar.create_safe("null", _var_data=_var_data)
-
- from .object import LiteralObjectVar
-
- if isinstance(value, Base):
- return LiteralObjectVar(
- value.dict(), _var_type=type(value), _var_data=_var_data
- )
-
- from .number import LiteralBooleanVar, LiteralNumberVar
- from .sequence import LiteralArrayVar, LiteralStringVar
-
- if isinstance(value, str):
- return LiteralStringVar.create(value, _var_data=_var_data)
-
- type_mapping = {
- int: LiteralNumberVar,
- float: LiteralNumberVar,
- bool: LiteralBooleanVar,
- dict: LiteralObjectVar,
- list: LiteralArrayVar,
- tuple: LiteralArrayVar,
- set: LiteralArrayVar,
- }
-
- constructor = type_mapping.get(type(value))
-
- if constructor is None:
- raise TypeError(f"Unsupported type {type(value)} for LiteralVar.")
-
- return constructor(value, _var_data=_var_data)
-
- def __post_init__(self):
- """Post-initialize the var."""
-
- def json(self) -> str:
- """Serialize the var to a JSON string.
-
- Raises:
- NotImplementedError: If the method is not implemented.
- """
- raise NotImplementedError(
- "LiteralVar subclasses must implement the json method."
- )
-
-
-P = ParamSpec("P")
-T = TypeVar("T", bound=ImmutableVar)
-
-
-def var_operation(*, output: Type[T]) -> Callable[[Callable[P, str]], Callable[P, T]]:
- """Decorator for creating a var operation.
-
- Example:
- ```python
- @var_operation(output=NumberVar)
- def add(a: NumberVar, b: NumberVar):
- return f"({a} + {b})"
- ```
-
- Args:
- output: The output type of the operation.
-
- Returns:
- The decorator.
- """
-
- def decorator(func: Callable[P, str], output=output):
- @functools.wraps(func)
- def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
- args_vars = [
- LiteralVar.create(arg) if not isinstance(arg, Var) else arg
- for arg in args
- ]
- kwargs_vars = {
- key: LiteralVar.create(value) if not isinstance(value, Var) else value
- for key, value in kwargs.items()
- }
- return output(
- _var_name=func(*args_vars, **kwargs_vars), # type: ignore
- _var_data=VarData.merge(
- *[arg._get_all_var_data() for arg in args if isinstance(arg, Var)],
- *[
- arg._get_all_var_data()
- for arg in kwargs.values()
- if isinstance(arg, Var)
- ],
- ),
- )
-
- return wrapper
-
- return decorator
-
-
-def unionize(*args: Type) -> Type:
- """Unionize the types.
-
- Args:
- args: The types to unionize.
-
- Returns:
- The unionized types.
- """
- if not args:
- return Any
- first, *rest = args
- if not rest:
- return first
- return Union[first, unionize(*rest)]
-
-
-def figure_out_type(value: Any) -> Type:
- """Figure out the type of the value.
-
- Args:
- value: The value to figure out the type of.
-
- Returns:
- The type of the value.
- """
- if isinstance(value, list):
- return List[unionize(*(figure_out_type(v) for v in value))]
- if isinstance(value, set):
- return Set[unionize(*(figure_out_type(v) for v in value))]
- if isinstance(value, tuple):
- return Tuple[unionize(*(figure_out_type(v) for v in value)), ...]
- if isinstance(value, dict):
- return Dict[
- unionize(*(figure_out_type(k) for k in value)),
- unionize(*(figure_out_type(v) for v in value.values())),
- ]
- return type(value)
diff --git a/reflex/experimental/vars/function.py b/reflex/experimental/vars/function.py
deleted file mode 100644
index 4514a482d..000000000
--- a/reflex/experimental/vars/function.py
+++ /dev/null
@@ -1,290 +0,0 @@
-"""Immutable function vars."""
-
-from __future__ import annotations
-
-import dataclasses
-import sys
-from functools import cached_property
-from typing import Any, Callable, Optional, Tuple, Type, Union
-
-from reflex.experimental.vars.base import ImmutableVar, LiteralVar
-from reflex.vars import ImmutableVarData, Var, VarData
-
-
-class FunctionVar(ImmutableVar[Callable]):
- """Base class for immutable function vars."""
-
- def __call__(self, *args: Var | Any) -> ArgsFunctionOperation:
- """Call the function with the given arguments.
-
- Args:
- *args: The arguments to call the function with.
-
- Returns:
- The function call operation.
- """
- return ArgsFunctionOperation(
- ("...args",),
- VarOperationCall(self, *args, ImmutableVar.create_safe("...args")),
- )
-
- def call(self, *args: Var | Any) -> VarOperationCall:
- """Call the function with the given arguments.
-
- Args:
- *args: The arguments to call the function with.
-
- Returns:
- The function call operation.
- """
- return VarOperationCall(self, *args)
-
-
-class FunctionStringVar(FunctionVar):
- """Base class for immutable function vars from a string."""
-
- def __init__(self, func: str, _var_data: VarData | None = None) -> None:
- """Initialize the function var.
-
- Args:
- func: The function to call.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(FunctionVar, self).__init__(
- _var_name=func,
- _var_type=Callable,
- _var_data=ImmutableVarData.merge(_var_data),
- )
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class VarOperationCall(ImmutableVar):
- """Base class for immutable vars that are the result of a function call."""
-
- _func: Optional[FunctionVar] = dataclasses.field(default=None)
- _args: Tuple[Union[Var, Any], ...] = dataclasses.field(default_factory=tuple)
-
- def __init__(
- self, func: FunctionVar, *args: Var | Any, _var_data: VarData | None = None
- ):
- """Initialize the function call var.
-
- Args:
- func: The function to call.
- *args: The arguments to call the function with.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(VarOperationCall, self).__init__(
- _var_name="",
- _var_type=Any,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "_func", func)
- object.__setattr__(self, "_args", args)
- object.__delattr__(self, "_var_name")
-
- def __getattr__(self, name):
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute of the var.
- """
- if name == "_var_name":
- return self._cached_var_name
- return super(type(self), self).__getattr__(name)
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"({str(self._func)}({', '.join([str(LiteralVar.create(arg)) for arg in self._args])}))"
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self._func._get_all_var_data() if self._func is not None else None,
- *[var._get_all_var_data() for var in self._args],
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- """Wrapper method for cached property.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return self._cached_get_all_var_data
-
- def __post_init__(self):
- """Post-initialize the var."""
- pass
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ArgsFunctionOperation(FunctionVar):
- """Base class for immutable function defined via arguments and return expression."""
-
- _args_names: Tuple[str, ...] = dataclasses.field(default_factory=tuple)
- _return_expr: Union[Var, Any] = dataclasses.field(default=None)
-
- def __init__(
- self,
- args_names: Tuple[str, ...],
- return_expr: Var | Any,
- _var_data: VarData | None = None,
- ) -> None:
- """Initialize the function with arguments var.
-
- Args:
- args_names: The names of the arguments.
- return_expr: The return expression of the function.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(ArgsFunctionOperation, self).__init__(
- _var_name=f"",
- _var_type=Callable,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "_args_names", args_names)
- object.__setattr__(self, "_return_expr", return_expr)
- object.__delattr__(self, "_var_name")
-
- def __getattr__(self, name):
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute of the var.
- """
- if name == "_var_name":
- return self._cached_var_name
- return super(type(self), self).__getattr__(name)
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"(({', '.join(self._args_names)}) => ({str(LiteralVar.create(self._return_expr))}))"
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self._return_expr._get_all_var_data(),
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- """Wrapper method for cached property.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return self._cached_get_all_var_data
-
- def __post_init__(self):
- """Post-initialize the var."""
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ToFunctionOperation(FunctionVar):
- """Base class of converting a var to a function."""
-
- _original_var: Var = dataclasses.field(
- default_factory=lambda: LiteralVar.create(None)
- )
-
- def __init__(
- self,
- original_var: Var,
- _var_type: Type[Callable] = Callable,
- _var_data: VarData | None = None,
- ) -> None:
- """Initialize the function with arguments var.
-
- Args:
- original_var: The original var to convert to a function.
- _var_type: The type of the function.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(ToFunctionOperation, self).__init__(
- _var_name=f"",
- _var_type=_var_type,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "_original_var", original_var)
- object.__delattr__(self, "_var_name")
-
- def __getattr__(self, name):
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute of the var.
- """
- if name == "_var_name":
- return self._cached_var_name
- return super(type(self), self).__getattr__(name)
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return str(self._original_var)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self._original_var._get_all_var_data(),
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- """Wrapper method for cached property.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return self._cached_get_all_var_data
diff --git a/reflex/experimental/vars/number.py b/reflex/experimental/vars/number.py
deleted file mode 100644
index 6bd3a7ff7..000000000
--- a/reflex/experimental/vars/number.py
+++ /dev/null
@@ -1,1458 +0,0 @@
-"""Immutable number vars."""
-
-from __future__ import annotations
-
-import dataclasses
-import json
-import sys
-from functools import cached_property
-from typing import Any, Union
-
-from reflex.experimental.vars.base import (
- ImmutableVar,
- LiteralVar,
-)
-from reflex.vars import ImmutableVarData, Var, VarData
-
-
-class NumberVar(ImmutableVar[Union[int, float]]):
- """Base class for immutable number vars."""
-
- def __add__(self, other: number_types | boolean_types) -> NumberAddOperation:
- """Add two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number addition operation.
- """
- return NumberAddOperation(self, +other)
-
- def __radd__(self, other: number_types | boolean_types) -> NumberAddOperation:
- """Add two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number addition operation.
- """
- return NumberAddOperation(+other, self)
-
- def __sub__(self, other: number_types | boolean_types) -> NumberSubtractOperation:
- """Subtract two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number subtraction operation.
- """
- return NumberSubtractOperation(self, +other)
-
- def __rsub__(self, other: number_types | boolean_types) -> NumberSubtractOperation:
- """Subtract two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number subtraction operation.
- """
- return NumberSubtractOperation(+other, self)
-
- def __abs__(self) -> NumberAbsoluteOperation:
- """Get the absolute value of the number.
-
- Returns:
- The number absolute operation.
- """
- return NumberAbsoluteOperation(self)
-
- def __mul__(self, other: number_types | boolean_types) -> NumberMultiplyOperation:
- """Multiply two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number multiplication operation.
- """
- return NumberMultiplyOperation(self, +other)
-
- def __rmul__(self, other: number_types | boolean_types) -> NumberMultiplyOperation:
- """Multiply two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number multiplication operation.
- """
- return NumberMultiplyOperation(+other, self)
-
- def __truediv__(self, other: number_types | boolean_types) -> NumberTrueDivision:
- """Divide two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number true division operation.
- """
- return NumberTrueDivision(self, +other)
-
- def __rtruediv__(self, other: number_types | boolean_types) -> NumberTrueDivision:
- """Divide two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number true division operation.
- """
- return NumberTrueDivision(+other, self)
-
- def __floordiv__(self, other: number_types | boolean_types) -> NumberFloorDivision:
- """Floor divide two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number floor division operation.
- """
- return NumberFloorDivision(self, +other)
-
- def __rfloordiv__(self, other: number_types | boolean_types) -> NumberFloorDivision:
- """Floor divide two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number floor division operation.
- """
- return NumberFloorDivision(+other, self)
-
- def __mod__(self, other: number_types | boolean_types) -> NumberModuloOperation:
- """Modulo two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number modulo operation.
- """
- return NumberModuloOperation(self, +other)
-
- def __rmod__(self, other: number_types | boolean_types) -> NumberModuloOperation:
- """Modulo two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number modulo operation.
- """
- return NumberModuloOperation(+other, self)
-
- def __pow__(self, other: number_types | boolean_types) -> NumberExponentOperation:
- """Exponentiate two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number exponent operation.
- """
- return NumberExponentOperation(self, +other)
-
- def __rpow__(self, other: number_types | boolean_types) -> NumberExponentOperation:
- """Exponentiate two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The number exponent operation.
- """
- return NumberExponentOperation(+other, self)
-
- def __neg__(self) -> NumberNegateOperation:
- """Negate the number.
-
- Returns:
- The number negation operation.
- """
- return NumberNegateOperation(self)
-
- def __and__(self, other: number_types | boolean_types) -> BooleanAndOperation:
- """Boolean AND two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The boolean AND operation.
- """
- boolified_other = other.bool() if isinstance(other, Var) else bool(other)
- return BooleanAndOperation(self.bool(), boolified_other)
-
- def __rand__(self, other: number_types | boolean_types) -> BooleanAndOperation:
- """Boolean AND two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The boolean AND operation.
- """
- boolified_other = other.bool() if isinstance(other, Var) else bool(other)
- return BooleanAndOperation(boolified_other, self.bool())
-
- def __or__(self, other: number_types | boolean_types) -> BooleanOrOperation:
- """Boolean OR two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The boolean OR operation.
- """
- boolified_other = other.bool() if isinstance(other, Var) else bool(other)
- return BooleanOrOperation(self.bool(), boolified_other)
-
- def __ror__(self, other: number_types | boolean_types) -> BooleanOrOperation:
- """Boolean OR two numbers.
-
- Args:
- other: The other number.
-
- Returns:
- The boolean OR operation.
- """
- boolified_other = other.bool() if isinstance(other, Var) else bool(other)
- return BooleanOrOperation(boolified_other, self.bool())
-
- def __invert__(self) -> BooleanNotOperation:
- """Boolean NOT the number.
-
- Returns:
- The boolean NOT operation.
- """
- return BooleanNotOperation(self.bool())
-
- def __pos__(self) -> NumberVar:
- """Positive the number.
-
- Returns:
- The number.
- """
- return self
-
- def __round__(self) -> NumberRoundOperation:
- """Round the number.
-
- Returns:
- The number round operation.
- """
- return NumberRoundOperation(self)
-
- def __ceil__(self) -> NumberCeilOperation:
- """Ceil the number.
-
- Returns:
- The number ceil operation.
- """
- return NumberCeilOperation(self)
-
- def __floor__(self) -> NumberFloorOperation:
- """Floor the number.
-
- Returns:
- The number floor operation.
- """
- return NumberFloorOperation(self)
-
- def __trunc__(self) -> NumberTruncOperation:
- """Trunc the number.
-
- Returns:
- The number trunc operation.
- """
- return NumberTruncOperation(self)
-
- def __lt__(self, other: number_types | boolean_types) -> LessThanOperation:
- """Less than comparison.
-
- Args:
- other: The other number.
-
- Returns:
- The result of the comparison.
- """
- return LessThanOperation(self, +other)
-
- def __le__(self, other: number_types | boolean_types) -> LessThanOrEqualOperation:
- """Less than or equal comparison.
-
- Args:
- other: The other number.
-
- Returns:
- The result of the comparison.
- """
- return LessThanOrEqualOperation(self, +other)
-
- def __eq__(self, other: number_types | boolean_types) -> EqualOperation:
- """Equal comparison.
-
- Args:
- other: The other number.
-
- Returns:
- The result of the comparison.
- """
- return EqualOperation(self, +other)
-
- def __ne__(self, other: number_types | boolean_types) -> NotEqualOperation:
- """Not equal comparison.
-
- Args:
- other: The other number.
-
- Returns:
- The result of the comparison.
- """
- return NotEqualOperation(self, +other)
-
- def __gt__(self, other: number_types | boolean_types) -> GreaterThanOperation:
- """Greater than comparison.
-
- Args:
- other: The other number.
-
- Returns:
- The result of the comparison.
- """
- return GreaterThanOperation(self, +other)
-
- def __ge__(
- self, other: number_types | boolean_types
- ) -> GreaterThanOrEqualOperation:
- """Greater than or equal comparison.
-
- Args:
- other: The other number.
-
- Returns:
- The result of the comparison.
- """
- return GreaterThanOrEqualOperation(self, +other)
-
- def bool(self) -> NotEqualOperation:
- """Boolean conversion.
-
- Returns:
- The boolean value of the number.
- """
- return NotEqualOperation(self, 0)
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class BinaryNumberOperation(NumberVar):
- """Base class for immutable number vars that are the result of a binary operation."""
-
- a: number_types = dataclasses.field(default=0)
- b: number_types = dataclasses.field(default=0)
-
- def __init__(
- self,
- a: number_types,
- b: number_types,
- _var_data: VarData | None = None,
- ):
- """Initialize the binary number operation var.
-
- Args:
- a: The first number.
- b: The second number.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(BinaryNumberOperation, self).__init__(
- _var_name="",
- _var_type=float,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "a", a)
- object.__setattr__(self, "b", b)
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Raises:
- NotImplementedError: Must be implemented by subclasses
- """
- raise NotImplementedError(
- "BinaryNumberOperation must implement _cached_var_name"
- )
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(BinaryNumberOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b)
- return ImmutableVarData.merge(
- first_value._get_all_var_data(),
- second_value._get_all_var_data(),
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class UnaryNumberOperation(NumberVar):
- """Base class for immutable number vars that are the result of a unary operation."""
-
- a: number_types = dataclasses.field(default=0)
-
- def __init__(
- self,
- a: number_types,
- _var_data: VarData | None = None,
- ):
- """Initialize the unary number operation var.
-
- Args:
- a: The number.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(UnaryNumberOperation, self).__init__(
- _var_name="",
- _var_type=float,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "a", a)
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Raises:
- NotImplementedError: Must be implemented by subclasses.
- """
- raise NotImplementedError(
- "UnaryNumberOperation must implement _cached_var_name"
- )
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(UnaryNumberOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- return ImmutableVarData.merge(value._get_all_var_data(), self._var_data)
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-class NumberAddOperation(BinaryNumberOperation):
- """Base class for immutable number vars that are the result of an addition operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b)
- return f"({str(first_value)} + {str(second_value)})"
-
-
-class NumberSubtractOperation(BinaryNumberOperation):
- """Base class for immutable number vars that are the result of a subtraction operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b)
- return f"({str(first_value)} - {str(second_value)})"
-
-
-class NumberAbsoluteOperation(UnaryNumberOperation):
- """Base class for immutable number vars that are the result of an absolute operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- return f"Math.abs({str(value)})"
-
-
-class NumberMultiplyOperation(BinaryNumberOperation):
- """Base class for immutable number vars that are the result of a multiplication operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b)
- return f"({str(first_value)} * {str(second_value)})"
-
-
-class NumberNegateOperation(UnaryNumberOperation):
- """Base class for immutable number vars that are the result of a negation operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- return f"-({str(value)})"
-
-
-class NumberTrueDivision(BinaryNumberOperation):
- """Base class for immutable number vars that are the result of a true division operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b)
- return f"({str(first_value)} / {str(second_value)})"
-
-
-class NumberFloorDivision(BinaryNumberOperation):
- """Base class for immutable number vars that are the result of a floor division operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b)
- return f"Math.floor({str(first_value)} / {str(second_value)})"
-
-
-class NumberModuloOperation(BinaryNumberOperation):
- """Base class for immutable number vars that are the result of a modulo operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b)
- return f"({str(first_value)} % {str(second_value)})"
-
-
-class NumberExponentOperation(BinaryNumberOperation):
- """Base class for immutable number vars that are the result of an exponent operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b)
- return f"({str(first_value)} ** {str(second_value)})"
-
-
-class NumberRoundOperation(UnaryNumberOperation):
- """Base class for immutable number vars that are the result of a round operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- return f"Math.round({str(value)})"
-
-
-class NumberCeilOperation(UnaryNumberOperation):
- """Base class for immutable number vars that are the result of a ceil operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- return f"Math.ceil({str(value)})"
-
-
-class NumberFloorOperation(UnaryNumberOperation):
- """Base class for immutable number vars that are the result of a floor operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- return f"Math.floor({str(value)})"
-
-
-class NumberTruncOperation(UnaryNumberOperation):
- """Base class for immutable number vars that are the result of a trunc operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a)
- return f"Math.trunc({str(value)})"
-
-
-class BooleanVar(ImmutableVar[bool]):
- """Base class for immutable boolean vars."""
-
- def __and__(self, other: bool) -> BooleanAndOperation:
- """AND two booleans.
-
- Args:
- other: The other boolean.
-
- Returns:
- The boolean AND operation.
- """
- return BooleanAndOperation(self, other)
-
- def __rand__(self, other: bool) -> BooleanAndOperation:
- """AND two booleans.
-
- Args:
- other: The other boolean.
-
- Returns:
- The boolean AND operation.
- """
- return BooleanAndOperation(other, self)
-
- def __or__(self, other: bool) -> BooleanOrOperation:
- """OR two booleans.
-
- Args:
- other: The other boolean.
-
- Returns:
- The boolean OR operation.
- """
- return BooleanOrOperation(self, other)
-
- def __ror__(self, other: bool) -> BooleanOrOperation:
- """OR two booleans.
-
- Args:
- other: The other boolean.
-
- Returns:
- The boolean OR operation.
- """
- return BooleanOrOperation(other, self)
-
- def __invert__(self) -> BooleanNotOperation:
- """NOT the boolean.
-
- Returns:
- The boolean NOT operation.
- """
- return BooleanNotOperation(self)
-
- def __int__(self) -> BooleanToIntOperation:
- """Convert the boolean to an int.
-
- Returns:
- The boolean to int operation.
- """
- return BooleanToIntOperation(self)
-
- def __pos__(self) -> BooleanToIntOperation:
- """Convert the boolean to an int.
-
- Returns:
- The boolean to int operation.
- """
- return BooleanToIntOperation(self)
-
- def bool(self) -> BooleanVar:
- """Boolean conversion.
-
- Returns:
- The boolean value of the boolean.
- """
- return self
-
- def __lt__(self, other: boolean_types | number_types) -> LessThanOperation:
- """Less than comparison.
-
- Args:
- other: The other boolean.
-
- Returns:
- The result of the comparison.
- """
- return LessThanOperation(+self, +other)
-
- def __le__(self, other: boolean_types | number_types) -> LessThanOrEqualOperation:
- """Less than or equal comparison.
-
- Args:
- other: The other boolean.
-
- Returns:
- The result of the comparison.
- """
- return LessThanOrEqualOperation(+self, +other)
-
- def __eq__(self, other: boolean_types | number_types) -> EqualOperation:
- """Equal comparison.
-
- Args:
- other: The other boolean.
-
- Returns:
- The result of the comparison.
- """
- return EqualOperation(+self, +other)
-
- def __ne__(self, other: boolean_types | number_types) -> NotEqualOperation:
- """Not equal comparison.
-
- Args:
- other: The other boolean.
-
- Returns:
- The result of the comparison.
- """
- return NotEqualOperation(+self, +other)
-
- def __gt__(self, other: boolean_types | number_types) -> GreaterThanOperation:
- """Greater than comparison.
-
- Args:
- other: The other boolean.
-
- Returns:
- The result of the comparison.
- """
- return GreaterThanOperation(+self, +other)
-
- def __ge__(
- self, other: boolean_types | number_types
- ) -> GreaterThanOrEqualOperation:
- """Greater than or equal comparison.
-
- Args:
- other: The other boolean.
-
- Returns:
- The result of the comparison.
- """
- return GreaterThanOrEqualOperation(+self, +other)
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class BooleanToIntOperation(NumberVar):
- """Base class for immutable number vars that are the result of a boolean to int operation."""
-
- a: boolean_types = dataclasses.field(default=False)
-
- def __init__(
- self,
- a: boolean_types,
- _var_data: VarData | None = None,
- ):
- """Initialize the boolean to int operation var.
-
- Args:
- a: The boolean.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(BooleanToIntOperation, self).__init__(
- _var_name="",
- _var_type=int,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "a", a)
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"({str(self.a)} ? 1 : 0)"
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(BooleanToIntOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.a._get_all_var_data() if isinstance(self.a, Var) else None,
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class NumberComparisonOperation(BooleanVar):
- """Base class for immutable boolean vars that are the result of a comparison operation."""
-
- a: number_types = dataclasses.field(default=0)
- b: number_types = dataclasses.field(default=0)
-
- def __init__(
- self,
- a: number_types,
- b: number_types,
- _var_data: VarData | None = None,
- ):
- """Initialize the comparison operation var.
-
- Args:
- a: The first value.
- b: The second value.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(NumberComparisonOperation, self).__init__(
- _var_name="",
- _var_type=bool,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "a", a)
- object.__setattr__(self, "b", b)
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Raises:
- NotImplementedError: Must be implemented by subclasses.
- """
- raise NotImplementedError("ComparisonOperation must implement _cached_var_name")
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(NumberComparisonOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b)
- return ImmutableVarData.merge(
- first_value._get_all_var_data(), second_value._get_all_var_data()
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-class GreaterThanOperation(NumberComparisonOperation):
- """Base class for immutable boolean vars that are the result of a greater than operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b)
- return f"({str(first_value)} > {str(second_value)})"
-
-
-class GreaterThanOrEqualOperation(NumberComparisonOperation):
- """Base class for immutable boolean vars that are the result of a greater than or equal operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b)
- return f"({str(first_value)} >= {str(second_value)})"
-
-
-class LessThanOperation(NumberComparisonOperation):
- """Base class for immutable boolean vars that are the result of a less than operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b)
- return f"({str(first_value)} < {str(second_value)})"
-
-
-class LessThanOrEqualOperation(NumberComparisonOperation):
- """Base class for immutable boolean vars that are the result of a less than or equal operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b)
- return f"({str(first_value)} <= {str(second_value)})"
-
-
-class EqualOperation(NumberComparisonOperation):
- """Base class for immutable boolean vars that are the result of an equal operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b)
- return f"({str(first_value)} == {str(second_value)})"
-
-
-class NotEqualOperation(NumberComparisonOperation):
- """Base class for immutable boolean vars that are the result of a not equal operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b)
- return f"({str(first_value)} != {str(second_value)})"
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class LogicalOperation(BooleanVar):
- """Base class for immutable boolean vars that are the result of a logical operation."""
-
- a: boolean_types = dataclasses.field(default=False)
- b: boolean_types = dataclasses.field(default=False)
-
- def __init__(
- self, a: boolean_types, b: boolean_types, _var_data: VarData | None = None
- ):
- """Initialize the logical operation var.
-
- Args:
- a: The first value.
- b: The second value.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(LogicalOperation, self).__init__(
- _var_name="",
- _var_type=bool,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "a", a)
- object.__setattr__(self, "b", b)
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Raises:
- NotImplementedError: Must be implemented by subclasses.
- """
- raise NotImplementedError("LogicalOperation must implement _cached_var_name")
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(LogicalOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b)
- return ImmutableVarData.merge(
- first_value._get_all_var_data(), second_value._get_all_var_data()
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-class BooleanAndOperation(LogicalOperation):
- """Base class for immutable boolean vars that are the result of a logical AND operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b)
- return f"({str(first_value)} && {str(second_value)})"
-
-
-class BooleanOrOperation(LogicalOperation):
- """Base class for immutable boolean vars that are the result of a logical OR operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a)
- second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b)
- return f"({str(first_value)} || {str(second_value)})"
-
-
-class BooleanNotOperation(BooleanVar):
- """Base class for immutable boolean vars that are the result of a logical NOT operation."""
-
- a: boolean_types = dataclasses.field()
-
- def __init__(self, a: boolean_types, _var_data: VarData | None = None):
- """Initialize the logical NOT operation var.
-
- Args:
- a: The value.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(BooleanNotOperation, self).__init__(
- _var_name="",
- _var_type=bool,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "a", a)
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a)
- return f"!({str(value)})"
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(BooleanNotOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a)
- return ImmutableVarData.merge(value._get_all_var_data())
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class LiteralBooleanVar(LiteralVar, BooleanVar):
- """Base class for immutable literal boolean vars."""
-
- _var_value: bool = dataclasses.field(default=False)
-
- def __init__(
- self,
- _var_value: bool,
- _var_data: VarData | None = None,
- ):
- """Initialize the boolean var.
-
- Args:
- _var_value: The value of the var.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(LiteralBooleanVar, self).__init__(
- _var_name="true" if _var_value else "false",
- _var_type=bool,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "_var_value", _var_value)
-
- def __hash__(self) -> int:
- """Hash the var.
-
- Returns:
- The hash of the var.
- """
- return hash((self.__class__.__name__, self._var_value))
-
- def json(self) -> str:
- """Get the JSON representation of the var.
-
- Returns:
- The JSON representation of the var.
- """
- return "true" if self._var_value else "false"
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class LiteralNumberVar(LiteralVar, NumberVar):
- """Base class for immutable literal number vars."""
-
- _var_value: float | int = dataclasses.field(default=0)
-
- def __init__(
- self,
- _var_value: float | int,
- _var_data: VarData | None = None,
- ):
- """Initialize the number var.
-
- Args:
- _var_value: The value of the var.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(LiteralNumberVar, self).__init__(
- _var_name=str(_var_value),
- _var_type=type(_var_value),
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "_var_value", _var_value)
-
- def __hash__(self) -> int:
- """Hash the var.
-
- Returns:
- The hash of the var.
- """
- return hash((self.__class__.__name__, self._var_value))
-
- def json(self) -> str:
- """Get the JSON representation of the var.
-
- Returns:
- The JSON representation of the var.
- """
- return json.dumps(self._var_value)
-
-
-number_types = Union[NumberVar, LiteralNumberVar, int, float]
-boolean_types = Union[BooleanVar, LiteralBooleanVar, bool]
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ToNumberVarOperation(NumberVar):
- """Base class for immutable number vars that are the result of a number operation."""
-
- _original_value: Var = dataclasses.field(
- default_factory=lambda: LiteralNumberVar(0)
- )
-
- def __init__(
- self,
- _original_value: Var,
- _var_type: type[int] | type[float] = float,
- _var_data: VarData | None = None,
- ):
- """Initialize the number var.
-
- Args:
- _original_value: The original value.
- _var_type: The type of the Var.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(ToNumberVarOperation, self).__init__(
- _var_name="",
- _var_type=_var_type,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "_original_value", _original_value)
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return str(self._original_value)
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(ToNumberVarOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self._original_value._get_all_var_data(), self._var_data
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ToBooleanVarOperation(BooleanVar):
- """Base class for immutable boolean vars that are the result of a boolean operation."""
-
- _original_value: Var = dataclasses.field(
- default_factory=lambda: LiteralBooleanVar(False)
- )
-
- def __init__(
- self,
- _original_value: Var,
- _var_data: VarData | None = None,
- ):
- """Initialize the boolean var.
-
- Args:
- _original_value: The original value.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(ToBooleanVarOperation, self).__init__(
- _var_name="",
- _var_type=bool,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "_original_value", _original_value)
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return str(self._original_value)
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(ToBooleanVarOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self._original_value._get_all_var_data(), self._var_data
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
diff --git a/reflex/experimental/vars/object.py b/reflex/experimental/vars/object.py
deleted file mode 100644
index a227f0d7c..000000000
--- a/reflex/experimental/vars/object.py
+++ /dev/null
@@ -1,804 +0,0 @@
-"""Classes for immutable object vars."""
-
-from __future__ import annotations
-
-import dataclasses
-import sys
-import typing
-from functools import cached_property
-from inspect import isclass
-from typing import (
- Any,
- Dict,
- List,
- NoReturn,
- Tuple,
- Type,
- TypeVar,
- Union,
- get_args,
- overload,
-)
-
-from typing_extensions import get_origin
-
-from reflex.experimental.vars.base import (
- ImmutableVar,
- LiteralVar,
- figure_out_type,
-)
-from reflex.experimental.vars.number import NumberVar
-from reflex.experimental.vars.sequence import ArrayVar, StringVar
-from reflex.utils.exceptions import VarAttributeError
-from reflex.utils.types import GenericType, get_attribute_access_type
-from reflex.vars import ImmutableVarData, Var, VarData
-
-OBJECT_TYPE = TypeVar("OBJECT_TYPE")
-
-KEY_TYPE = TypeVar("KEY_TYPE")
-VALUE_TYPE = TypeVar("VALUE_TYPE")
-
-ARRAY_INNER_TYPE = TypeVar("ARRAY_INNER_TYPE")
-
-OTHER_KEY_TYPE = TypeVar("OTHER_KEY_TYPE")
-
-
-class ObjectVar(ImmutableVar[OBJECT_TYPE]):
- """Base class for immutable object vars."""
-
- @overload
- def _key_type(self: ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]]) -> KEY_TYPE: ...
-
- @overload
- def _key_type(self) -> Type: ...
-
- def _key_type(self) -> Type:
- """Get the type of the keys of the object.
-
- Returns:
- The type of the keys of the object.
- """
- fixed_type = (
- self._var_type if isclass(self._var_type) else get_origin(self._var_type)
- )
- args = get_args(self._var_type) if issubclass(fixed_type, dict) else ()
- return args[0] if args else Any
-
- @overload
- def _value_type(self: ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]]) -> VALUE_TYPE: ...
-
- @overload
- def _value_type(self) -> Type: ...
-
- def _value_type(self) -> Type:
- """Get the type of the values of the object.
-
- Returns:
- The type of the values of the object.
- """
- fixed_type = (
- self._var_type if isclass(self._var_type) else get_origin(self._var_type)
- )
- args = get_args(self._var_type) if issubclass(fixed_type, dict) else ()
- return args[1] if args else Any
-
- @overload
- def keys(
- self: ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]],
- ) -> ArrayVar[List[KEY_TYPE]]: ...
-
- @overload
- def keys(self) -> ArrayVar: ...
-
- def keys(self) -> ArrayVar:
- """Get the keys of the object.
-
- Returns:
- The keys of the object.
- """
- return ObjectKeysOperation(self)
-
- @overload
- def values(
- self: ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]],
- ) -> ArrayVar[List[VALUE_TYPE]]: ...
-
- @overload
- def values(self) -> ArrayVar: ...
-
- def values(self) -> ArrayVar:
- """Get the values of the object.
-
- Returns:
- The values of the object.
- """
- return ObjectValuesOperation(self)
-
- @overload
- def entries(
- self: ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]],
- ) -> ArrayVar[List[Tuple[KEY_TYPE, VALUE_TYPE]]]: ...
-
- @overload
- def entries(self) -> ArrayVar: ...
-
- def entries(self) -> ArrayVar:
- """Get the entries of the object.
-
- Returns:
- The entries of the object.
- """
- return ObjectEntriesOperation(self)
-
- def merge(self, other: ObjectVar) -> ObjectMergeOperation:
- """Merge two objects.
-
- Args:
- other: The other object to merge.
-
- Returns:
- The merged object.
- """
- return ObjectMergeOperation(self, other)
-
- # NoReturn is used here to catch when key value is Any
- @overload
- def __getitem__(
- self: ObjectVar[Dict[KEY_TYPE, NoReturn]],
- key: Var | Any,
- ) -> ImmutableVar: ...
-
- @overload
- def __getitem__(
- self: (
- ObjectVar[Dict[KEY_TYPE, int]]
- | ObjectVar[Dict[KEY_TYPE, float]]
- | ObjectVar[Dict[KEY_TYPE, int | float]]
- ),
- key: Var | Any,
- ) -> NumberVar: ...
-
- @overload
- def __getitem__(
- self: ObjectVar[Dict[KEY_TYPE, str]],
- key: Var | Any,
- ) -> StringVar: ...
-
- @overload
- def __getitem__(
- self: ObjectVar[Dict[KEY_TYPE, list[ARRAY_INNER_TYPE]]],
- key: Var | Any,
- ) -> ArrayVar[list[ARRAY_INNER_TYPE]]: ...
-
- @overload
- def __getitem__(
- self: ObjectVar[Dict[KEY_TYPE, set[ARRAY_INNER_TYPE]]],
- key: Var | Any,
- ) -> ArrayVar[set[ARRAY_INNER_TYPE]]: ...
-
- @overload
- def __getitem__(
- self: ObjectVar[Dict[KEY_TYPE, tuple[ARRAY_INNER_TYPE, ...]]],
- key: Var | Any,
- ) -> ArrayVar[tuple[ARRAY_INNER_TYPE, ...]]: ...
-
- @overload
- def __getitem__(
- self: ObjectVar[Dict[KEY_TYPE, dict[OTHER_KEY_TYPE, VALUE_TYPE]]],
- key: Var | Any,
- ) -> ObjectVar[dict[OTHER_KEY_TYPE, VALUE_TYPE]]: ...
-
- def __getitem__(self, key: Var | Any) -> ImmutableVar:
- """Get an item from the object.
-
- Args:
- key: The key to get from the object.
-
- Returns:
- The item from the object.
- """
- return ObjectItemOperation(self, key).guess_type()
-
- # NoReturn is used here to catch when key value is Any
- @overload
- def __getattr__(
- self: ObjectVar[Dict[KEY_TYPE, NoReturn]],
- name: str,
- ) -> ImmutableVar: ...
-
- @overload
- def __getattr__(
- self: (
- ObjectVar[Dict[KEY_TYPE, int]]
- | ObjectVar[Dict[KEY_TYPE, float]]
- | ObjectVar[Dict[KEY_TYPE, int | float]]
- ),
- name: str,
- ) -> NumberVar: ...
-
- @overload
- def __getattr__(
- self: ObjectVar[Dict[KEY_TYPE, str]],
- name: str,
- ) -> StringVar: ...
-
- @overload
- def __getattr__(
- self: ObjectVar[Dict[KEY_TYPE, list[ARRAY_INNER_TYPE]]],
- name: str,
- ) -> ArrayVar[list[ARRAY_INNER_TYPE]]: ...
-
- @overload
- def __getattr__(
- self: ObjectVar[Dict[KEY_TYPE, set[ARRAY_INNER_TYPE]]],
- name: str,
- ) -> ArrayVar[set[ARRAY_INNER_TYPE]]: ...
-
- @overload
- def __getattr__(
- self: ObjectVar[Dict[KEY_TYPE, tuple[ARRAY_INNER_TYPE, ...]]],
- name: str,
- ) -> ArrayVar[tuple[ARRAY_INNER_TYPE, ...]]: ...
-
- @overload
- def __getattr__(
- self: ObjectVar[Dict[KEY_TYPE, dict[OTHER_KEY_TYPE, VALUE_TYPE]]],
- name: str,
- ) -> ObjectVar[dict[OTHER_KEY_TYPE, VALUE_TYPE]]: ...
-
- def __getattr__(self, name) -> ImmutableVar:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Raises:
- VarAttributeError: The State var has no such attribute or may have been annotated wrongly.
-
- Returns:
- The attribute of the var.
- """
- fixed_type = (
- self._var_type if isclass(self._var_type) else get_origin(self._var_type)
- )
- if not issubclass(fixed_type, dict):
- attribute_type = get_attribute_access_type(self._var_type, name)
- if attribute_type is None:
- raise VarAttributeError(
- f"The State var `{self._var_name}` has no attribute '{name}' or may have been annotated "
- f"wrongly."
- )
- return ObjectItemOperation(self, name, attribute_type).guess_type()
- else:
- return ObjectItemOperation(self, name).guess_type()
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class LiteralObjectVar(LiteralVar, ObjectVar[OBJECT_TYPE]):
- """Base class for immutable literal object vars."""
-
- _var_value: Dict[Union[Var, Any], Union[Var, Any]] = dataclasses.field(
- default_factory=dict
- )
-
- def __init__(
- self: LiteralObjectVar[OBJECT_TYPE],
- _var_value: OBJECT_TYPE,
- _var_type: Type[OBJECT_TYPE] | None = None,
- _var_data: VarData | None = None,
- ):
- """Initialize the object var.
-
- Args:
- _var_value: The value of the var.
- _var_type: The type of the var.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(LiteralObjectVar, self).__init__(
- _var_name="",
- _var_type=(figure_out_type(_var_value) if _var_type is None else _var_type),
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(
- self,
- "_var_value",
- _var_value,
- )
- object.__delattr__(self, "_var_name")
-
- def _key_type(self) -> Type:
- """Get the type of the keys of the object.
-
- Returns:
- The type of the keys of the object.
- """
- args_list = typing.get_args(self._var_type)
- return args_list[0] if args_list else Any
-
- def _value_type(self) -> Type:
- """Get the type of the values of the object.
-
- Returns:
- The type of the values of the object.
- """
- args_list = typing.get_args(self._var_type)
- return args_list[1] if args_list else Any
-
- def __getattr__(self, name):
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute of the var.
- """
- if name == "_var_name":
- return self._cached_var_name
- return super(type(self), self).__getattr__(name)
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return (
- "({ "
- + ", ".join(
- [
- f"[{str(LiteralVar.create(key))}] : {str(LiteralVar.create(value))}"
- for key, value in self._var_value.items()
- ]
- )
- + " })"
- )
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- *[
- value._get_all_var_data()
- for key, value in self._var_value
- if isinstance(value, Var)
- ],
- *[
- key._get_all_var_data()
- for key, value in self._var_value
- if isinstance(key, Var)
- ],
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- """Wrapper method for cached property.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return self._cached_get_all_var_data
-
- def json(self) -> str:
- """Get the JSON representation of the object.
-
- Returns:
- The JSON representation of the object.
- """
- return (
- "{"
- + ", ".join(
- [
- f"{LiteralVar.create(key).json()}:{LiteralVar.create(value).json()}"
- for key, value in self._var_value.items()
- ]
- )
- + "}"
- )
-
- def __hash__(self) -> int:
- """Get the hash of the var.
-
- Returns:
- The hash of the var.
- """
- return hash((self.__class__.__name__, self._var_name))
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ObjectToArrayOperation(ArrayVar):
- """Base class for object to array operations."""
-
- value: ObjectVar = dataclasses.field(default_factory=lambda: LiteralObjectVar({}))
-
- def __init__(
- self,
- _var_value: ObjectVar,
- _var_type: Type = list,
- _var_data: VarData | None = None,
- ):
- """Initialize the object to array operation.
-
- Args:
- _var_value: The value of the operation.
- _var_data: Additional hooks and imports associated with the operation.
- """
- super(ObjectToArrayOperation, self).__init__(
- _var_name="",
- _var_type=_var_type,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "value", _var_value)
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the operation.
-
- Raises:
- NotImplementedError: Must implement _cached_var_name.
- """
- raise NotImplementedError(
- "ObjectToArrayOperation must implement _cached_var_name"
- )
-
- def __getattr__(self, name):
- """Get an attribute of the operation.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute of the operation.
- """
- if name == "_var_name":
- return self._cached_var_name
- return super(type(self), self).__getattr__(name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the operation.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.value._get_all_var_data(),
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- """Wrapper method for cached property.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return self._cached_get_all_var_data
-
-
-class ObjectKeysOperation(ObjectToArrayOperation):
- """Operation to get the keys of an object."""
-
- def __init__(
- self,
- value: ObjectVar,
- _var_data: VarData | None = None,
- ):
- """Initialize the object keys operation.
-
- Args:
- value: The value of the operation.
- _var_data: Additional hooks and imports associated with the operation.
- """
- super(ObjectKeysOperation, self).__init__(
- value, List[value._key_type()], _var_data
- )
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the operation.
-
- Returns:
- The name of the operation.
- """
- return f"Object.keys({self.value._var_name})"
-
-
-class ObjectValuesOperation(ObjectToArrayOperation):
- """Operation to get the values of an object."""
-
- def __init__(
- self,
- value: ObjectVar,
- _var_data: VarData | None = None,
- ):
- """Initialize the object values operation.
-
- Args:
- value: The value of the operation.
- _var_data: Additional hooks and imports associated with the operation.
- """
- super(ObjectValuesOperation, self).__init__(
- value, List[value._value_type()], _var_data
- )
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the operation.
-
- Returns:
- The name of the operation.
- """
- return f"Object.values({self.value._var_name})"
-
-
-class ObjectEntriesOperation(ObjectToArrayOperation):
- """Operation to get the entries of an object."""
-
- def __init__(
- self,
- value: ObjectVar,
- _var_data: VarData | None = None,
- ):
- """Initialize the object entries operation.
-
- Args:
- value: The value of the operation.
- _var_data: Additional hooks and imports associated with the operation.
- """
- super(ObjectEntriesOperation, self).__init__(
- value, List[Tuple[value._key_type(), value._value_type()]], _var_data
- )
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the operation.
-
- Returns:
- The name of the operation.
- """
- return f"Object.entries({self.value._var_name})"
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ObjectMergeOperation(ObjectVar):
- """Operation to merge two objects."""
-
- left: ObjectVar = dataclasses.field(default_factory=lambda: LiteralObjectVar({}))
- right: ObjectVar = dataclasses.field(default_factory=lambda: LiteralObjectVar({}))
-
- def __init__(
- self,
- left: ObjectVar,
- right: ObjectVar,
- _var_data: VarData | None = None,
- ):
- """Initialize the object merge operation.
-
- Args:
- left: The left object to merge.
- right: The right object to merge.
- _var_data: Additional hooks and imports associated with the operation.
- """
- super(ObjectMergeOperation, self).__init__(
- _var_name="",
- _var_type=left._var_type,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "left", left)
- object.__setattr__(self, "right", right)
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the operation.
-
- Returns:
- The name of the operation.
- """
- return f"Object.assign({self.left._var_name}, {self.right._var_name})"
-
- def __getattr__(self, name):
- """Get an attribute of the operation.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute of the operation.
- """
- if name == "_var_name":
- return self._cached_var_name
- return super(type(self), self).__getattr__(name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the operation.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.left._get_all_var_data(),
- self.right._get_all_var_data(),
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- """Wrapper method for cached property.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return self._cached_get_all_var_data
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ObjectItemOperation(ImmutableVar):
- """Operation to get an item from an object."""
-
- value: ObjectVar = dataclasses.field(default_factory=lambda: LiteralObjectVar({}))
- key: Var | Any = dataclasses.field(default_factory=lambda: LiteralVar.create(None))
-
- def __init__(
- self,
- value: ObjectVar,
- key: Var | Any,
- _var_type: GenericType | None = None,
- _var_data: VarData | None = None,
- ):
- """Initialize the object item operation.
-
- Args:
- value: The value of the operation.
- key: The key to get from the object.
- _var_data: Additional hooks and imports associated with the operation.
- """
- super(ObjectItemOperation, self).__init__(
- _var_name="",
- _var_type=value._value_type() if _var_type is None else _var_type,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "value", value)
- object.__setattr__(
- self, "key", key if isinstance(key, Var) else LiteralVar.create(key)
- )
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the operation.
-
- Returns:
- The name of the operation.
- """
- return f"{str(self.value)}[{str(self.key)}]"
-
- def __getattr__(self, name):
- """Get an attribute of the operation.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute of the operation.
- """
- if name == "_var_name":
- return self._cached_var_name
- return super(type(self), self).__getattr__(name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the operation.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.value._get_all_var_data(),
- self.key._get_all_var_data(),
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- """Wrapper method for cached property.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return self._cached_get_all_var_data
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ToObjectOperation(ObjectVar):
- """Operation to convert a var to an object."""
-
- _original_var: Var = dataclasses.field(default_factory=lambda: LiteralObjectVar({}))
-
- def __init__(
- self,
- _original_var: Var,
- _var_type: Type = dict,
- _var_data: VarData | None = None,
- ):
- """Initialize the to object operation.
-
- Args:
- _original_var: The original var to convert.
- _var_type: The type of the var.
- _var_data: Additional hooks and imports associated with the operation.
- """
- super(ToObjectOperation, self).__init__(
- _var_name="",
- _var_type=_var_type,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "_original_var", _original_var)
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the operation.
-
- Returns:
- The name of the operation.
- """
- return str(self._original_var)
-
- def __getattr__(self, name):
- """Get an attribute of the operation.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute of the operation.
- """
- if name == "_var_name":
- return self._cached_var_name
- return super(type(self), self).__getattr__(name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the operation.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self._original_var._get_all_var_data(),
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- """Wrapper method for cached property.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return self._cached_get_all_var_data
diff --git a/reflex/experimental/vars/sequence.py b/reflex/experimental/vars/sequence.py
deleted file mode 100644
index f622159a6..000000000
--- a/reflex/experimental/vars/sequence.py
+++ /dev/null
@@ -1,1764 +0,0 @@
-"""Collection of string classes and utilities."""
-
-from __future__ import annotations
-
-import dataclasses
-import functools
-import inspect
-import json
-import re
-import sys
-import typing
-from functools import cached_property
-from typing import (
- TYPE_CHECKING,
- Any,
- Dict,
- List,
- Literal,
- Set,
- Tuple,
- TypeVar,
- Union,
- overload,
-)
-
-from typing_extensions import get_origin
-
-from reflex import constants
-from reflex.constants.base import REFLEX_VAR_OPENING_TAG
-from reflex.experimental.vars.base import (
- ImmutableVar,
- LiteralVar,
- figure_out_type,
- unionize,
-)
-from reflex.experimental.vars.number import (
- BooleanVar,
- LiteralNumberVar,
- NotEqualOperation,
- NumberVar,
-)
-from reflex.utils.types import GenericType
-from reflex.vars import ImmutableVarData, Var, VarData, _global_vars
-
-if TYPE_CHECKING:
- from .object import ObjectVar
-
-
-class StringVar(ImmutableVar[str]):
- """Base class for immutable string vars."""
-
- def __add__(self, other: StringVar | str) -> ConcatVarOperation:
- """Concatenate two strings.
-
- Args:
- other: The other string.
-
- Returns:
- The string concatenation operation.
- """
- return ConcatVarOperation(self, other)
-
- def __radd__(self, other: StringVar | str) -> ConcatVarOperation:
- """Concatenate two strings.
-
- Args:
- other: The other string.
-
- Returns:
- The string concatenation operation.
- """
- return ConcatVarOperation(other, self)
-
- def __mul__(self, other: int) -> ConcatVarOperation:
- """Concatenate two strings.
-
- Args:
- other: The other string.
-
- Returns:
- The string concatenation operation.
- """
- return ConcatVarOperation(*[self for _ in range(other)])
-
- def __rmul__(self, other: int) -> ConcatVarOperation:
- """Concatenate two strings.
-
- Args:
- other: The other string.
-
- Returns:
- The string concatenation operation.
- """
- return ConcatVarOperation(*[self for _ in range(other)])
-
- @overload
- def __getitem__(self, i: slice) -> ArrayJoinOperation: ...
-
- @overload
- def __getitem__(self, i: int | NumberVar) -> StringItemOperation: ...
-
- def __getitem__(
- self, i: slice | int | NumberVar
- ) -> ArrayJoinOperation | StringItemOperation:
- """Get a slice of the string.
-
- Args:
- i: The slice.
-
- Returns:
- The string slice operation.
- """
- if isinstance(i, slice):
- return self.split()[i].join()
- return StringItemOperation(self, i)
-
- def length(self) -> NumberVar:
- """Get the length of the string.
-
- Returns:
- The string length operation.
- """
- return self.split().length()
-
- def lower(self) -> StringLowerOperation:
- """Convert the string to lowercase.
-
- Returns:
- The string lower operation.
- """
- return StringLowerOperation(self)
-
- def upper(self) -> StringUpperOperation:
- """Convert the string to uppercase.
-
- Returns:
- The string upper operation.
- """
- return StringUpperOperation(self)
-
- def strip(self) -> StringStripOperation:
- """Strip the string.
-
- Returns:
- The string strip operation.
- """
- return StringStripOperation(self)
-
- def bool(self) -> NotEqualOperation:
- """Boolean conversion.
-
- Returns:
- The boolean value of the string.
- """
- return NotEqualOperation(self.length(), 0)
-
- def reversed(self) -> ArrayJoinOperation:
- """Reverse the string.
-
- Returns:
- The string reverse operation.
- """
- return self.split().reverse().join()
-
- def contains(self, other: StringVar | str) -> StringContainsOperation:
- """Check if the string contains another string.
-
- Args:
- other: The other string.
-
- Returns:
- The string contains operation.
- """
- return StringContainsOperation(self, other)
-
- def split(self, separator: StringVar | str = "") -> StringSplitOperation:
- """Split the string.
-
- Args:
- separator: The separator.
-
- Returns:
- The string split operation.
- """
- return StringSplitOperation(self, separator)
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class StringToStringOperation(StringVar):
- """Base class for immutable string vars that are the result of a string to string operation."""
-
- a: StringVar = dataclasses.field(
- default_factory=lambda: LiteralStringVar.create("")
- )
-
- def __init__(self, a: StringVar | str, _var_data: VarData | None = None):
- """Initialize the string to string operation var.
-
- Args:
- a: The string.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(StringToStringOperation, self).__init__(
- _var_name="",
- _var_type=str,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(
- self, "a", a if isinstance(a, Var) else LiteralStringVar.create(a)
- )
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Raises:
- NotImplementedError: Must be implemented by subclasses.
- """
- raise NotImplementedError(
- "StringToStringOperation must implement _cached_var_name"
- )
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(StringToStringOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.a._get_all_var_data() if isinstance(self.a, Var) else None,
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-class StringLowerOperation(StringToStringOperation):
- """Base class for immutable string vars that are the result of a string lower operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"{str(self.a)}.toLowerCase()"
-
-
-class StringUpperOperation(StringToStringOperation):
- """Base class for immutable string vars that are the result of a string upper operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"{str(self.a)}.toUpperCase()"
-
-
-class StringStripOperation(StringToStringOperation):
- """Base class for immutable string vars that are the result of a string strip operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"{str(self.a)}.trim()"
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class StringContainsOperation(BooleanVar):
- """Base class for immutable boolean vars that are the result of a string contains operation."""
-
- a: StringVar = dataclasses.field(
- default_factory=lambda: LiteralStringVar.create("")
- )
- b: StringVar = dataclasses.field(
- default_factory=lambda: LiteralStringVar.create("")
- )
-
- def __init__(
- self, a: StringVar | str, b: StringVar | str, _var_data: VarData | None = None
- ):
- """Initialize the string contains operation var.
-
- Args:
- a: The first string.
- b: The second string.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(StringContainsOperation, self).__init__(
- _var_name="",
- _var_type=bool,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(
- self, "a", a if isinstance(a, Var) else LiteralStringVar.create(a)
- )
- object.__setattr__(
- self, "b", b if isinstance(b, Var) else LiteralStringVar.create(b)
- )
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"{str(self.a)}.includes({str(self.b)})"
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(StringContainsOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.a._get_all_var_data(), self.b._get_all_var_data(), self._var_data
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class StringItemOperation(StringVar):
- """Base class for immutable string vars that are the result of a string item operation."""
-
- a: StringVar = dataclasses.field(
- default_factory=lambda: LiteralStringVar.create("")
- )
- i: NumberVar = dataclasses.field(default_factory=lambda: LiteralNumberVar(0))
-
- def __init__(
- self, a: StringVar | str, i: int | NumberVar, _var_data: VarData | None = None
- ):
- """Initialize the string item operation var.
-
- Args:
- a: The string.
- i: The index.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(StringItemOperation, self).__init__(
- _var_name="",
- _var_type=str,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(
- self, "a", a if isinstance(a, Var) else LiteralStringVar.create(a)
- )
- object.__setattr__(self, "i", i if isinstance(i, Var) else LiteralNumberVar(i))
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"{str(self.a)}.at({str(self.i)})"
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(StringItemOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.a._get_all_var_data(), self.i._get_all_var_data(), self._var_data
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-class ArrayJoinOperation(StringVar):
- """Base class for immutable string vars that are the result of an array join operation."""
-
- a: ArrayVar = dataclasses.field(default_factory=lambda: LiteralArrayVar([]))
- b: StringVar = dataclasses.field(
- default_factory=lambda: LiteralStringVar.create("")
- )
-
- def __init__(
- self, a: ArrayVar, b: StringVar | str, _var_data: VarData | None = None
- ):
- """Initialize the array join operation var.
-
- Args:
- a: The array.
- b: The separator.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(ArrayJoinOperation, self).__init__(
- _var_name="",
- _var_type=str,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "a", a)
- object.__setattr__(
- self, "b", b if isinstance(b, Var) else LiteralStringVar.create(b)
- )
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"{str(self.a)}.join({str(self.b)})"
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(ArrayJoinOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.a._get_all_var_data(), self.b._get_all_var_data(), self._var_data
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-# Compile regex for finding reflex var tags.
-_decode_var_pattern_re = (
- rf"{constants.REFLEX_VAR_OPENING_TAG}(.*?){constants.REFLEX_VAR_CLOSING_TAG}"
-)
-_decode_var_pattern = re.compile(_decode_var_pattern_re, flags=re.DOTALL)
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class LiteralStringVar(LiteralVar, StringVar):
- """Base class for immutable literal string vars."""
-
- _var_value: str = dataclasses.field(default="")
-
- def __init__(
- self,
- _var_value: str,
- _var_data: VarData | None = None,
- ):
- """Initialize the string var.
-
- Args:
- _var_value: The value of the var.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(LiteralStringVar, self).__init__(
- _var_name=f'"{_var_value}"',
- _var_type=str,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "_var_value", _var_value)
-
- @classmethod
- def create(
- cls,
- value: str,
- _var_data: VarData | None = None,
- ) -> LiteralStringVar | ConcatVarOperation:
- """Create a var from a string value.
-
- Args:
- value: The value to create the var from.
- _var_data: Additional hooks and imports associated with the Var.
-
- Returns:
- The var.
- """
- if REFLEX_VAR_OPENING_TAG in value:
- strings_and_vals: list[Var | str] = []
- offset = 0
-
- # Initialize some methods for reading json.
- var_data_config = VarData().__config__
-
- def json_loads(s):
- try:
- return var_data_config.json_loads(s)
- except json.decoder.JSONDecodeError:
- return var_data_config.json_loads(
- var_data_config.json_loads(f'"{s}"')
- )
-
- # Find all tags
- while m := _decode_var_pattern.search(value):
- start, end = m.span()
- if start > 0:
- strings_and_vals.append(value[:start])
-
- serialized_data = m.group(1)
-
- if serialized_data.isnumeric() or (
- serialized_data[0] == "-" and serialized_data[1:].isnumeric()
- ):
- # This is a global immutable var.
- var = _global_vars[int(serialized_data)]
- strings_and_vals.append(var)
- value = value[(end + len(var._var_name)) :]
- else:
- data = json_loads(serialized_data)
- string_length = data.pop("string_length", None)
- var_data = VarData.parse_obj(data)
-
- # Use string length to compute positions of interpolations.
- if string_length is not None:
- realstart = start + offset
- var_data.interpolations = [
- (realstart, realstart + string_length)
- ]
- strings_and_vals.append(
- ImmutableVar.create_safe(
- value[end : (end + string_length)], _var_data=var_data
- )
- )
- value = value[(end + string_length) :]
-
- offset += end - start
-
- if value:
- strings_and_vals.append(value)
-
- return ConcatVarOperation(*strings_and_vals, _var_data=_var_data)
-
- return LiteralStringVar(
- value,
- _var_data=_var_data,
- )
-
- def __hash__(self) -> int:
- """Get the hash of the var.
-
- Returns:
- The hash of the var.
- """
- return hash((self.__class__.__name__, self._var_value))
-
- def json(self) -> str:
- """Get the JSON representation of the var.
-
- Returns:
- The JSON representation of the var.
- """
- return json.dumps(self._var_value)
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ConcatVarOperation(StringVar):
- """Representing a concatenation of literal string vars."""
-
- _var_value: Tuple[Union[Var, str], ...] = dataclasses.field(default_factory=tuple)
-
- def __init__(self, *value: Var | str, _var_data: VarData | None = None):
- """Initialize the operation of concatenating literal string vars.
-
- Args:
- value: The values to concatenate.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(ConcatVarOperation, self).__init__(
- _var_name="", _var_data=ImmutableVarData.merge(_var_data), _var_type=str
- )
- object.__setattr__(self, "_var_value", value)
- object.__delattr__(self, "_var_name")
-
- def __getattr__(self, name):
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute of the var.
- """
- if name == "_var_name":
- return self._cached_var_name
- return super(type(self), self).__getattr__(name)
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return (
- "("
- + "+".join(
- [
- str(element) if isinstance(element, Var) else f'"{element}"'
- for element in self._var_value
- ]
- )
- + ")"
- )
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- *[
- var._get_all_var_data()
- for var in self._var_value
- if isinstance(var, Var)
- ],
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- """Wrapper method for cached property.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return self._cached_get_all_var_data
-
- def __post_init__(self):
- """Post-initialize the var."""
- pass
-
-
-ARRAY_VAR_TYPE = TypeVar("ARRAY_VAR_TYPE", bound=Union[List, Tuple, Set])
-
-OTHER_TUPLE = TypeVar("OTHER_TUPLE")
-
-INNER_ARRAY_VAR = TypeVar("INNER_ARRAY_VAR")
-
-KEY_TYPE = TypeVar("KEY_TYPE")
-VALUE_TYPE = TypeVar("VALUE_TYPE")
-
-
-class ArrayVar(ImmutableVar[ARRAY_VAR_TYPE]):
- """Base class for immutable array vars."""
-
- from reflex.experimental.vars.sequence import StringVar
-
- def join(self, sep: StringVar | str = "") -> ArrayJoinOperation:
- """Join the elements of the array.
-
- Args:
- sep: The separator between elements.
-
- Returns:
- The joined elements.
- """
- from reflex.experimental.vars.sequence import ArrayJoinOperation
-
- return ArrayJoinOperation(self, sep)
-
- def reverse(self) -> ArrayVar[ARRAY_VAR_TYPE]:
- """Reverse the array.
-
- Returns:
- The reversed array.
- """
- return ArrayReverseOperation(self)
-
- @overload
- def __getitem__(self, i: slice) -> ArrayVar[ARRAY_VAR_TYPE]: ...
-
- @overload
- def __getitem__(
- self: (
- ArrayVar[Tuple[int, OTHER_TUPLE]]
- | ArrayVar[Tuple[float, OTHER_TUPLE]]
- | ArrayVar[Tuple[int | float, OTHER_TUPLE]]
- ),
- i: Literal[0, -2],
- ) -> NumberVar: ...
-
- @overload
- def __getitem__(
- self: (
- ArrayVar[Tuple[OTHER_TUPLE, int]]
- | ArrayVar[Tuple[OTHER_TUPLE, float]]
- | ArrayVar[Tuple[OTHER_TUPLE, int | float]]
- ),
- i: Literal[1, -1],
- ) -> NumberVar: ...
-
- @overload
- def __getitem__(
- self: ArrayVar[Tuple[str, OTHER_TUPLE]], i: Literal[0, -2]
- ) -> StringVar: ...
-
- @overload
- def __getitem__(
- self: ArrayVar[Tuple[OTHER_TUPLE, str]], i: Literal[1, -1]
- ) -> StringVar: ...
-
- @overload
- def __getitem__(
- self: ArrayVar[Tuple[bool, OTHER_TUPLE]], i: Literal[0, -2]
- ) -> BooleanVar: ...
-
- @overload
- def __getitem__(
- self: ArrayVar[Tuple[OTHER_TUPLE, bool]], i: Literal[1, -1]
- ) -> BooleanVar: ...
-
- @overload
- def __getitem__(
- self: (
- ARRAY_VAR_OF_LIST_ELEMENT[int]
- | ARRAY_VAR_OF_LIST_ELEMENT[float]
- | ARRAY_VAR_OF_LIST_ELEMENT[int | float]
- ),
- i: int | NumberVar,
- ) -> NumberVar: ...
-
- @overload
- def __getitem__(
- self: ARRAY_VAR_OF_LIST_ELEMENT[str], i: int | NumberVar
- ) -> StringVar: ...
-
- @overload
- def __getitem__(
- self: ARRAY_VAR_OF_LIST_ELEMENT[bool], i: int | NumberVar
- ) -> BooleanVar: ...
-
- @overload
- def __getitem__(
- self: ARRAY_VAR_OF_LIST_ELEMENT[List[INNER_ARRAY_VAR]],
- i: int | NumberVar,
- ) -> ArrayVar[List[INNER_ARRAY_VAR]]: ...
-
- @overload
- def __getitem__(
- self: ARRAY_VAR_OF_LIST_ELEMENT[Set[INNER_ARRAY_VAR]],
- i: int | NumberVar,
- ) -> ArrayVar[Set[INNER_ARRAY_VAR]]: ...
-
- @overload
- def __getitem__(
- self: ARRAY_VAR_OF_LIST_ELEMENT[Tuple[INNER_ARRAY_VAR, ...]],
- i: int | NumberVar,
- ) -> ArrayVar[Tuple[INNER_ARRAY_VAR, ...]]: ...
-
- @overload
- def __getitem__(
- self: ARRAY_VAR_OF_LIST_ELEMENT[Dict[KEY_TYPE, VALUE_TYPE]],
- i: int | NumberVar,
- ) -> ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]]: ...
-
- @overload
- def __getitem__(self, i: int | NumberVar) -> ImmutableVar: ...
-
- def __getitem__(
- self, i: slice | int | NumberVar
- ) -> ArrayVar[ARRAY_VAR_TYPE] | ImmutableVar:
- """Get a slice of the array.
-
- Args:
- i: The slice.
-
- Returns:
- The array slice operation.
- """
- if isinstance(i, slice):
- return ArraySliceOperation(self, i)
- return ArrayItemOperation(self, i).guess_type()
-
- def length(self) -> NumberVar:
- """Get the length of the array.
-
- Returns:
- The length of the array.
- """
- return ArrayLengthOperation(self)
-
- @overload
- @classmethod
- def range(cls, stop: int | NumberVar, /) -> ArrayVar[List[int]]: ...
-
- @overload
- @classmethod
- def range(
- cls,
- start: int | NumberVar,
- end: int | NumberVar,
- step: int | NumberVar = 1,
- /,
- ) -> ArrayVar[List[int]]: ...
-
- @classmethod
- def range(
- cls,
- first_endpoint: int | NumberVar,
- second_endpoint: int | NumberVar | None = None,
- step: int | NumberVar | None = None,
- ) -> ArrayVar[List[int]]:
- """Create a range of numbers.
-
- Args:
- first_endpoint: The end of the range if second_endpoint is not provided, otherwise the start of the range.
- second_endpoint: The end of the range.
- step: The step of the range.
-
- Returns:
- The range of numbers.
- """
- if second_endpoint is None:
- start = 0
- end = first_endpoint
- else:
- start = first_endpoint
- end = second_endpoint
-
- return RangeOperation(start, end, step or 1)
-
- def contains(self, other: Any) -> BooleanVar:
- """Check if the array contains an element.
-
- Args:
- other: The element to check for.
-
- Returns:
- The array contains operation.
- """
- return ArrayContainsOperation(self, other)
-
-
-LIST_ELEMENT = TypeVar("LIST_ELEMENT")
-
-ARRAY_VAR_OF_LIST_ELEMENT = Union[
- ArrayVar[List[LIST_ELEMENT]],
- ArrayVar[Set[LIST_ELEMENT]],
- ArrayVar[Tuple[LIST_ELEMENT, ...]],
-]
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class LiteralArrayVar(LiteralVar, ArrayVar[ARRAY_VAR_TYPE]):
- """Base class for immutable literal array vars."""
-
- _var_value: Union[
- List[Union[Var, Any]], Set[Union[Var, Any]], Tuple[Union[Var, Any], ...]
- ] = dataclasses.field(default_factory=list)
-
- def __init__(
- self: LiteralArrayVar[ARRAY_VAR_TYPE],
- _var_value: ARRAY_VAR_TYPE,
- _var_type: type[ARRAY_VAR_TYPE] | None = None,
- _var_data: VarData | None = None,
- ):
- """Initialize the array var.
-
- Args:
- _var_value: The value of the var.
- _var_type: The type of the var.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(LiteralArrayVar, self).__init__(
- _var_name="",
- _var_data=ImmutableVarData.merge(_var_data),
- _var_type=(figure_out_type(_var_value) if _var_type is None else _var_type),
- )
- object.__setattr__(self, "_var_value", _var_value)
- object.__delattr__(self, "_var_name")
-
- def __getattr__(self, name):
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute of the var.
- """
- if name == "_var_name":
- return self._cached_var_name
- return super(type(self), self).__getattr__(name)
-
- @functools.cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return (
- "["
- + ", ".join(
- [str(LiteralVar.create(element)) for element in self._var_value]
- )
- + "]"
- )
-
- @functools.cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- *[
- var._get_all_var_data()
- for var in self._var_value
- if isinstance(var, Var)
- ],
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- """Wrapper method for cached property.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return self._cached_get_all_var_data
-
- def __hash__(self) -> int:
- """Get the hash of the var.
-
- Returns:
- The hash of the var.
- """
- return hash((self.__class__.__name__, self._var_name))
-
- def json(self) -> str:
- """Get the JSON representation of the var.
-
- Returns:
- The JSON representation of the var.
- """
- return (
- "["
- + ", ".join(
- [LiteralVar.create(element).json() for element in self._var_value]
- )
- + "]"
- )
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class StringSplitOperation(ArrayVar):
- """Base class for immutable array vars that are the result of a string split operation."""
-
- a: StringVar = dataclasses.field(
- default_factory=lambda: LiteralStringVar.create("")
- )
- b: StringVar = dataclasses.field(
- default_factory=lambda: LiteralStringVar.create("")
- )
-
- def __init__(
- self, a: StringVar | str, b: StringVar | str, _var_data: VarData | None = None
- ):
- """Initialize the string split operation var.
-
- Args:
- a: The string.
- b: The separator.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(StringSplitOperation, self).__init__(
- _var_name="",
- _var_type=List[str],
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(
- self, "a", a if isinstance(a, Var) else LiteralStringVar.create(a)
- )
- object.__setattr__(
- self, "b", b if isinstance(b, Var) else LiteralStringVar.create(b)
- )
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"{str(self.a)}.split({str(self.b)})"
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(StringSplitOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.a._get_all_var_data(), self.b._get_all_var_data(), self._var_data
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ArrayToArrayOperation(ArrayVar):
- """Base class for immutable array vars that are the result of an array to array operation."""
-
- a: ArrayVar = dataclasses.field(default_factory=lambda: LiteralArrayVar([]))
-
- def __init__(self, a: ArrayVar, _var_data: VarData | None = None):
- """Initialize the array to array operation var.
-
- Args:
- a: The string.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(ArrayToArrayOperation, self).__init__(
- _var_name="",
- _var_type=a._var_type,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "a", a)
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Raises:
- NotImplementedError: Must be implemented by subclasses.
- """
- raise NotImplementedError(
- "ArrayToArrayOperation must implement _cached_var_name"
- )
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(ArrayToArrayOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.a._get_all_var_data() if isinstance(self.a, Var) else None,
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ArraySliceOperation(ArrayVar):
- """Base class for immutable string vars that are the result of a string slice operation."""
-
- a: ArrayVar = dataclasses.field(default_factory=lambda: LiteralArrayVar([]))
- _slice: slice = dataclasses.field(default_factory=lambda: slice(None, None, None))
-
- def __init__(self, a: ArrayVar, _slice: slice, _var_data: VarData | None = None):
- """Initialize the string slice operation var.
-
- Args:
- a: The string.
- _slice: The slice.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(ArraySliceOperation, self).__init__(
- _var_name="",
- _var_type=a._var_type,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "a", a)
- object.__setattr__(self, "_slice", _slice)
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
-
- Raises:
- ValueError: If the slice step is zero.
- """
- start, end, step = self._slice.start, self._slice.stop, self._slice.step
-
- normalized_start = (
- LiteralVar.create(start)
- if start is not None
- else ImmutableVar.create_safe("undefined")
- )
- normalized_end = (
- LiteralVar.create(end)
- if end is not None
- else ImmutableVar.create_safe("undefined")
- )
- if step is None:
- return (
- f"{str(self.a)}.slice({str(normalized_start)}, {str(normalized_end)})"
- )
- if not isinstance(step, Var):
- if step < 0:
- actual_start = end + 1 if end is not None else 0
- actual_end = start + 1 if start is not None else self.a.length()
- return str(
- ArraySliceOperation(
- ArrayReverseOperation(
- ArraySliceOperation(self.a, slice(actual_start, actual_end))
- ),
- slice(None, None, -step),
- )
- )
- if step == 0:
- raise ValueError("slice step cannot be zero")
- return f"{str(self.a)}.slice({str(normalized_start)}, {str(normalized_end)}).filter((_, i) => i % {str(step)} === 0)"
-
- actual_start_reverse = end + 1 if end is not None else 0
- actual_end_reverse = start + 1 if start is not None else self.a.length()
-
- return f"{str(self.step)} > 0 ? {str(self.a)}.slice({str(normalized_start)}, {str(normalized_end)}).filter((_, i) => i % {str(step)} === 0) : {str(self.a)}.slice({str(actual_start_reverse)}, {str(actual_end_reverse)}).reverse().filter((_, i) => i % {str(-step)} === 0)"
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(ArraySliceOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.a._get_all_var_data(),
- *[
- slice_value._get_all_var_data()
- for slice_value in (
- self._slice.start,
- self._slice.stop,
- self._slice.step,
- )
- if slice_value is not None and isinstance(slice_value, Var)
- ],
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-class ArrayReverseOperation(ArrayToArrayOperation):
- """Base class for immutable string vars that are the result of a string reverse operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"{str(self.a)}.reverse()"
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ArrayToNumberOperation(NumberVar):
- """Base class for immutable number vars that are the result of an array to number operation."""
-
- a: ArrayVar = dataclasses.field(
- default_factory=lambda: LiteralArrayVar([]),
- )
-
- def __init__(self, a: ArrayVar, _var_data: VarData | None = None):
- """Initialize the string to number operation var.
-
- Args:
- a: The array.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(ArrayToNumberOperation, self).__init__(
- _var_name="",
- _var_type=int,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "a", a if isinstance(a, Var) else LiteralArrayVar(a))
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Raises:
- NotImplementedError: Must be implemented by subclasses.
- """
- raise NotImplementedError(
- "StringToNumberOperation must implement _cached_var_name"
- )
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(ArrayToNumberOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(self.a._get_all_var_data(), self._var_data)
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-class ArrayLengthOperation(ArrayToNumberOperation):
- """Base class for immutable number vars that are the result of an array length operation."""
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"{str(self.a)}.length"
-
-
-def is_tuple_type(t: GenericType) -> bool:
- """Check if a type is a tuple type.
-
- Args:
- t: The type to check.
-
- Returns:
- Whether the type is a tuple type.
- """
- if inspect.isclass(t):
- return issubclass(t, tuple)
- return get_origin(t) is tuple
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ArrayItemOperation(ImmutableVar):
- """Base class for immutable array vars that are the result of an array item operation."""
-
- a: ArrayVar = dataclasses.field(default_factory=lambda: LiteralArrayVar([]))
- i: NumberVar = dataclasses.field(default_factory=lambda: LiteralNumberVar(0))
-
- def __init__(
- self,
- a: ArrayVar,
- i: NumberVar | int,
- _var_data: VarData | None = None,
- ):
- """Initialize the array item operation var.
-
- Args:
- a: The array.
- i: The index.
- _var_data: Additional hooks and imports associated with the Var.
- """
- args = typing.get_args(a._var_type)
- if args and isinstance(i, int) and is_tuple_type(a._var_type):
- element_type = args[i % len(args)]
- else:
- element_type = unionize(*args)
- super(ArrayItemOperation, self).__init__(
- _var_name="",
- _var_type=element_type,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "a", a if isinstance(a, Var) else LiteralArrayVar(a))
- object.__setattr__(
- self,
- "i",
- i if isinstance(i, Var) else LiteralNumberVar(i),
- )
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"{str(self.a)}.at({str(self.i)})"
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(ArrayItemOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.a._get_all_var_data(), self.i._get_all_var_data(), self._var_data
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class RangeOperation(ArrayVar):
- """Base class for immutable array vars that are the result of a range operation."""
-
- start: NumberVar = dataclasses.field(default_factory=lambda: LiteralNumberVar(0))
- end: NumberVar = dataclasses.field(default_factory=lambda: LiteralNumberVar(0))
- step: NumberVar = dataclasses.field(default_factory=lambda: LiteralNumberVar(1))
-
- def __init__(
- self,
- start: NumberVar | int,
- end: NumberVar | int,
- step: NumberVar | int,
- _var_data: VarData | None = None,
- ):
- """Initialize the range operation var.
-
- Args:
- start: The start of the range.
- end: The end of the range.
- step: The step of the range.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(RangeOperation, self).__init__(
- _var_name="",
- _var_type=List[int],
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(
- self,
- "start",
- start if isinstance(start, Var) else LiteralNumberVar(start),
- )
- object.__setattr__(
- self,
- "end",
- end if isinstance(end, Var) else LiteralNumberVar(end),
- )
- object.__setattr__(
- self,
- "step",
- step if isinstance(step, Var) else LiteralNumberVar(step),
- )
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- start, end, step = self.start, self.end, self.step
- return f"Array.from({{ length: ({str(end)} - {str(start)}) / {str(step)} }}, (_, i) => {str(start)} + i * {str(step)})"
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(RangeOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.start._get_all_var_data(),
- self.end._get_all_var_data(),
- self.step._get_all_var_data(),
- self._var_data,
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ArrayContainsOperation(BooleanVar):
- """Base class for immutable boolean vars that are the result of an array contains operation."""
-
- a: ArrayVar = dataclasses.field(default_factory=lambda: LiteralArrayVar([]))
- b: Var = dataclasses.field(default_factory=lambda: LiteralVar.create(None))
-
- def __init__(self, a: ArrayVar, b: Any | Var, _var_data: VarData | None = None):
- """Initialize the array contains operation var.
-
- Args:
- a: The array.
- b: The element to check for.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(ArrayContainsOperation, self).__init__(
- _var_name="",
- _var_type=bool,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(self, "a", a)
- object.__setattr__(self, "b", b if isinstance(b, Var) else LiteralVar.create(b))
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return f"{str(self.a)}.includes({str(self.b)})"
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(ArrayContainsOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.a._get_all_var_data(), self.b._get_all_var_data(), self._var_data
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ToStringOperation(StringVar):
- """Base class for immutable string vars that are the result of a to string operation."""
-
- original_var: Var = dataclasses.field(
- default_factory=lambda: LiteralStringVar.create("")
- )
-
- def __init__(self, original_var: Var, _var_data: VarData | None = None):
- """Initialize the to string operation var.
-
- Args:
- original_var: The original var.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(ToStringOperation, self).__init__(
- _var_name="",
- _var_type=str,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(
- self,
- "original_var",
- original_var,
- )
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return str(self.original_var)
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(ToStringOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.original_var._get_all_var_data(), self._var_data
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
-
-
-@dataclasses.dataclass(
- eq=False,
- frozen=True,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class ToArrayOperation(ArrayVar):
- """Base class for immutable array vars that are the result of a to array operation."""
-
- original_var: Var = dataclasses.field(default_factory=lambda: LiteralArrayVar([]))
-
- def __init__(
- self,
- original_var: Var,
- _var_type: type[list] | type[set] | type[tuple] = list,
- _var_data: VarData | None = None,
- ):
- """Initialize the to array operation var.
-
- Args:
- original_var: The original var.
- _var_type: The type of the array.
- _var_data: Additional hooks and imports associated with the Var.
- """
- super(ToArrayOperation, self).__init__(
- _var_name="",
- _var_type=_var_type,
- _var_data=ImmutableVarData.merge(_var_data),
- )
- object.__setattr__(
- self,
- "original_var",
- original_var,
- )
- object.__delattr__(self, "_var_name")
-
- @cached_property
- def _cached_var_name(self) -> str:
- """The name of the var.
-
- Returns:
- The name of the var.
- """
- return str(self.original_var)
-
- def __getattr__(self, name: str) -> Any:
- """Get an attribute of the var.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The attribute value.
- """
- if name == "_var_name":
- return self._cached_var_name
- getattr(super(ToArrayOperation, self), name)
-
- @cached_property
- def _cached_get_all_var_data(self) -> ImmutableVarData | None:
- """Get all VarData associated with the Var.
-
- Returns:
- The VarData of the components and all of its children.
- """
- return ImmutableVarData.merge(
- self.original_var._get_all_var_data(), self._var_data
- )
-
- def _get_all_var_data(self) -> ImmutableVarData | None:
- return self._cached_get_all_var_data
diff --git a/reflex/istate/__init__.py b/reflex/istate/__init__.py
new file mode 100644
index 000000000..d71d038f8
--- /dev/null
+++ b/reflex/istate/__init__.py
@@ -0,0 +1 @@
+"""This module will provide interfaces for the state."""
diff --git a/reflex/istate/data.py b/reflex/istate/data.py
new file mode 100644
index 000000000..987921889
--- /dev/null
+++ b/reflex/istate/data.py
@@ -0,0 +1,126 @@
+"""This module contains the dataclasses representing the router object."""
+
+import dataclasses
+from typing import Optional
+
+from reflex import constants
+from reflex.utils import format
+
+
+@dataclasses.dataclass(frozen=True)
+class HeaderData:
+ """An object containing headers data."""
+
+ host: str = ""
+ origin: str = ""
+ upgrade: str = ""
+ connection: str = ""
+ cookie: str = ""
+ pragma: str = ""
+ cache_control: str = ""
+ user_agent: str = ""
+ sec_websocket_version: str = ""
+ sec_websocket_key: str = ""
+ sec_websocket_extensions: str = ""
+ accept_encoding: str = ""
+ accept_language: str = ""
+
+ def __init__(self, router_data: Optional[dict] = None):
+ """Initialize the HeaderData object based on router_data.
+
+ Args:
+ router_data: the router_data dict.
+ """
+ if router_data:
+ for k, v in router_data.get(constants.RouteVar.HEADERS, {}).items():
+ object.__setattr__(self, format.to_snake_case(k), v)
+ else:
+ for k in dataclasses.fields(self):
+ object.__setattr__(self, k.name, "")
+
+
+@dataclasses.dataclass(frozen=True)
+class PageData:
+ """An object containing page data."""
+
+ host: str = "" # repeated with self.headers.origin (remove or keep the duplicate?)
+ path: str = ""
+ raw_path: str = ""
+ full_path: str = ""
+ full_raw_path: str = ""
+ params: dict = dataclasses.field(default_factory=dict)
+
+ def __init__(self, router_data: Optional[dict] = None):
+ """Initialize the PageData object based on router_data.
+
+ Args:
+ router_data: the router_data dict.
+ """
+ if router_data:
+ object.__setattr__(
+ self,
+ "host",
+ router_data.get(constants.RouteVar.HEADERS, {}).get("origin", ""),
+ )
+ object.__setattr__(
+ self, "path", router_data.get(constants.RouteVar.PATH, "")
+ )
+ object.__setattr__(
+ self, "raw_path", router_data.get(constants.RouteVar.ORIGIN, "")
+ )
+ object.__setattr__(self, "full_path", f"{self.host}{self.path}")
+ object.__setattr__(self, "full_raw_path", f"{self.host}{self.raw_path}")
+ object.__setattr__(
+ self, "params", router_data.get(constants.RouteVar.QUERY, {})
+ )
+ else:
+ object.__setattr__(self, "host", "")
+ object.__setattr__(self, "path", "")
+ object.__setattr__(self, "raw_path", "")
+ object.__setattr__(self, "full_path", "")
+ object.__setattr__(self, "full_raw_path", "")
+ object.__setattr__(self, "params", {})
+
+
+@dataclasses.dataclass(frozen=True, init=False)
+class SessionData:
+ """An object containing session data."""
+
+ client_token: str = ""
+ client_ip: str = ""
+ session_id: str = ""
+
+ def __init__(self, router_data: Optional[dict] = None):
+ """Initialize the SessionData object based on router_data.
+
+ Args:
+ router_data: the router_data dict.
+ """
+ if router_data:
+ client_token = router_data.get(constants.RouteVar.CLIENT_TOKEN, "")
+ client_ip = router_data.get(constants.RouteVar.CLIENT_IP, "")
+ session_id = router_data.get(constants.RouteVar.SESSION_ID, "")
+ else:
+ client_token = client_ip = session_id = ""
+ object.__setattr__(self, "client_token", client_token)
+ object.__setattr__(self, "client_ip", client_ip)
+ object.__setattr__(self, "session_id", session_id)
+
+
+@dataclasses.dataclass(frozen=True, init=False)
+class RouterData:
+ """An object containing RouterData."""
+
+ session: SessionData = dataclasses.field(default_factory=SessionData)
+ headers: HeaderData = dataclasses.field(default_factory=HeaderData)
+ page: PageData = dataclasses.field(default_factory=PageData)
+
+ def __init__(self, router_data: Optional[dict] = None):
+ """Initialize the RouterData object.
+
+ Args:
+ router_data: the router_data dict.
+ """
+ object.__setattr__(self, "session", SessionData(router_data))
+ object.__setattr__(self, "headers", HeaderData(router_data))
+ object.__setattr__(self, "page", PageData(router_data))
diff --git a/reflex/istate/dynamic.py b/reflex/istate/dynamic.py
new file mode 100644
index 000000000..e5da36c26
--- /dev/null
+++ b/reflex/istate/dynamic.py
@@ -0,0 +1,3 @@
+"""A container for dynamically generated states."""
+
+# This page intentionally left blank.
diff --git a/reflex/istate/proxy.py b/reflex/istate/proxy.py
new file mode 100644
index 000000000..8d6051cf2
--- /dev/null
+++ b/reflex/istate/proxy.py
@@ -0,0 +1,33 @@
+"""A module to hold state proxy classes."""
+
+from typing import Any
+
+from reflex.state import StateProxy
+
+
+class ReadOnlyStateProxy(StateProxy):
+ """A read-only proxy for a state."""
+
+ def __setattr__(self, name: str, value: Any) -> None:
+ """Prevent setting attributes on the state for read-only proxy.
+
+ Args:
+ name: The attribute name.
+ value: The attribute value.
+
+ Raises:
+ NotImplementedError: Always raised when trying to set an attribute on proxied state.
+ """
+ if name.startswith("_self_"):
+ # Special case attributes of the proxy itself, not applied to the wrapped object.
+ super().__setattr__(name, value)
+ return
+ raise NotImplementedError("This is a read-only state proxy.")
+
+ def mark_dirty(self):
+ """Mark the state as dirty.
+
+ Raises:
+ NotImplementedError: Always raised when trying to mark the proxied state as dirty.
+ """
+ raise NotImplementedError("This is a read-only state proxy.")
diff --git a/reflex/istate/storage.py b/reflex/istate/storage.py
new file mode 100644
index 000000000..85e21ffa7
--- /dev/null
+++ b/reflex/istate/storage.py
@@ -0,0 +1,144 @@
+"""Client-side storage classes for reflex state variables."""
+
+from __future__ import annotations
+
+from typing import Any
+
+from reflex.utils import format
+
+
+class ClientStorageBase:
+ """Base class for client-side storage."""
+
+ def options(self) -> dict[str, Any]:
+ """Get the options for the storage.
+
+ Returns:
+ All set options for the storage (not None).
+ """
+ return {
+ format.to_camel_case(k): v for k, v in vars(self).items() if v is not None
+ }
+
+
+class Cookie(ClientStorageBase, str):
+ """Represents a state Var that is stored as a cookie in the browser."""
+
+ name: str | None
+ path: str
+ max_age: int | None
+ domain: str | None
+ secure: bool | None
+ same_site: str
+
+ def __new__(
+ cls,
+ object: Any = "",
+ encoding: str | None = None,
+ errors: str | None = None,
+ /,
+ name: str | None = None,
+ path: str = "/",
+ max_age: int | None = None,
+ domain: str | None = None,
+ secure: bool | None = None,
+ same_site: str = "lax",
+ ):
+ """Create a client-side Cookie (str).
+
+ Args:
+ object: The initial object.
+ encoding: The encoding to use.
+ errors: The error handling scheme to use.
+ name: The name of the cookie on the client side.
+ path: Cookie path. Use / as the path if the cookie should be accessible on all pages.
+ max_age: Relative max age of the cookie in seconds from when the client receives it.
+ domain: Domain for the cookie (sub.domain.com or .allsubdomains.com).
+ secure: Is the cookie only accessible through HTTPS?
+ same_site: Whether the cookie is sent with third party requests.
+ One of (true|false|none|lax|strict)
+
+ Returns:
+ The client-side Cookie object.
+
+ Note: expires (absolute Date) is not supported at this time.
+ """
+ if encoding or errors:
+ inst = super().__new__(cls, object, encoding or "utf-8", errors or "strict")
+ else:
+ inst = super().__new__(cls, object)
+ inst.name = name
+ inst.path = path
+ inst.max_age = max_age
+ inst.domain = domain
+ inst.secure = secure
+ inst.same_site = same_site
+ return inst
+
+
+class LocalStorage(ClientStorageBase, str):
+ """Represents a state Var that is stored in localStorage in the browser."""
+
+ name: str | None
+ sync: bool = False
+
+ def __new__(
+ cls,
+ object: Any = "",
+ encoding: str | None = None,
+ errors: str | None = None,
+ /,
+ name: str | None = None,
+ sync: bool = False,
+ ) -> "LocalStorage":
+ """Create a client-side localStorage (str).
+
+ Args:
+ object: The initial object.
+ encoding: The encoding to use.
+ errors: The error handling scheme to use.
+ name: The name of the storage key on the client side.
+ sync: Whether changes should be propagated to other tabs.
+
+ Returns:
+ The client-side localStorage object.
+ """
+ if encoding or errors:
+ inst = super().__new__(cls, object, encoding or "utf-8", errors or "strict")
+ else:
+ inst = super().__new__(cls, object)
+ inst.name = name
+ inst.sync = sync
+ return inst
+
+
+class SessionStorage(ClientStorageBase, str):
+ """Represents a state Var that is stored in sessionStorage in the browser."""
+
+ name: str | None
+
+ def __new__(
+ cls,
+ object: Any = "",
+ encoding: str | None = None,
+ errors: str | None = None,
+ /,
+ name: str | None = None,
+ ) -> "SessionStorage":
+ """Create a client-side sessionStorage (str).
+
+ Args:
+ object: The initial object.
+ encoding: The encoding to use.
+ errors: The error handling scheme to use
+ name: The name of the storage on the client side
+
+ Returns:
+ The client-side sessionStorage object.
+ """
+ if encoding or errors:
+ inst = super().__new__(cls, object, encoding or "utf-8", errors or "strict")
+ else:
+ inst = super().__new__(cls, object)
+ inst.name = name
+ return inst
diff --git a/reflex/istate/wrappers.py b/reflex/istate/wrappers.py
new file mode 100644
index 000000000..d4e74cf8a
--- /dev/null
+++ b/reflex/istate/wrappers.py
@@ -0,0 +1,27 @@
+"""Wrappers for the state manager."""
+
+from typing import Any
+
+from reflex.istate.proxy import ReadOnlyStateProxy
+from reflex.state import _split_substate_key, _substate_key, get_state_manager
+
+
+async def get_state(token, state_cls: Any | None = None) -> ReadOnlyStateProxy:
+ """Get the instance of a state for a token.
+
+ Args:
+ token: The token for the state.
+ state_cls: The class of the state.
+
+ Returns:
+ A read-only proxy of the state instance.
+ """
+ mng = get_state_manager()
+ if state_cls is not None:
+ root_state = await mng.get_state(_substate_key(token, state_cls))
+ else:
+ root_state = await mng.get_state(token)
+ _, state_path = _split_substate_key(token)
+ state_cls = root_state.get_class_substate(tuple(state_path.split(".")))
+ instance = await root_state.get_state(state_cls)
+ return ReadOnlyStateProxy(instance)
diff --git a/reflex/middleware/hydrate_middleware.py b/reflex/middleware/hydrate_middleware.py
index 99abf97aa..2ad329e9d 100644
--- a/reflex/middleware/hydrate_middleware.py
+++ b/reflex/middleware/hydrate_middleware.py
@@ -2,18 +2,19 @@
from __future__ import annotations
+import dataclasses
from typing import TYPE_CHECKING, Optional
from reflex import constants
from reflex.event import Event, get_hydrate_event
from reflex.middleware.middleware import Middleware
from reflex.state import BaseState, StateUpdate
-from reflex.utils import format
if TYPE_CHECKING:
from reflex.app import App
+@dataclasses.dataclass(init=True)
class HydrateMiddleware(Middleware):
"""Middleware to handle initial app hydration."""
@@ -41,7 +42,7 @@ class HydrateMiddleware(Middleware):
setattr(state, constants.CompileVars.IS_HYDRATED, False)
# Get the initial state.
- delta = format.format_state(state.dict())
+ delta = state.dict()
# since a full dict was captured, clean any dirtiness
state._clean()
diff --git a/reflex/middleware/middleware.py b/reflex/middleware/middleware.py
index 76cbcfe9a..ef9de0bde 100644
--- a/reflex/middleware/middleware.py
+++ b/reflex/middleware/middleware.py
@@ -2,10 +2,9 @@
from __future__ import annotations
-from abc import ABC
+from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Optional
-from reflex.base import Base
from reflex.event import Event
from reflex.state import BaseState, StateUpdate
@@ -13,9 +12,10 @@ if TYPE_CHECKING:
from reflex.app import App
-class Middleware(Base, ABC):
+class Middleware(ABC):
"""Middleware to preprocess and postprocess requests."""
+ @abstractmethod
async def preprocess(
self, app: App, state: BaseState, event: Event
) -> Optional[StateUpdate]:
diff --git a/reflex/model.py b/reflex/model.py
index 71e26f76a..de63589fc 100644
--- a/reflex/model.py
+++ b/reflex/model.py
@@ -2,9 +2,9 @@
from __future__ import annotations
-import os
+import re
from collections import defaultdict
-from pathlib import Path
+from contextlib import suppress
from typing import Any, ClassVar, Optional, Type, Union
import alembic.autogenerate
@@ -15,13 +15,56 @@ import alembic.runtime.environment
import alembic.script
import alembic.util
import sqlalchemy
+import sqlalchemy.exc
+import sqlalchemy.ext.asyncio
import sqlalchemy.orm
-from reflex import constants
from reflex.base import Base
-from reflex.config import get_config
+from reflex.config import environment, get_config
from reflex.utils import console
-from reflex.utils.compat import sqlmodel
+from reflex.utils.compat import sqlmodel, sqlmodel_field_has_primary_key
+
+_ENGINE: dict[str, sqlalchemy.engine.Engine] = {}
+_ASYNC_ENGINE: dict[str, sqlalchemy.ext.asyncio.AsyncEngine] = {}
+_AsyncSessionLocal: dict[str | None, sqlalchemy.ext.asyncio.async_sessionmaker] = {}
+
+# Import AsyncSession _after_ reflex.utils.compat
+from sqlmodel.ext.asyncio.session import AsyncSession # noqa: E402
+
+
+def _safe_db_url_for_logging(url: str) -> str:
+ """Remove username and password from the database URL for logging.
+
+ Args:
+ url: The database URL.
+
+ Returns:
+ The database URL with the username and password removed.
+ """
+ return re.sub(r"://[^@]+@", "://:@", url)
+
+
+def get_engine_args(url: str | None = None) -> dict[str, Any]:
+ """Get the database engine arguments.
+
+ Args:
+ url: The database url.
+
+ Returns:
+ The database engine arguments as a dict.
+ """
+ kwargs: dict[str, Any] = {
+ # Print the SQL queries if the log level is INFO or lower.
+ "echo": environment.SQLALCHEMY_ECHO.get(),
+ # Check connections before returning them.
+ "pool_pre_ping": environment.SQLALCHEMY_POOL_PRE_PING.get(),
+ }
+ conf = get_config()
+ url = url or conf.db_url
+ if url is not None and url.startswith("sqlite"):
+ # Needed for the admin dash on sqlite.
+ kwargs["connect_args"] = {"check_same_thread": False}
+ return kwargs
def get_engine(url: str | None = None) -> sqlalchemy.engine.Engine:
@@ -40,15 +83,81 @@ def get_engine(url: str | None = None) -> sqlalchemy.engine.Engine:
url = url or conf.db_url
if url is None:
raise ValueError("No database url configured")
- if not Path(constants.ALEMBIC_CONFIG).exists():
+
+ global _ENGINE
+ if url in _ENGINE:
+ return _ENGINE[url]
+
+ if not environment.ALEMBIC_CONFIG.get().exists():
console.warn(
"Database is not initialized, run [bold]reflex db init[/bold] first."
)
- # Print the SQL queries if the log level is INFO or lower.
- echo_db_query = os.environ.get("SQLALCHEMY_ECHO") == "True"
- # Needed for the admin dash on sqlite.
- connect_args = {"check_same_thread": False} if url.startswith("sqlite") else {}
- return sqlmodel.create_engine(url, echo=echo_db_query, connect_args=connect_args)
+ _ENGINE[url] = sqlmodel.create_engine(
+ url,
+ **get_engine_args(url),
+ )
+ return _ENGINE[url]
+
+
+def get_async_engine(url: str | None) -> sqlalchemy.ext.asyncio.AsyncEngine:
+ """Get the async database engine.
+
+ Args:
+ url: The database url.
+
+ Returns:
+ The async database engine.
+
+ Raises:
+ ValueError: If the async database url is None.
+ """
+ if url is None:
+ conf = get_config()
+ url = conf.async_db_url
+ if url is not None and conf.db_url is not None:
+ async_db_url_tail = url.partition("://")[2]
+ db_url_tail = conf.db_url.partition("://")[2]
+ if async_db_url_tail != db_url_tail:
+ console.warn(
+ f"async_db_url `{_safe_db_url_for_logging(url)}` "
+ "should reference the same database as "
+ f"db_url `{_safe_db_url_for_logging(conf.db_url)}`."
+ )
+ if url is None:
+ raise ValueError("No async database url configured")
+
+ global _ASYNC_ENGINE
+ if url in _ASYNC_ENGINE:
+ return _ASYNC_ENGINE[url]
+
+ if not environment.ALEMBIC_CONFIG.get().exists():
+ console.warn(
+ "Database is not initialized, run [bold]reflex db init[/bold] first."
+ )
+ _ASYNC_ENGINE[url] = sqlalchemy.ext.asyncio.create_async_engine(
+ url,
+ **get_engine_args(url),
+ )
+ return _ASYNC_ENGINE[url]
+
+
+async def get_db_status() -> dict[str, bool]:
+ """Checks the status of the database connection.
+
+ Attempts to connect to the database and execute a simple query to verify connectivity.
+
+ Returns:
+ The status of the database connection.
+ """
+ status = True
+ try:
+ engine = get_engine()
+ with engine.connect() as connection:
+ connection.execute(sqlalchemy.text("SELECT 1"))
+ except sqlalchemy.exc.OperationalError:
+ status = False
+
+ return {"db": status}
SQLModelOrSqlAlchemy = Union[
@@ -144,8 +253,7 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue
non_default_primary_key_fields = [
field_name
for field_name, field in cls.__fields__.items()
- if field_name != "id"
- and getattr(field.field_info, "primary_key", None) is True
+ if field_name != "id" and sqlmodel_field_has_primary_key(field)
]
if non_default_primary_key_fields:
cls.__fields__.pop("id", None)
@@ -181,11 +289,10 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue
relationships = {}
# SQLModel relationships do not appear in __fields__, but should be included if present.
for name in self.__sqlmodel_relationships__:
- try:
+ with suppress(
+ sqlalchemy.orm.exc.DetachedInstanceError # This happens when the relationship was never loaded and the session is closed.
+ ):
relationships[name] = self._dict_recursive(getattr(self, name))
- except sqlalchemy.orm.exc.DetachedInstanceError:
- # This happens when the relationship was never loaded and the session is closed.
- continue
return {
**base_fields,
**relationships,
@@ -213,7 +320,7 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue
Returns:
tuple of (config, script_directory)
"""
- config = alembic.config.Config(constants.ALEMBIC_CONFIG)
+ config = alembic.config.Config(environment.ALEMBIC_CONFIG.get())
return config, alembic.script.ScriptDirectory(
config.get_main_option("script_location", default="version"),
)
@@ -248,8 +355,8 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue
def alembic_init(cls):
"""Initialize alembic for the project."""
alembic.command.init(
- config=alembic.config.Config(constants.ALEMBIC_CONFIG),
- directory=str(Path(constants.ALEMBIC_CONFIG).parent / "alembic"),
+ config=alembic.config.Config(environment.ALEMBIC_CONFIG.get()),
+ directory=str(environment.ALEMBIC_CONFIG.get().parent / "alembic"),
)
@classmethod
@@ -269,7 +376,7 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue
Returns:
True when changes have been detected.
"""
- if not Path(constants.ALEMBIC_CONFIG).exists():
+ if not environment.ALEMBIC_CONFIG.get().exists():
return False
config, script_directory = cls._alembic_config()
@@ -370,7 +477,7 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue
True - indicating the process was successful.
None - indicating the process was skipped.
"""
- if not Path(constants.ALEMBIC_CONFIG).exists():
+ if not environment.ALEMBIC_CONFIG.get().exists():
return
with cls.get_db_engine().connect() as connection:
@@ -407,6 +514,31 @@ def session(url: str | None = None) -> sqlmodel.Session:
return sqlmodel.Session(get_engine(url))
+def asession(url: str | None = None) -> AsyncSession:
+ """Get an async sqlmodel session to interact with the database.
+
+ async with rx.asession() as asession:
+ ...
+
+ Most operations against the `asession` must be awaited.
+
+ Args:
+ url: The database url.
+
+ Returns:
+ An async database session.
+ """
+ global _AsyncSessionLocal
+ if url not in _AsyncSessionLocal:
+ _AsyncSessionLocal[url] = sqlalchemy.ext.asyncio.async_sessionmaker(
+ bind=get_async_engine(url),
+ class_=AsyncSession,
+ autocommit=False,
+ autoflush=False,
+ )
+ return _AsyncSessionLocal[url]()
+
+
def sqla_session(url: str | None = None) -> sqlalchemy.orm.Session:
"""Get a bare sqlalchemy session to interact with the database.
diff --git a/reflex/page.py b/reflex/page.py
index 1e5e8603d..44ca6ab31 100644
--- a/reflex/page.py
+++ b/reflex/page.py
@@ -6,6 +6,7 @@ from collections import defaultdict
from typing import Any, Dict, List
from reflex.config import get_config
+from reflex.event import BASE_STATE, EventType
DECORATED_PAGES: Dict[str, List] = defaultdict(list)
@@ -17,7 +18,7 @@ def page(
description: str | None = None,
meta: list[Any] | None = None,
script_tags: list[Any] | None = None,
- on_load: Any | list[Any] | None = None,
+ on_load: EventType[[], BASE_STATE] | None = None,
):
"""Decorate a function as a page.
@@ -65,13 +66,20 @@ def page(
return decorator
-def get_decorated_pages() -> list[dict]:
+def get_decorated_pages(omit_implicit_routes=True) -> list[dict[str, Any]]:
"""Get the decorated pages.
+ Args:
+ omit_implicit_routes: Whether to omit pages where the route will be implicitly guessed later.
+
Returns:
The decorated pages.
"""
return sorted(
- [page_data for _, page_data in DECORATED_PAGES[get_config().app_name]],
- key=lambda x: x["route"],
+ [
+ page_data
+ for _, page_data in DECORATED_PAGES[get_config().app_name]
+ if not omit_implicit_routes or "route" in page_data
+ ],
+ key=lambda x: x.get("route", ""),
)
diff --git a/reflex/reflex.py b/reflex/reflex.py
index 224bace47..e333bfbd1 100644
--- a/reflex/reflex.py
+++ b/reflex/reflex.py
@@ -3,23 +3,21 @@
from __future__ import annotations
import atexit
-import os
-import webbrowser
from pathlib import Path
from typing import List, Optional
import typer
import typer.core
-from reflex_cli.deployments import deployments_cli
-from reflex_cli.utils import dependency
+from reflex_cli.v2.deployments import check_version, hosting_cli
from reflex import constants
-from reflex.config import get_config
+from reflex.config import environment, get_config
from reflex.custom_components.custom_components import custom_components_cli
-from reflex.utils import console, redir, telemetry
+from reflex.state import reset_disk_state_manager
+from reflex.utils import console, telemetry
# Disable typer+rich integration for help panels
-typer.core.rich = False # type: ignore
+typer.core.rich = None # type: ignore
# Create the app.
try:
@@ -85,40 +83,11 @@ def _init(
prerequisites.initialize_reflex_user_directory()
prerequisites.ensure_reflex_installation_id()
- # When upgrading to 0.4, show migration instructions.
- if prerequisites.should_show_rx_chakra_migration_instructions():
- prerequisites.show_rx_chakra_migration_instructions()
-
# Set up the web project.
prerequisites.initialize_frontend_dependencies()
- # Integrate with reflex.build.
- generation_hash = None
- if ai:
- if template is None:
- # If AI is requested and no template specified, redirect the user to reflex.build.
- generation_hash = redir.reflex_build_redirect()
- elif prerequisites.is_generation_hash(template):
- # Otherwise treat the template as a generation hash.
- generation_hash = template
- else:
- console.error(
- "Cannot use `--template` option with `--ai` option. Please remove `--template` option."
- )
- raise typer.Exit(2)
- template = constants.Templates.DEFAULT
-
# Initialize the app.
- prerequisites.initialize_app(app_name, template)
-
- # If a reflex.build generation hash is available, download the code and apply it to the main module.
- if generation_hash:
- prerequisites.initialize_main_module_index_from_generation(
- app_name, generation_hash=generation_hash
- )
-
- # Migrate Pynecone projects to Reflex.
- prerequisites.migrate_to_reflex()
+ template = prerequisites.initialize_app(app_name, template, ai)
# Initialize the .gitignore.
prerequisites.initialize_gitignore()
@@ -126,8 +95,9 @@ def _init(
# Initialize the requirements.txt.
prerequisites.initialize_requirements_txt()
+ template_msg = f" using the {template} template" if template else ""
# Finish initializing the app.
- console.success(f"Initialized {app_name}")
+ console.success(f"Initialized {app_name}{template_msg}")
@cli.command()
@@ -167,7 +137,7 @@ def _run(
console.set_log_level(loglevel)
# Set env mode in the environment
- os.environ[constants.ENV_MODE_ENV_VAR] = env.value
+ environment.REFLEX_ENV_MODE.set(env)
# Show system info
exec.output_system_info()
@@ -184,6 +154,9 @@ def _run(
if prerequisites.needs_reinit(frontend=frontend):
_init(name=config.app_name, loglevel=loglevel)
+ # Delete the states folder if it exists.
+ reset_disk_state_manager()
+
# Find the next available open port if applicable.
if frontend:
frontend_port = processes.handle_port(
@@ -229,7 +202,8 @@ def _run(
exec.run_frontend_prod,
exec.run_backend_prod,
)
- assert setup_frontend and frontend_cmd and backend_cmd, "Invalid env"
+ if not setup_frontend or not frontend_cmd or not backend_cmd:
+ raise ValueError("Invalid env")
# Post a telemetry event.
telemetry.send(f"run-{env.value}")
@@ -247,13 +221,23 @@ def _run(
# In prod mode, run the backend on a separate thread.
if backend and env == constants.Env.PROD:
- commands.append((backend_cmd, backend_host, backend_port))
+ commands.append(
+ (
+ backend_cmd,
+ backend_host,
+ backend_port,
+ loglevel.subprocess_level(),
+ frontend,
+ )
+ )
# Start the frontend and backend.
with processes.run_concurrently_context(*commands):
# In dev mode, run the backend on the main thread.
if backend and env == constants.Env.DEV:
- backend_cmd(backend_host, int(backend_port))
+ backend_cmd(
+ backend_host, int(backend_port), loglevel.subprocess_level(), frontend
+ )
# The windows uvicorn bug workaround
# https://github.com/reflex-dev/reflex/issues/2335
if constants.IS_WINDOWS and exec.frontend_process:
@@ -267,9 +251,17 @@ def run(
constants.Env.DEV, help="The environment to run the app in."
),
frontend: bool = typer.Option(
- False, "--frontend-only", help="Execute only frontend."
+ False,
+ "--frontend-only",
+ help="Execute only frontend.",
+ envvar=environment.REFLEX_FRONTEND_ONLY.name,
+ ),
+ backend: bool = typer.Option(
+ False,
+ "--backend-only",
+ help="Execute only backend.",
+ envvar=environment.REFLEX_BACKEND_ONLY.name,
),
- backend: bool = typer.Option(False, "--backend-only", help="Execute only backend."),
frontend_port: str = typer.Option(
config.frontend_port, help="Specify a different frontend port."
),
@@ -284,6 +276,12 @@ def run(
),
):
"""Run the app in the current directory."""
+ if frontend and backend:
+ console.error("Cannot use both --frontend-only and --backend-only options.")
+ raise typer.Exit(1)
+ environment.REFLEX_BACKEND_ONLY.set(backend)
+ environment.REFLEX_FRONTEND_ONLY.set(frontend)
+
_run(env, frontend, backend, frontend_port, backend_port, backend_host, loglevel)
@@ -299,7 +297,7 @@ def export(
True, "--frontend-only", help="Export only frontend.", show_default=False
),
zip_dest_dir: str = typer.Option(
- os.getcwd(),
+ str(Path.cwd()),
help="The directory to export the zip files to.",
show_default=False,
),
@@ -325,41 +323,21 @@ def export(
backend=backend,
zip_dest_dir=zip_dest_dir,
upload_db_file=upload_db_file,
- loglevel=loglevel,
+ loglevel=loglevel.subprocess_level(),
)
-def _login() -> str:
- """Helper function to authenticate with Reflex hosting service."""
- from reflex_cli.utils import hosting
-
- access_token, invitation_code = hosting.authenticated_token()
- if access_token:
- console.print("You already logged in.")
- return access_token
-
- # If not already logged in, open a browser window/tab to the login page.
- access_token = hosting.authenticate_on_browser(invitation_code)
-
- if not access_token:
- console.error(f"Unable to authenticate. Please try again or contact support.")
- raise typer.Exit(1)
-
- console.print("Successfully logged in.")
- return access_token
-
-
@cli.command()
-def login(
- loglevel: constants.LogLevel = typer.Option(
- config.loglevel, help="The log level to use."
- ),
-):
- """Authenticate with Reflex hosting service."""
- # Set the log level.
- console.set_log_level(loglevel)
+def login(loglevel: constants.LogLevel = typer.Option(config.loglevel)):
+ """Authenticate with experimental Reflex hosting service."""
+ from reflex_cli.v2 import cli as hosting_cli
- _login()
+ check_version()
+
+ validated_info = hosting_cli.login()
+ if validated_info is not None:
+ _skip_compile() # Allow running outside of an app dir
+ telemetry.send("login", user_uuid=validated_info.get("user_id"))
@cli.command()
@@ -369,13 +347,11 @@ def logout(
),
):
"""Log out of access to Reflex hosting service."""
- from reflex_cli.utils import hosting
+ from reflex_cli.v2.cli import logout
- console.set_log_level(loglevel)
+ check_version()
- hosting.log_out_on_browser()
- console.debug("Deleting access token from config locally")
- hosting.delete_token_from_config(include_invitation_code=True)
+ logout(loglevel) # type: ignore
db_cli = typer.Typer()
@@ -384,7 +360,7 @@ script_cli = typer.Typer()
def _skip_compile():
"""Skip the compile step."""
- os.environ[constants.SKIP_COMPILE_ENV_VAR] = "yes"
+ environment.REFLEX_SKIP_COMPILE.set(True)
@db_cli.command(name="init")
@@ -399,7 +375,7 @@ def db_init():
return
# Check the alembic config.
- if Path(constants.ALEMBIC_CONFIG).exists():
+ if environment.ALEMBIC_CONFIG.get().exists():
console.error(
"Database is already initialized. Use "
"[bold]reflex db makemigrations[/bold] to create schema change "
@@ -458,25 +434,8 @@ def makemigrations(
)
-@script_cli.command(
- name="keep-chakra",
- help="Change all rx. references to rx.chakra., to preserve Chakra UI usage.",
-)
-def keep_chakra():
- """Change all rx. references to rx.chakra., to preserve Chakra UI usage."""
- from reflex.utils import prerequisites
-
- prerequisites.migrate_to_rx_chakra()
-
-
@cli.command()
def deploy(
- key: Optional[str] = typer.Option(
- None,
- "-k",
- "--deployment-key",
- help="The name of the deployment. Domain name safe characters only.",
- ),
app_name: str = typer.Option(
config.app_name,
"--app-name",
@@ -484,71 +443,70 @@ def deploy(
hidden=True,
),
regions: List[str] = typer.Option(
- list(),
+ [],
"-r",
"--region",
- help="The regions to deploy to.",
+ help="The regions to deploy to. `reflex cloud regions` For multiple envs, repeat this option, e.g. --region sjc --region iad",
),
envs: List[str] = typer.Option(
- list(),
+ [],
"--env",
help="The environment variables to set: =. For multiple envs, repeat this option, e.g. --env k1=v2 --env k2=v2.",
),
- cpus: Optional[int] = typer.Option(
- None, help="The number of CPUs to allocate.", hidden=True
- ),
- memory_mb: Optional[int] = typer.Option(
- None, help="The amount of memory to allocate.", hidden=True
- ),
- auto_start: Optional[bool] = typer.Option(
+ vmtype: Optional[str] = typer.Option(
None,
- help="Whether to auto start the instance.",
- hidden=True,
+ "--vmtype",
+ help="Vm type id. Run `reflex cloud vmtypes` to get options.",
),
- auto_stop: Optional[bool] = typer.Option(
+ hostname: Optional[str] = typer.Option(
None,
- help="Whether to auto stop the instance.",
- hidden=True,
- ),
- frontend_hostname: Optional[str] = typer.Option(
- None,
- "--frontend-hostname",
+ "--hostname",
help="The hostname of the frontend.",
- hidden=True,
),
interactive: bool = typer.Option(
True,
help="Whether to list configuration options and ask for confirmation.",
),
- with_metrics: Optional[str] = typer.Option(
+ envfile: Optional[str] = typer.Option(
None,
- help="Setting for metrics scraping for the deployment. Setup required in user code.",
- hidden=True,
- ),
- with_tracing: Optional[str] = typer.Option(
- None,
- help="Setting to export tracing for the deployment. Setup required in user code.",
- hidden=True,
- ),
- upload_db_file: bool = typer.Option(
- False,
- help="Whether to include local sqlite db files when uploading to hosting service.",
- hidden=True,
+ "--envfile",
+ help="The path to an env file to use. Will override any envs set manually.",
),
loglevel: constants.LogLevel = typer.Option(
config.loglevel, help="The log level to use."
),
+ project: Optional[str] = typer.Option(
+ None,
+ "--project",
+ help="project id to deploy to",
+ ),
+ token: Optional[str] = typer.Option(
+ None,
+ "--token",
+ help="token to use for auth",
+ ),
):
"""Deploy the app to the Reflex hosting service."""
- from reflex_cli import cli as hosting_cli
+ from reflex_cli.utils import dependency
+ from reflex_cli.v2 import cli as hosting_cli
from reflex.utils import export as export_utils
from reflex.utils import prerequisites
+ check_version()
+
# Set the log level.
console.set_log_level(loglevel)
- # Only check requirements if interactive. There is user interaction for requirements update.
+ if not token:
+ # make sure user is logged in.
+ if interactive:
+ hosting_cli.login()
+ else:
+ raise SystemExit("Token is required for non-interactive mode.")
+
+ # Only check requirements if interactive.
+ # There is user interaction for requirements update.
if interactive:
dependency.check_requirements()
@@ -571,42 +529,26 @@ def deploy(
frontend=frontend,
backend=backend,
zipping=zipping,
- loglevel=loglevel,
- upload_db_file=upload_db_file,
+ loglevel=loglevel.subprocess_level(),
),
- key=key,
regions=regions,
envs=envs,
- cpus=cpus,
- memory_mb=memory_mb,
- auto_start=auto_start,
- auto_stop=auto_stop,
- frontend_hostname=frontend_hostname,
+ vmtype=vmtype,
+ envfile=envfile,
+ hostname=hostname,
interactive=interactive,
- with_metrics=with_metrics,
- with_tracing=with_tracing,
- loglevel=loglevel.value,
+ loglevel=type(loglevel).INFO, # type: ignore
+ token=token,
+ project=project,
)
-@cli.command()
-def demo(
- frontend_port: str = typer.Option(
- "3001", help="Specify a different frontend port."
- ),
- backend_port: str = typer.Option("8001", help="Specify a different backend port."),
-):
- """Run the demo app."""
- # Open the demo app in a terminal.
- webbrowser.open("https://demo.reflex.run")
-
-
cli.add_typer(db_cli, name="db", help="Subcommands for managing the database schema.")
cli.add_typer(script_cli, name="script", help="Subcommands running helper scripts.")
cli.add_typer(
- deployments_cli,
- name="deployments",
- help="Subcommands for managing the Deployments.",
+ hosting_cli,
+ name="cloud",
+ help="Subcommands for managing the reflex cloud.",
)
cli.add_typer(
custom_components_cli,
diff --git a/reflex/state.py b/reflex/state.py
index 56b842666..e6724c766 100644
--- a/reflex/state.py
+++ b/reflex/state.py
@@ -5,18 +5,27 @@ from __future__ import annotations
import asyncio
import contextlib
import copy
+import dataclasses
import functools
import inspect
import os
import traceback
+import json
+import pickle
+import sys
+import time
+import typing
import uuid
from abc import ABC, abstractmethod
from collections import defaultdict
+from hashlib import md5
+from pathlib import Path
from types import FunctionType, MethodType
from typing import (
TYPE_CHECKING,
Any,
AsyncIterator,
+ BinaryIO,
Callable,
ClassVar,
Dict,
@@ -24,27 +33,59 @@ from typing import (
Optional,
Sequence,
Set,
+ Tuple,
Type,
+ TypeVar,
Union,
cast,
+ get_args,
+ get_type_hints,
)
-import dill
+from redis.asyncio.client import PubSub
from sqlalchemy.orm import DeclarativeBase
+from typing_extensions import Self
-from reflex.config import get_config
+from reflex import event
+from reflex.config import PerformanceMode, get_config
+from reflex.istate.data import RouterData
+from reflex.istate.storage import ClientStorageBase
+from reflex.model import Model
+from reflex.vars.base import (
+ ComputedVar,
+ DynamicRouteVar,
+ Var,
+ computed_var,
+ dispatch,
+ get_unique_variable_name,
+ is_computed_var,
+)
try:
import pydantic.v1 as pydantic
except ModuleNotFoundError:
import pydantic
+from pydantic import BaseModel as BaseModelV2
+
+try:
+ from pydantic.v1 import BaseModel as BaseModelV1
+except ModuleNotFoundError:
+ BaseModelV1 = BaseModelV2
+
+try:
+ from pydantic.v1 import validator
+except ModuleNotFoundError:
+ from pydantic import validator
+
import wrapt
from redis.asyncio import Redis
from redis.exceptions import ResponseError
+import reflex.istate.dynamic
from reflex import constants
from reflex.base import Base
+from reflex.config import environment
from reflex.event import (
BACKGROUND_TASK_MARKER,
Event,
@@ -52,11 +93,34 @@ from reflex.event import (
EventSpec,
fix_events,
)
-from reflex.utils import console, format, prerequisites, types
-from reflex.utils.exceptions import ImmutableStateError, LockExpiredError
+from reflex.utils import console, format, path_ops, prerequisites, types
+from reflex.utils.exceptions import (
+ ComputedVarShadowsBaseVars,
+ ComputedVarShadowsStateVar,
+ DynamicComponentInvalidSignature,
+ DynamicRouteArgShadowsStateVar,
+ EventHandlerShadowsBuiltInStateMethod,
+ ImmutableStateError,
+ InvalidLockWarningThresholdError,
+ InvalidStateManagerMode,
+ LockExpiredError,
+ ReflexRuntimeError,
+ SetUndefinedStateVarError,
+ StateSchemaMismatchError,
+ StateSerializationError,
+ StateTooLargeError,
+)
from reflex.utils.exec import is_testing_env
-from reflex.utils.serializers import SerializedType, serialize, serializer
-from reflex.vars import BaseVar, ComputedVar, Var, computed_var
+from reflex.utils.serializers import serializer
+from reflex.utils.types import (
+ _isinstance,
+ get_origin,
+ is_optional,
+ is_union,
+ override,
+ value_inside_optional,
+)
+from reflex.vars import VarData
if TYPE_CHECKING:
from reflex.components.component import Component
@@ -66,8 +130,11 @@ Delta = Dict[str, Any]
var = computed_var
-# If the state is this large, it's considered a performance issue.
-TOO_LARGE_SERIALIZED_STATE = 100 * 1024 # 100kb
+if environment.REFLEX_PERF_MODE.get() != PerformanceMode.OFF:
+ # If the state is this large, it's considered a performance issue.
+ TOO_LARGE_SERIALIZED_STATE = environment.REFLEX_STATE_SIZE_LIMIT.get() * 1024
+ # Only warn about each state class size once.
+ _WARNED_ABOUT_STATE_SIZE: Set[str] = set()
def print_stack(depth: int = 3):
@@ -86,97 +153,14 @@ def print_stack(depth: int = 3):
)
-class HeaderData(Base):
- """An object containing headers data."""
-
- host: str = ""
- origin: str = ""
- upgrade: str = ""
- connection: str = ""
- pragma: str = ""
- cache_control: str = ""
- user_agent: str = ""
- sec_websocket_version: str = ""
- sec_websocket_key: str = ""
- sec_websocket_extensions: str = ""
- accept_encoding: str = ""
- accept_language: str = ""
-
- def __init__(self, router_data: Optional[dict] = None):
- """Initalize the HeaderData object based on router_data.
-
- Args:
- router_data: the router_data dict.
- """
- super().__init__()
- if router_data:
- for k, v in router_data.get(constants.RouteVar.HEADERS, {}).items():
- setattr(self, format.to_snake_case(k), v)
-
-
-class PageData(Base):
- """An object containing page data."""
-
- host: str = "" # repeated with self.headers.origin (remove or keep the duplicate?)
- path: str = ""
- raw_path: str = ""
- full_path: str = ""
- full_raw_path: str = ""
- params: dict = {}
-
- def __init__(self, router_data: Optional[dict] = None):
- """Initalize the PageData object based on router_data.
-
- Args:
- router_data: the router_data dict.
- """
- super().__init__()
- if router_data:
- self.host = router_data.get(constants.RouteVar.HEADERS, {}).get("origin")
- self.path = router_data.get(constants.RouteVar.PATH, "")
- self.raw_path = router_data.get(constants.RouteVar.ORIGIN, "")
- self.full_path = f"{self.host}{self.path}"
- self.full_raw_path = f"{self.host}{self.raw_path}"
- self.params = router_data.get(constants.RouteVar.QUERY, {})
-
-
-class SessionData(Base):
- """An object containing session data."""
-
- client_token: str = ""
- client_ip: str = ""
- session_id: str = ""
-
- def __init__(self, router_data: Optional[dict] = None):
- """Initalize the SessionData object based on router_data.
-
- Args:
- router_data: the router_data dict.
- """
- super().__init__()
- if router_data:
- self.client_token = router_data.get(constants.RouteVar.CLIENT_TOKEN, "")
- self.client_ip = router_data.get(constants.RouteVar.CLIENT_IP, "")
- self.session_id = router_data.get(constants.RouteVar.SESSION_ID, "")
-
-
-class RouterData(Base):
- """An object containing RouterData."""
-
- session: SessionData = SessionData()
- headers: HeaderData = HeaderData()
- page: PageData = PageData()
-
- def __init__(self, router_data: Optional[dict] = None):
- """Initialize the RouterData object.
-
- Args:
- router_data: the router_data dict.
- """
- super().__init__()
- self.session = SessionData(router_data)
- self.headers = HeaderData(router_data)
- self.page = PageData(router_data)
+# Errors caught during pickling of state
+HANDLED_PICKLE_ERRORS = (
+ pickle.PicklingError,
+ AttributeError,
+ IndexError,
+ TypeError,
+ ValueError,
+)
def _no_chain_background_task(
@@ -252,10 +236,11 @@ def _split_substate_key(substate_key: str) -> tuple[str, str]:
return token, state_name
+@dataclasses.dataclass(frozen=True, init=False)
class EventHandlerSetVar(EventHandler):
"""A special event handler to wrap setvar functionality."""
- state_cls: Type[BaseState]
+ state_cls: Type[BaseState] = dataclasses.field(init=False)
def __init__(self, state_cls: Type[BaseState]):
"""Initialize the EventHandlerSetVar.
@@ -266,8 +251,8 @@ class EventHandlerSetVar(EventHandler):
super().__init__(
fn=type(self).setvar,
state_full_name=state_cls.get_full_name(),
- state_cls=state_cls, # type: ignore
)
+ object.__setattr__(self, "state_cls", state_cls)
def setvar(self, var_name: str, value: Any):
"""Set the state variable to the value of the event.
@@ -292,6 +277,7 @@ class EventHandlerSetVar(EventHandler):
Raises:
AttributeError: If the given Var name does not exist on the state.
EventHandlerValueError: If the given Var name is not a str
+ NotImplementedError: If the setter for the given Var is async
"""
from reflex.utils.exceptions import EventHandlerValueError
@@ -300,14 +286,62 @@ class EventHandlerSetVar(EventHandler):
raise EventHandlerValueError(
f"Var name must be passed as a string, got {args[0]!r}"
)
+
+ handler = getattr(self.state_cls, constants.SETTER_PREFIX + args[0], None)
+
# Check that the requested Var setter exists on the State at compile time.
- if getattr(self.state_cls, constants.SETTER_PREFIX + args[0], None) is None:
+ if handler is None:
raise AttributeError(
f"Variable `{args[0]}` cannot be set on `{self.state_cls.get_full_name()}`"
)
+
+ if asyncio.iscoroutinefunction(handler.fn):
+ raise NotImplementedError(
+ f"Setter for {args[0]} is async, which is not supported."
+ )
+
return super().__call__(*args)
+if TYPE_CHECKING:
+ from pydantic.v1.fields import ModelField
+
+
+def _unwrap_field_type(type_: Type) -> Type:
+ """Unwrap rx.Field type annotations.
+
+ Args:
+ type_: The type to unwrap.
+
+ Returns:
+ The unwrapped type.
+ """
+ from reflex.vars import Field
+
+ if get_origin(type_) is Field:
+ return get_args(type_)[0]
+ return type_
+
+
+def get_var_for_field(cls: Type[BaseState], f: ModelField):
+ """Get a Var instance for a Pydantic field.
+
+ Args:
+ cls: The state class.
+ f: The Pydantic field.
+
+ Returns:
+ The Var instance.
+ """
+ field_name = format.format_state_name(cls.get_full_name()) + "." + f.name
+
+ return dispatch(
+ field_name=field_name,
+ var_data=VarData.from_state(cls, f.name),
+ result_var_type=_unwrap_field_type(f.outer_type_),
+ )
+
+
class BaseState(Base, ABC, extra=pydantic.Extra.allow):
"""The state of the app."""
@@ -315,7 +349,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
vars: ClassVar[Dict[str, Var]] = {}
# The base vars of the class.
- base_vars: ClassVar[Dict[str, BaseVar]] = {}
+ base_vars: ClassVar[Dict[str, Var]] = {}
# The computed vars of the class.
computed_vars: ClassVar[Dict[str, ComputedVar]] = {}
@@ -379,7 +413,6 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
def __init__(
self,
- *args,
parent_state: BaseState | None = None,
init_substates: bool = True,
_reflex_internal_init: bool = False,
@@ -390,11 +423,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
DO NOT INSTANTIATE STATE CLASSES DIRECTLY! Use StateManager.get_state() instead.
Args:
- *args: The args to pass to the Pydantic init method.
parent_state: The parent state.
init_substates: Whether to initialize the substates in this instance.
_reflex_internal_init: A flag to indicate that the state is being initialized by the framework.
- **kwargs: The kwargs to pass to the Pydantic init method.
+ **kwargs: The kwargs to set as attributes on the state.
Raises:
ReflexRuntimeError: If the state is instantiated directly by end user.
@@ -406,8 +438,14 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
"State classes should not be instantiated directly in a Reflex app. "
"See https://reflex.dev/docs/state/ for further information."
)
+ if type(self)._mixin:
+ raise ReflexRuntimeError(
+ f"{type(self).__name__} is a state mixin and cannot be instantiated directly."
+ )
kwargs["parent_state"] = parent_state
- super().__init__(*args, **kwargs)
+ super().__init__()
+ for name, value in kwargs.items():
+ setattr(self, name, value)
# Setup the substates (for memory state manager only).
if init_substates:
@@ -418,9 +456,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
)
# Create a fresh copy of the backend variables for this instance
- self._backend_vars = copy.deepcopy(
- {name: item for name, item in self.backend_vars.items()}
- )
+ self._backend_vars = copy.deepcopy(self.backend_vars)
def __repr__(self) -> str:
"""Get the string representation of the state.
@@ -428,7 +464,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
Returns:
The string representation of the state.
"""
- return f"{self.__class__.__name__}({self.dict()})"
+ return f"{type(self).__name__}({self.dict()})"
@classmethod
def _get_computed_vars(cls) -> list[ComputedVar]:
@@ -439,9 +475,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
"""
return [
v
- for mixin in cls._mixins() + [cls]
- for v in mixin.__dict__.values()
- if isinstance(v, ComputedVar)
+ for mixin in [*cls._mixins(), cls]
+ for name, v in mixin.__dict__.items()
+ if is_computed_var(v) and name not in cls.inherited_vars
]
@classmethod
@@ -483,6 +519,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
# Set the scope of the state.
cls._scope = scope
+ # Handle locally-defined states for pickling.
+ if "" in cls.__qualname__:
+ cls._handle_local_def()
# Validate the module name.
cls._validate_module_name()
@@ -491,7 +530,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
cls._check_overridden_methods()
# Computed vars should not shadow builtin state props.
- cls._check_overriden_basevars()
+ cls._check_overridden_basevars()
# Reset subclass tracking for this class.
cls.class_subclasses = set()
@@ -506,35 +545,33 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
cls.inherited_backend_vars = parent_state.backend_vars
# Check if another substate class with the same name has already been defined.
- if cls.get_name() in set(
- c.get_name() for c in parent_state.class_subclasses
- ):
- if is_testing_env():
- # Clear existing subclass with same name when app is reloaded via
- # utils.prerequisites.get_app(reload=True)
- parent_state.class_subclasses = set(
- c
- for c in parent_state.class_subclasses
- if c.get_name() != cls.get_name()
- )
- else:
- # During normal operation, subclasses cannot have the same name, even if they are
- # defined in different modules.
- raise StateValueError(
- f"The substate class '{cls.get_name()}' has been defined multiple times. "
- "Shadowing substate classes is not allowed."
- )
+ if cls.get_name() in {c.get_name() for c in parent_state.class_subclasses}:
+ # This should not happen, since we have added module prefix to state names in #3214
+ raise StateValueError(
+ f"The substate class '{cls.get_name()}' has been defined multiple times. "
+ "Shadowing substate classes is not allowed."
+ )
# Track this new subclass in the parent state's subclasses set.
parent_state.class_subclasses.add(cls)
# Get computed vars.
computed_vars = cls._get_computed_vars()
+ cls._check_overridden_computed_vars()
new_backend_vars = {
name: value
for name, value in cls.__dict__.items()
if types.is_backend_base_variable(name, cls)
}
+ # Add annotated backend vars that may not have a default value.
+ new_backend_vars.update(
+ {
+ name: cls._get_var_default(name, annotation_value)
+ for name, annotation_value in cls._get_type_hints().items()
+ if name not in new_backend_vars
+ and types.is_backend_base_variable(name, cls)
+ }
+ )
cls.backend_vars = {
**cls.inherited_backend_vars,
@@ -543,13 +580,14 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
# Set the base and computed vars.
cls.base_vars = {
- f.name: BaseVar(_var_name=f.name, _var_type=f.outer_type_)._var_set_state(
- cls
- )
+ f.name: get_var_for_field(cls, f)
for f in cls.get_fields().values()
if f.name not in cls.get_skip_vars()
}
- cls.computed_vars = {v._var_name: v._var_set_state(cls) for v in computed_vars}
+ cls.computed_vars = {
+ v._js_expr: v._replace(merge_var_data=VarData.from_state(cls))
+ for v in computed_vars
+ }
cls.vars = {
**cls.inherited_vars,
**cls.base_vars,
@@ -570,15 +608,15 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
for mixin in cls._mixins():
for name, value in mixin.__dict__.items():
- if isinstance(value, ComputedVar):
+ if name in cls.inherited_vars:
+ continue
+ if is_computed_var(value):
fget = cls._copy_fn(value.fget)
- newcv = value._replace(fget=fget)
+ newcv = value._replace(fget=fget, _var_data=VarData.from_state(cls))
# cleanup refs to mixin cls in var_data
- newcv._var_data = None
- newcv._var_set_state(cls)
setattr(cls, name, newcv)
- cls.computed_vars[newcv._var_name] = newcv
- cls.vars[newcv._var_name] = newcv
+ cls.computed_vars[newcv._js_expr] = newcv
+ cls.vars[newcv._js_expr] = newcv
continue
if types.is_backend_base_variable(name, mixin):
cls.backend_vars[name] = copy.deepcopy(value)
@@ -601,6 +639,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
cls.event_handlers[name] = handler
setattr(cls, name, handler)
+ # Initialize per-class var dependency tracking.
+ cls._computed_var_dependencies = defaultdict(set)
+ cls._substate_var_dependencies = defaultdict(set)
cls._init_var_dependency_dicts()
@staticmethod
@@ -643,6 +684,48 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
and hasattr(value, "__code__")
)
+ @classmethod
+ def _evaluate(
+ cls, f: Callable[[Self], Any], of_type: Union[type, None] = None
+ ) -> Var:
+ """Evaluate a function to a ComputedVar. Experimental.
+
+ Args:
+ f: The function to evaluate.
+ of_type: The type of the ComputedVar. Defaults to Component.
+
+ Returns:
+ The ComputedVar.
+ """
+ console.warn(
+ "The _evaluate method is experimental and may be removed in future versions."
+ )
+ from reflex.components.component import Component
+
+ of_type = of_type or Component
+
+ unique_var_name = get_unique_variable_name()
+
+ @computed_var(_js_expr=unique_var_name, return_type=of_type)
+ def computed_var_func(state: Self):
+ result = f(state)
+
+ if not _isinstance(result, of_type):
+ console.warn(
+ f"Inline ComputedVar {f} expected type {of_type}, got {type(result)}. "
+ "You can specify expected type with `of_type` argument."
+ )
+
+ return result
+
+ setattr(cls, unique_var_name, computed_var_func)
+ cls.computed_vars[unique_var_name] = computed_var_func
+ cls.vars[unique_var_name] = computed_var_func
+ cls._update_substate_inherited_vars({unique_var_name: computed_var_func})
+ cls._always_dirty_computed_vars.add(unique_var_name)
+
+ return getattr(cls, unique_var_name)
+
@classmethod
def _mixins(cls) -> List[Type]:
"""Get the mixin classes of the state.
@@ -660,6 +743,39 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
)
]
+ @classmethod
+ def _handle_local_def(cls):
+ """Handle locally-defined states for pickling."""
+ known_names = dir(reflex.istate.dynamic)
+ proposed_name = cls.__name__
+ for ix in range(len(known_names)):
+ if proposed_name not in known_names:
+ break
+ proposed_name = f"{cls.__name__}_{ix}"
+ setattr(reflex.istate.dynamic, proposed_name, cls)
+ cls.__original_name__ = cls.__name__
+ cls.__original_module__ = cls.__module__
+ cls.__name__ = cls.__qualname__ = proposed_name
+ cls.__module__ = reflex.istate.dynamic.__name__
+
+ @classmethod
+ def _get_type_hints(cls) -> dict[str, Any]:
+ """Get the type hints for this class.
+
+ If the class is dynamic, evaluate the type hints with the original
+ module in the local namespace.
+
+ Returns:
+ The type hints dict.
+ """
+ original_module = getattr(cls, "__original_module__", None)
+ if original_module is not None:
+ localns = sys.modules[original_module].__dict__
+ else:
+ localns = None
+
+ return get_type_hints(cls, localns=localns)
+
@classmethod
def _init_var_dependency_dicts(cls):
"""Initialize the var dependency tracking dicts.
@@ -670,10 +786,6 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
Additional updates tracking dicts for vars and substates that always
need to be recomputed.
"""
- # Initialize per-class var dependency tracking.
- cls._computed_var_dependencies = defaultdict(set)
- cls._substate_var_dependencies = defaultdict(set)
-
inherited_vars = set(cls.inherited_vars).union(
set(cls.inherited_backend_vars),
)
@@ -696,11 +808,11 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
)
# ComputedVar with cache=False always need to be recomputed
- cls._always_dirty_computed_vars = set(
+ cls._always_dirty_computed_vars = {
cvar_name
for cvar_name, cvar in cls.computed_vars.items()
if not cvar._cache
- )
+ }
# Any substate containing a ComputedVar with cache=False always needs to be recomputed
if cls._always_dirty_computed_vars: # or cls._scope is not None:
@@ -714,12 +826,15 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
parent_state.get_parent_state(),
)
+ # Reset cached schema value
+ cls._to_schema.cache_clear()
+
@classmethod
def _check_overridden_methods(cls):
"""Check for shadow methods and raise error if any.
Raises:
- NameError: When an event handler shadows an inbuilt state method.
+ EventHandlerShadowsBuiltInStateMethod: When an event handler shadows an inbuilt state method.
"""
overridden_methods = set()
state_base_functions = cls._get_base_functions()
@@ -733,21 +848,37 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
overridden_methods.add(method.__name__)
for method_name in overridden_methods:
- raise NameError(
+ raise EventHandlerShadowsBuiltInStateMethod(
f"The event handler name `{method_name}` shadows a builtin State method; use a different name instead"
)
@classmethod
- def _check_overriden_basevars(cls):
+ def _check_overridden_basevars(cls):
"""Check for shadow base vars and raise error if any.
Raises:
- NameError: When a computed var shadows a base var.
+ ComputedVarShadowsBaseVars: When a computed var shadows a base var.
"""
for computed_var_ in cls._get_computed_vars():
- if computed_var_._var_name in cls.__annotations__:
- raise NameError(
- f"The computed var name `{computed_var_._var_name}` shadows a base var in {cls.__module__}.{cls.__name__}; use a different name instead"
+ if computed_var_._js_expr in cls.__annotations__:
+ raise ComputedVarShadowsBaseVars(
+ f"The computed var name `{computed_var_._js_expr}` shadows a base var in {cls.__module__}.{cls.__name__}; use a different name instead"
+ )
+
+ @classmethod
+ def _check_overridden_computed_vars(cls) -> None:
+ """Check for shadow computed vars and raise error if any.
+
+ Raises:
+ ComputedVarShadowsStateVar: When a computed var shadows another.
+ """
+ for name, cv in cls.__dict__.items():
+ if not is_computed_var(cv):
+ continue
+ name = cv._js_expr
+ if name in cls.inherited_vars or name in cls.inherited_backend_vars:
+ raise ComputedVarShadowsStateVar(
+ f"The computed var name `{cv._js_expr}` shadows a var in {cls.__module__}.{cls.__name__}; use a different name instead"
)
@classmethod
@@ -774,6 +905,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
def get_parent_state(cls) -> Type[BaseState] | None:
"""Get the parent state.
+ Raises:
+ ValueError: If more than one parent state is found.
+
Returns:
The parent state.
"""
@@ -782,9 +916,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
for base in cls.__bases__
if issubclass(base, BaseState) and base is not BaseState and not base._mixin
]
- assert (
- len(parent_states) < 2
- ), f"Only one parent state is allowed {parent_states}."
+ if len(parent_states) >= 2:
+ raise ValueError(f"Only one parent state is allowed {parent_states}.")
return parent_states[0] if len(parent_states) == 1 else None # type: ignore
@classmethod
@@ -869,7 +1002,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
return getattr(substate, name)
@classmethod
- def _init_var(cls, prop: BaseVar):
+ def _init_var(cls, prop: Var):
"""Initialize a variable.
Args:
@@ -885,7 +1018,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
"State vars must be primitive Python types, "
"Plotly figures, Pandas dataframes, "
"or subclasses of rx.Base. "
- f'Found var "{prop._var_name}" with type {prop._var_type}.'
+ f'Found var "{prop._js_expr}" with type {prop._var_type}.'
)
cls._set_var(prop)
cls._create_setter(prop)
@@ -912,8 +1045,11 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
)
# create the variable based on name and type
- var = BaseVar(_var_name=name, _var_type=type_)
- var._var_set_state(cls)
+ var = Var(
+ _js_expr=format.format_state_name(cls.get_full_name()) + "." + name,
+ _var_type=type_,
+ _var_data=VarData.from_state(cls, name),
+ ).guess_type()
# add the pydantic field dynamically (must be done before _init_var)
cls.add_field(var, default_value)
@@ -932,13 +1068,13 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
cls._init_var_dependency_dicts()
@classmethod
- def _set_var(cls, prop: BaseVar):
+ def _set_var(cls, prop: Var):
"""Set the var as a class member.
Args:
prop: The var instance to set.
"""
- setattr(cls, prop._var_name, prop)
+ setattr(cls, prop._var_field_name, prop)
@classmethod
def _create_event_handler(cls, fn):
@@ -958,39 +1094,60 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
cls.setvar = cls.event_handlers["setvar"] = EventHandlerSetVar(state_cls=cls)
@classmethod
- def _create_setter(cls, prop: BaseVar):
+ def _create_setter(cls, prop: Var):
"""Create a setter for the var.
Args:
prop: The var to create a setter for.
"""
- setter_name = prop.get_setter_name(include_state=False)
+ setter_name = prop._get_setter_name(include_state=False)
if setter_name not in cls.__dict__:
- event_handler = cls._create_event_handler(prop.get_setter())
+ event_handler = cls._create_event_handler(prop._get_setter())
cls.event_handlers[setter_name] = event_handler
setattr(cls, setter_name, event_handler)
@classmethod
- def _set_default_value(cls, prop: BaseVar):
+ def _set_default_value(cls, prop: Var):
"""Set the default value for the var.
Args:
prop: The var to set the default value for.
"""
# Get the pydantic field for the var.
- field = cls.get_fields()[prop._var_name]
+ field = cls.get_fields()[prop._var_field_name]
if field.required:
- default_value = prop.get_default_value()
+ default_value = prop._get_default_value()
if default_value is not None:
field.required = False
field.default = default_value
if (
not field.required
and field.default is None
+ and field.default_factory is None
and not types.is_optional(prop._var_type)
):
# Ensure frontend uses null coalescing when accessing.
- prop._var_type = Optional[prop._var_type]
+ object.__setattr__(prop, "_var_type", Optional[prop._var_type])
+
+ @classmethod
+ def _get_var_default(cls, name: str, annotation_value: Any) -> Any:
+ """Get the default value of a (backend) var.
+
+ Args:
+ name: The name of the var.
+ annotation_value: The annotation value of the var.
+
+ Returns:
+ The default value of the var or None.
+ """
+ try:
+ return getattr(cls, name)
+ except AttributeError:
+ try:
+ return Var("", _var_type=annotation_value)._get_default_value()
+ except TypeError:
+ pass
+ return None
@staticmethod
def _get_base_functions() -> dict[str, FunctionType]:
@@ -1005,6 +1162,27 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
if not func[0].startswith("__")
}
+ @classmethod
+ def _update_substate_inherited_vars(cls, vars_to_add: dict[str, Var]):
+ """Update the inherited vars of substates recursively when new vars are added.
+
+ Also updates the var dependency tracking dicts after adding vars.
+
+ Args:
+ vars_to_add: names to Var instances to add to substates
+ """
+ for substate_class in cls.class_subclasses:
+ for name, var in vars_to_add.items():
+ if types.is_backend_base_variable(name, cls):
+ substate_class.backend_vars.setdefault(name, var)
+ substate_class.inherited_backend_vars.setdefault(name, var)
+ else:
+ substate_class.vars.setdefault(name, var)
+ substate_class.inherited_vars.setdefault(name, var)
+ substate_class._update_substate_inherited_vars(vars_to_add)
+ # Reinitialize dependency tracking dicts.
+ cls._init_var_dependency_dicts()
+
@classmethod
def setup_dynamic_args(cls, args: dict[str, str]):
"""Set up args for easy access in renderer.
@@ -1012,21 +1190,24 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
Args:
args: a dict of args
"""
+ if not args:
+ return
+
+ cls._check_overwritten_dynamic_args(list(args.keys()))
def argsingle_factory(param):
- @ComputedVar
def inner_func(self) -> str:
return self.router.page.params.get(param, "")
return inner_func
def arglist_factory(param):
- @ComputedVar
- def inner_func(self) -> List:
+ def inner_func(self) -> List[str]:
return self.router.page.params.get(param, [])
return inner_func
+ dynamic_vars = {}
for param, value in args.items():
if value == constants.RouteArgType.SINGLE:
func = argsingle_factory(param)
@@ -1034,13 +1215,39 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
func = arglist_factory(param)
else:
continue
- # to allow passing as a prop
- func._var_name = param
- cls.vars[param] = cls.computed_vars[param] = func._var_set_state(cls) # type: ignore
- setattr(cls, param, func)
+ dynamic_vars[param] = DynamicRouteVar(
+ fget=func,
+ cache=True,
+ _js_expr=param,
+ _var_data=VarData.from_state(cls),
+ )
+ setattr(cls, param, dynamic_vars[param])
- # Reinitialize dependency tracking dicts.
- cls._init_var_dependency_dicts()
+ # Update tracking dicts.
+ cls.computed_vars.update(dynamic_vars)
+ cls.vars.update(dynamic_vars)
+ cls._update_substate_inherited_vars(dynamic_vars)
+
+ @classmethod
+ def _check_overwritten_dynamic_args(cls, args: list[str]):
+ """Check if dynamic args are shadowing existing vars. Recursively checks all child states.
+
+ Args:
+ args: a dict of args
+
+ Raises:
+ DynamicRouteArgShadowsStateVar: If a dynamic arg is shadowing an existing var.
+ """
+ for arg in args:
+ if (
+ arg in cls.computed_vars
+ and not isinstance(cls.computed_vars[arg], DynamicRouteVar)
+ ) or arg in cls.base_vars:
+ raise DynamicRouteArgShadowsStateVar(
+ f"Dynamic route arg '{arg}' is shadowing an existing var in {cls.__module__}.{cls.__name__}"
+ )
+ for substate in cls.get_substates():
+ substate._check_overwritten_dynamic_args(args)
def __getattribute__(self, name: str) -> Any:
"""Get the state var.
@@ -1057,13 +1264,16 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
if not super().__getattribute__("__dict__"):
return super().__getattribute__(name)
- inherited_vars = {
- **super().__getattribute__("inherited_vars"),
- **super().__getattribute__("inherited_backend_vars"),
- }
+ # Fast path for dunder
+ if name.startswith("__"):
+ return super().__getattribute__(name)
# For now, handle router_data updates as a special case.
- if name in inherited_vars or name == constants.ROUTER_DATA:
+ if (
+ name == constants.ROUTER_DATA
+ or name in super().__getattribute__("inherited_vars")
+ or name in super().__getattribute__("inherited_backend_vars")
+ ):
parent_state = super().__getattribute__("parent_state")
if parent_state is not None:
return getattr(parent_state, name)
@@ -1093,7 +1303,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
if parent_state is not None:
return getattr(parent_state, name)
- if isinstance(value, MutableProxy.__mutable_types__) and (
+ if MutableProxy._is_mutable_type(value) and (
name in super().__getattribute__("base_vars") or name in backend_vars
):
# track changes in mutable containers (list, dict, set, etc)
@@ -1109,14 +1319,16 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
Args:
name: The name of the attribute.
value: The value of the attribute.
+
+ Raises:
+ SetUndefinedStateVarError: If a value of a var is set without first defining it.
"""
if isinstance(value, MutableProxy):
# unwrap proxy objects when assigning back to the state
value = value.__wrapped__
# Set the var on the parent state.
- inherited_vars = {**self.inherited_vars, **self.inherited_backend_vars}
- if name in inherited_vars:
+ if name in self.inherited_vars or name in self.inherited_backend_vars:
setattr(self.parent_state, name, value)
return
@@ -1126,6 +1338,35 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
self._mark_dirty()
return
+ if (
+ name not in self.vars
+ and name not in self.get_skip_vars()
+ and not name.startswith("__")
+ and not name.startswith(
+ f"_{getattr(type(self), '__original_name__', type(self).__name__)}__"
+ )
+ ):
+ raise SetUndefinedStateVarError(
+ f"The state variable '{name}' has not been defined in '{type(self).__name__}'. "
+ f"All state variables must be declared before they can be set."
+ )
+
+ fields = self.get_fields()
+
+ if name in fields:
+ field = fields[name]
+ field_type = _unwrap_field_type(field.outer_type_)
+ if field.allow_none and not is_optional(field_type):
+ field_type = Union[field_type, None]
+ if not _isinstance(value, field_type):
+ console.deprecate(
+ "mismatched-type-assignment",
+ f"Tried to assign value {value} of type {type(value)} to field {type(self).__name__}.{name} of type {field_type}."
+ " This might lead to unexpected behavior.",
+ "0.6.5",
+ "0.7.0",
+ )
+
# Set the attribute.
super().__setattr__(name, value)
@@ -1153,6 +1394,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
default = copy.deepcopy(field.default)
setattr(self, prop_name, default)
+ # Reset the backend vars.
+ for prop_name, value in self.backend_vars.items():
+ setattr(self, prop_name, copy.deepcopy(value))
+
# Recursively reset the substates.
for substate in self.substates.values():
substate.reset()
@@ -1255,6 +1500,17 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
parent_states_with_name.append((parent_state.get_full_name(), parent_state))
return parent_states_with_name
+ def _get_root_state(self) -> BaseState:
+ """Get the root state of the state tree.
+
+ Returns:
+ The root state of the state tree.
+ """
+ parent_state = self
+ while parent_state.parent_state is not None:
+ parent_state = parent_state.parent_state
+ return parent_state
+
async def _populate_parent_states(self, target_state_cls: Type[BaseState]):
"""Populate substates in the tree between the target_state_cls and common ancestor of this state.
@@ -1312,10 +1568,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
Returns:
The instance of state_cls associated with this state's client_token.
"""
- if self.parent_state is None:
- root_state = self
- else:
- root_state = self._get_parent_states()[-1][1]
+ root_state = self._get_root_state()
return root_state.get_substate(state_cls.get_full_name().split("."))
async def _get_state_from_redis(self, state_cls: Type[BaseState]) -> BaseState:
@@ -1495,9 +1748,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
The valid StateUpdate containing the events and final flag.
"""
# get the delta from the root of the state tree
- state = self
- while state.parent_state is not None:
- state = state.parent_state
+ state = self._get_root_state()
token = self._get_token()
@@ -1557,6 +1808,44 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
# Get the function to process the event.
fn = functools.partial(handler.fn, state)
+ try:
+ type_hints = typing.get_type_hints(handler.fn)
+ except Exception:
+ type_hints = {}
+
+ for arg, value in list(payload.items()):
+ hinted_args = type_hints.get(arg, Any)
+ if hinted_args is Any:
+ continue
+ if is_union(hinted_args):
+ if value is None:
+ continue
+ hinted_args = value_inside_optional(hinted_args)
+ if (
+ isinstance(value, dict)
+ and inspect.isclass(hinted_args)
+ and not types.is_generic_alias(hinted_args) # py3.9-py3.10
+ ):
+ if issubclass(hinted_args, Model):
+ # Remove non-fields from the payload
+ payload[arg] = hinted_args(
+ **{
+ key: value
+ for key, value in value.items()
+ if key in hinted_args.__fields__
+ }
+ )
+ elif dataclasses.is_dataclass(hinted_args) or issubclass(
+ hinted_args, (Base, BaseModelV1, BaseModelV2)
+ ):
+ payload[arg] = hinted_args(**value)
+ if isinstance(value, list) and (hinted_args is set or hinted_args is Set):
+ payload[arg] = set(value)
+ if isinstance(value, list) and (
+ hinted_args is tuple or hinted_args is Tuple
+ ):
+ payload[arg] = tuple(value)
+
# Wrap the function in a try/except block.
try:
# Handle async functions.
@@ -1620,11 +1909,11 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
Returns:
Set of computed vars to include in the delta.
"""
- return set(
+ return {
cvar
for cvar in self.computed_vars
if self.computed_vars[cvar].needs_update(instance=self)
- )
+ }
def _dirty_computed_vars(
self, from_vars: set[str] | None = None, include_backend: bool = True
@@ -1638,12 +1927,12 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
Returns:
Set of computed vars to include in the delta.
"""
- return set(
+ return {
cvar
for dirty_var in from_vars or self.dirty_vars
for cvar in self._computed_var_dependencies[dirty_var]
if include_backend or not self.computed_vars[cvar]._backend
- )
+ }
@classmethod
def _potentially_dirty_substates(cls) -> set[Type[BaseState]]:
@@ -1653,16 +1942,16 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
Set of State classes that may need to be fetched to recalc computed vars.
"""
# _always_dirty_substates need to be fetched to recalc computed vars.
- fetch_substates = set(
+ fetch_substates = {
cls.get_class_substate((cls.get_name(), *substate_name.split(".")))
for substate_name in cls._always_dirty_substates
- )
+ }
for dependent_substates in cls._substate_var_dependencies.values():
fetch_substates.update(
- set(
+ {
cls.get_class_substate((cls.get_name(), *substate_name.split(".")))
for substate_name in dependent_substates
- )
+ }
)
return fetch_substates
@@ -1694,11 +1983,12 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
if len(self.scopes_and_subscopes()) > 1 and "router" in delta_vars:
delta_vars.remove("router")
- subdelta = {
- prop: getattr(self, prop)
+ subdelta: Dict[str, Any] = {
+ prop: self.get_value(prop)
for prop in delta_vars
if not types.is_backend_base_variable(prop, type(self))
}
+
if len(subdelta) > 0:
delta[self.get_full_name()] = subdelta
@@ -1710,9 +2000,6 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
for substate in self.dirty_substates.union(self._always_dirty_substates):
delta.update(substates[substate].get_delta())
- # Format the delta.
- delta = format.format_state(delta)
-
# Return the delta.
return delta
@@ -1751,6 +2038,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
if var in self.base_vars or var in self._backend_vars:
self._was_touched = True
break
+ if var == constants.ROUTER_DATA and self.parent_state is None:
+ self._was_touched = True
+ break
def _get_was_touched(self) -> bool:
"""Check current dirty_vars and flag to determine if state instance was modified.
@@ -1792,9 +2082,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
Returns:
The value of the field.
"""
- if isinstance(key, MutableProxy):
- return super().get_value(key.__wrapped__)
- return super().get_value(key)
+ value = super().get_value(key)
+ if isinstance(value, MutableProxy):
+ return value.__wrapped__
+ return value
def dict(
self, include_computed: bool = True, initial: bool = False, **kwargs
@@ -1816,17 +2107,16 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
self._mark_dirty()
base_vars = {
- prop_name: self.get_value(getattr(self, prop_name))
- for prop_name in self.base_vars
+ prop_name: self.get_value(prop_name) for prop_name in self.base_vars
}
- if initial:
+ if initial and include_computed:
computed_vars = {
# Include initial computed vars.
prop_name: (
cv._initial_value
- if isinstance(cv, ComputedVar)
+ if is_computed_var(cv)
and not isinstance(cv._initial_value, types.Unset)
- else self.get_value(getattr(self, prop_name))
+ else self.get_value(prop_name)
)
for prop_name, cv in self.computed_vars.items()
if not cv._backend
@@ -1834,7 +2124,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
elif include_computed:
computed_vars = {
# Include the computed vars.
- prop_name: self.get_value(getattr(self, prop_name))
+ prop_name: self.get_value(prop_name)
for prop_name, cv in self.computed_vars.items()
if not cv._backend
}
@@ -1879,7 +2169,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
def __getstate__(self):
"""Get the state for redis serialization.
- This method is called by cloudpickle to serialize the object.
+ This method is called by pickle to serialize the object.
It explicitly removes parent_state and substates because those are serialized separately
by the StateManagerRedis to allow for better horizontal scaling as state size increases.
@@ -1888,15 +2178,158 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
The state dict for serialization.
"""
state = super().__getstate__()
- # Never serialize parent_state or substates
state["__dict__"] = state["__dict__"].copy()
- state["__dict__"]["parent_state"] = None
- state["__dict__"]["substates"] = {}
+ if state["__dict__"].get("parent_state") is not None:
+ # Do not serialize router data in substates (only the root state).
+ state["__dict__"].pop("router", None)
+ state["__dict__"].pop("router_data", None)
+ # Never serialize parent_state or substates.
+ state["__dict__"].pop("parent_state", None)
+ state["__dict__"].pop("substates", None)
state["__dict__"].pop("_was_touched", None)
+ # Remove all inherited vars.
+ for inherited_var_name in self.inherited_vars:
+ state["__dict__"].pop(inherited_var_name, None)
return state
+ def __setstate__(self, state: dict[str, Any]):
+ """Set the state from redis deserialization.
-EventHandlerSetVar.update_forward_refs()
+ This method is called by pickle to deserialize the object.
+
+ Args:
+ state: The state dict for deserialization.
+ """
+ state["__dict__"]["parent_state"] = None
+ state["__dict__"]["substates"] = {}
+ super().__setstate__(state)
+
+ def _check_state_size(
+ self,
+ pickle_state_size: int,
+ ):
+ """Print a warning when the state is too large.
+
+ Args:
+ pickle_state_size: The size of the pickled state.
+
+ Raises:
+ StateTooLargeError: If the state is too large.
+ """
+ state_full_name = self.get_full_name()
+ if (
+ state_full_name not in _WARNED_ABOUT_STATE_SIZE
+ and pickle_state_size > TOO_LARGE_SERIALIZED_STATE
+ and self.substates
+ ):
+ msg = (
+ f"State {state_full_name} serializes to {pickle_state_size} bytes "
+ + "which may present performance issues. Consider reducing the size of this state."
+ )
+ if environment.REFLEX_PERF_MODE.get() == PerformanceMode.WARN:
+ console.warn(msg)
+ elif environment.REFLEX_PERF_MODE.get() == PerformanceMode.RAISE:
+ raise StateTooLargeError(msg)
+ _WARNED_ABOUT_STATE_SIZE.add(state_full_name)
+
+ @classmethod
+ @functools.lru_cache()
+ def _to_schema(cls) -> str:
+ """Convert a state to a schema.
+
+ Returns:
+ The hash of the schema.
+ """
+
+ def _field_tuple(
+ field_name: str,
+ ) -> Tuple[str, str, Any, Union[bool, None], Any]:
+ model_field = cls.__fields__[field_name]
+ return (
+ field_name,
+ model_field.name,
+ _serialize_type(model_field.type_),
+ (
+ model_field.required
+ if isinstance(model_field.required, bool)
+ else None
+ ),
+ (model_field.default if is_serializable(model_field.default) else None),
+ )
+
+ return md5(
+ pickle.dumps(
+ sorted(_field_tuple(field_name) for field_name in cls.base_vars)
+ )
+ ).hexdigest()
+
+ def _serialize(self) -> bytes:
+ """Serialize the state for redis.
+
+ Returns:
+ The serialized state.
+
+ Raises:
+ StateSerializationError: If the state cannot be serialized.
+ """
+ payload = b""
+ error = ""
+ try:
+ payload = pickle.dumps((self._to_schema(), self))
+ except HANDLED_PICKLE_ERRORS as og_pickle_error:
+ error = (
+ f"Failed to serialize state {self.get_full_name()} due to unpicklable object. "
+ "This state will not be persisted. "
+ )
+ try:
+ import dill
+
+ payload = dill.dumps((self._to_schema(), self))
+ except ImportError:
+ error += (
+ f"Pickle error: {og_pickle_error}. "
+ "Consider `pip install 'dill>=0.3.8'` for more exotic serialization support."
+ )
+ except HANDLED_PICKLE_ERRORS as ex:
+ error += f"Dill was also unable to pickle the state: {ex}"
+ console.warn(error)
+
+ if environment.REFLEX_PERF_MODE.get() != PerformanceMode.OFF:
+ self._check_state_size(len(payload))
+
+ if not payload:
+ raise StateSerializationError(error)
+
+ return payload
+
+ @classmethod
+ def _deserialize(
+ cls, data: bytes | None = None, fp: BinaryIO | None = None
+ ) -> BaseState:
+ """Deserialize the state from redis/disk.
+
+ data and fp are mutually exclusive, but one must be provided.
+
+ Args:
+ data: The serialized state data.
+ fp: The file pointer to the serialized state data.
+
+ Returns:
+ The deserialized state.
+
+ Raises:
+ ValueError: If both data and fp are provided, or neither are provided.
+ StateSchemaMismatchError: If the state schema does not match the expected schema.
+ """
+ if data is not None and fp is None:
+ (substate_schema, state) = pickle.loads(data)
+ elif fp is not None and data is None:
+ (substate_schema, state) = pickle.load(fp)
+ else:
+ raise ValueError("Only one of `data` or `fp` must be provided")
+ if substate_schema != state._to_schema():
+ raise StateSchemaMismatchError()
+ return state
class State(BaseState):
@@ -1906,10 +2339,56 @@ class State(BaseState):
is_hydrated: bool = False
+T = TypeVar("T", bound=BaseState)
+
+
+def dynamic(func: Callable[[T], Component]):
+ """Create a dynamically generated components from a state class.
+
+ Args:
+ func: The function to generate the component.
+
+ Returns:
+ The dynamically generated component.
+
+ Raises:
+ DynamicComponentInvalidSignature: If the function does not have exactly one parameter.
+ DynamicComponentInvalidSignature: If the function does not have a type hint for the state class.
+ """
+ number_of_parameters = len(inspect.signature(func).parameters)
+
+ func_signature = get_type_hints(func)
+
+ if "return" in func_signature:
+ func_signature.pop("return")
+
+ values = list(func_signature.values())
+
+ if number_of_parameters != 1:
+ raise DynamicComponentInvalidSignature(
+ "The function must have exactly one parameter, which is the state class."
+ )
+
+ if len(values) != 1:
+ raise DynamicComponentInvalidSignature(
+ "You must provide a type hint for the state class in the function."
+ )
+
+ state_class: Type[T] = values[0]
+
+ def wrapper() -> Component:
+ from reflex.components.base.fragment import fragment
+
+ return fragment(state_class._evaluate(lambda state: func(state)))
+
+ return wrapper
+
+
class FrontendEventExceptionState(State):
"""Substate for handling frontend exceptions."""
- def handle_frontend_exception(self, stack: str) -> None:
+ @event
+ def handle_frontend_exception(self, stack: str, component_stack: str) -> None:
"""Handle frontend exceptions.
If a frontend exception handler is provided, it will be called.
@@ -1917,6 +2396,7 @@ class FrontendEventExceptionState(State):
Args:
stack: The stack trace of the exception.
+ component_stack: The stack trace of the component where the exception occurred.
"""
app_instance = getattr(prerequisites.get_app(), constants.CompileVars.APP)
@@ -2016,6 +2496,23 @@ class ComponentState(State, mixin=True):
# The number of components created from this class.
_per_component_state_instance_count: ClassVar[int] = 0
+ def __init__(self, *args, **kwargs):
+ """Do not allow direct initialization of the ComponentState.
+
+ Args:
+ *args: The args to pass to the State init method.
+ **kwargs: The kwargs to pass to the State init method.
+
+ Raises:
+ ReflexRuntimeError: If the ComponentState is initialized directly.
+ """
+ if type(self)._mixin:
+ raise ReflexRuntimeError(
+ f"{ComponentState.__name__} {type(self).__name__} is not meant to be initialized directly. "
+ + "Use the `create` method to create a new instance and access the state via the `State` attribute."
+ )
+ super().__init__(*args, **kwargs)
+
@classmethod
def __init_subclass__(cls, mixin: bool = True, **kwargs):
"""Overwrite mixin default to True.
@@ -2054,7 +2551,14 @@ class ComponentState(State, mixin=True):
"""
cls._per_component_state_instance_count += 1
state_cls_name = f"{cls.__name__}_n{cls._per_component_state_instance_count}"
- component_state = type(state_cls_name, (cls, State), {}, mixin=False)
+ component_state = type(
+ state_cls_name,
+ (cls, State),
+ {"__module__": reflex.istate.dynamic.__name__},
+ mixin=False,
+ )
+ # Save a reference to the dynamic state for pickle/unpickle.
+ setattr(reflex.istate.dynamic, state_cls_name, component_state)
component = component_state.get_component(*children, **props)
component.State = component_state
return component
@@ -2079,7 +2583,7 @@ class StateProxy(wrapt.ObjectProxy):
class State(rx.State):
counter: int = 0
- @rx.background
+ @rx.event(background=True)
async def bg_increment(self):
await asyncio.sleep(1)
async with self:
@@ -2322,27 +2826,39 @@ class StateProxy(wrapt.ObjectProxy):
Returns:
The state update.
"""
+ original_mutable = self._self_mutable
self._self_mutable = True
try:
return self.__wrapped__._as_state_update(*args, **kwargs)
finally:
- self._self_mutable = False
+ self._self_mutable = original_mutable
-class StateUpdate(Base):
+@dataclasses.dataclass(
+ frozen=True,
+)
+class StateUpdate:
"""A state update sent to the frontend."""
# The state delta.
- delta: Delta = {}
+ delta: Delta = dataclasses.field(default_factory=dict)
# Events to be added to the event queue.
- events: List[Event] = []
+ events: List[Event] = dataclasses.field(default_factory=list)
# Whether this is the final state update for the event.
final: bool = True
scopes: list[str] = []
+ def json(self) -> str:
+ """Convert the state update to a JSON string.
+
+ Returns:
+ The state update as a JSON string.
+ """
+ return format.json_dumps(self)
+
class StateManager(Base, ABC):
"""A class to manage many client states."""
@@ -2357,20 +2873,33 @@ class StateManager(Base, ABC):
Args:
state: The state class to use.
+ Raises:
+ InvalidStateManagerMode: If the state manager mode is invalid.
+
Returns:
- The state manager (either memory or redis).
+ The state manager (either disk, memory or redis).
"""
- redis = prerequisites.get_redis()
- if redis is not None:
- # make sure expiration values are obtained only from the config object on creation
- config = get_config()
- return StateManagerRedis(
- state=state,
- redis=redis,
- token_expiration=config.redis_token_expiration,
- lock_expiration=config.redis_lock_expiration,
- )
- return StateManagerMemory(state=state)
+ config = get_config()
+ if prerequisites.parse_redis_url() is not None:
+ config.state_manager_mode = constants.StateManagerMode.REDIS
+ if config.state_manager_mode == constants.StateManagerMode.MEMORY:
+ return StateManagerMemory(state=state)
+ if config.state_manager_mode == constants.StateManagerMode.DISK:
+ return StateManagerDisk(state=state)
+ if config.state_manager_mode == constants.StateManagerMode.REDIS:
+ redis = prerequisites.get_redis()
+ if redis is not None:
+ # make sure expiration values are obtained only from the config object on creation
+ return StateManagerRedis(
+ state=state,
+ redis=redis,
+ token_expiration=config.redis_token_expiration,
+ lock_expiration=config.redis_lock_expiration,
+ lock_warning_threshold=config.redis_lock_warning_threshold,
+ )
+ raise InvalidStateManagerMode(
+ f"Expected one of: DISK, MEMORY, REDIS, got {config.state_manager_mode}"
+ )
@abstractmethod
async def get_state(self, token: str) -> BaseState:
@@ -2427,6 +2956,7 @@ class StateManagerMemory(StateManager):
"_states_locks": {"exclude": True},
}
+ @override
async def get_state(self, token: str) -> BaseState:
"""Get the state for a token.
@@ -2447,6 +2977,7 @@ class StateManagerMemory(StateManager):
return self.states[token]
+ @override
async def set_state(self, token: str, state: BaseState):
"""Set the state for a token.
@@ -2456,6 +2987,7 @@ class StateManagerMemory(StateManager):
"""
pass
+ @override
@contextlib.asynccontextmanager
async def modify_state(self, token: str) -> AsyncIterator[BaseState]:
"""Modify the state for a token while holding exclusive lock.
@@ -2477,23 +3009,254 @@ class StateManagerMemory(StateManager):
await self.set_state(token, state)
-# Workaround https://github.com/cloudpipe/cloudpickle/issues/408 for dynamic pydantic classes
-if not isinstance(State.validate.__func__, FunctionType):
- cython_function_or_method = type(State.validate.__func__)
+def _default_token_expiration() -> int:
+ """Get the default token expiration time.
- @dill.register(cython_function_or_method)
- def _dill_reduce_cython_function_or_method(pickler, obj):
- # Ignore cython function when pickling.
- pass
+ Returns:
+ The default token expiration time.
+ """
+ return get_config().redis_token_expiration
-@dill.register(type(State))
-def _dill_reduce_state(pickler, obj):
- if obj is not State and issubclass(obj, State):
- # Avoid serializing subclasses of State, instead get them by reference from the State class.
- pickler.save_reduce(State.get_class_substate, (obj.get_full_name(),), obj=obj)
- else:
- dill.Pickler.dispatch[type](pickler, obj)
+def _serialize_type(type_: Any) -> str:
+ """Serialize a type.
+
+ Args:
+ type_: The type to serialize.
+
+ Returns:
+ The serialized type.
+ """
+ if not inspect.isclass(type_):
+ return f"{type_}"
+ return f"{type_.__module__}.{type_.__qualname__}"
+
+
+def is_serializable(value: Any) -> bool:
+ """Check if a value is serializable.
+
+ Args:
+ value: The value to check.
+
+ Returns:
+ Whether the value is serializable.
+ """
+ try:
+ return bool(pickle.dumps(value))
+ except Exception:
+ return False
+
+
+def reset_disk_state_manager():
+ """Reset the disk state manager."""
+ states_directory = prerequisites.get_web_dir() / constants.Dirs.STATES
+ if states_directory.exists():
+ for path in states_directory.iterdir():
+ path.unlink()
+
+
+class StateManagerDisk(StateManager):
+ """A state manager that stores states in memory."""
+
+ # The mapping of client ids to states.
+ states: Dict[str, BaseState] = {}
+
+ # The mutex ensures the dict of mutexes is updated exclusively
+ _state_manager_lock = asyncio.Lock()
+
+ # The dict of mutexes for each client
+ _states_locks: Dict[str, asyncio.Lock] = pydantic.PrivateAttr({})
+
+ # The token expiration time (s).
+ token_expiration: int = pydantic.Field(default_factory=_default_token_expiration)
+
+ class Config:
+ """The Pydantic config."""
+
+ fields = {
+ "_states_locks": {"exclude": True},
+ }
+ keep_untouched = (functools.cached_property,)
+
+ def __init__(self, state: Type[BaseState]):
+ """Create a new state manager.
+
+ Args:
+ state: The state class to use.
+ """
+ super().__init__(state=state)
+
+ path_ops.mkdir(self.states_directory)
+
+ self._purge_expired_states()
+
+ @functools.cached_property
+ def states_directory(self) -> Path:
+ """Get the states directory.
+
+ Returns:
+ The states directory.
+ """
+ return prerequisites.get_web_dir() / constants.Dirs.STATES
+
+ def _purge_expired_states(self):
+ """Purge expired states from the disk."""
+ import time
+
+ for path in path_ops.ls(self.states_directory):
+ # check path is a pickle file
+ if path.suffix != ".pkl":
+ continue
+
+ # load last edited field from file
+ last_edited = path.stat().st_mtime
+
+ # check if the file is older than the token expiration time
+ if time.time() - last_edited > self.token_expiration:
+ # remove the file
+ path.unlink()
+
+ def token_path(self, token: str) -> Path:
+ """Get the path for a token.
+
+ Args:
+ token: The token to get the path for.
+
+ Returns:
+ The path for the token.
+ """
+ return (
+ self.states_directory / f"{md5(token.encode()).hexdigest()}.pkl"
+ ).absolute()
+
+ async def load_state(self, token: str) -> BaseState | None:
+ """Load a state object based on the provided token.
+
+ Args:
+ token: The token used to identify the state object.
+
+ Returns:
+ The loaded state object or None.
+ """
+ token_path = self.token_path(token)
+
+ if token_path.exists():
+ try:
+ with token_path.open(mode="rb") as file:
+ return BaseState._deserialize(fp=file)
+ except Exception:
+ pass
+
+ async def populate_substates(
+ self, client_token: str, state: BaseState, root_state: BaseState
+ ):
+ """Populate the substates of a state object.
+
+ Args:
+ client_token: The client token.
+ state: The state object to populate.
+ root_state: The root state object.
+ """
+ for substate in state.get_substates():
+ substate_token = _substate_key(client_token, substate)
+
+ fresh_instance = await root_state.get_state(substate)
+ instance = await self.load_state(substate_token)
+ if instance is not None:
+ # Ensure all substates exist, even if they weren't serialized previously.
+ instance.substates = fresh_instance.substates
+ else:
+ instance = fresh_instance
+ state.substates[substate.get_name()] = instance
+ instance.parent_state = state
+
+ await self.populate_substates(client_token, instance, root_state)
+
+ @override
+ async def get_state(
+ self,
+ token: str,
+ ) -> BaseState:
+ """Get the state for a token.
+
+ Args:
+ token: The token to get the state for.
+
+ Returns:
+ The state for the token.
+ """
+ client_token = _split_substate_key(token)[0]
+ root_state = self.states.get(client_token)
+ if root_state is not None:
+ # Retrieved state from memory.
+ return root_state
+
+ # Deserialize root state from disk.
+ root_state = await self.load_state(_substate_key(client_token, self.state))
+ # Create a new root state tree with all substates instantiated.
+ fresh_root_state = self.state(_reflex_internal_init=True)
+ if root_state is None:
+ root_state = fresh_root_state
+ else:
+ # Ensure all substates exist, even if they were not serialized previously.
+ root_state.substates = fresh_root_state.substates
+ self.states[client_token] = root_state
+ await self.populate_substates(client_token, root_state, root_state)
+ return root_state
+
+ async def set_state_for_substate(self, client_token: str, substate: BaseState):
+ """Set the state for a substate.
+
+ Args:
+ client_token: The client token.
+ substate: The substate to set.
+ """
+ substate_token = _substate_key(client_token, substate)
+
+ if substate._get_was_touched():
+ substate._was_touched = False # Reset the touched flag after serializing.
+ pickle_state = substate._serialize()
+ if pickle_state:
+ if not self.states_directory.exists():
+ self.states_directory.mkdir(parents=True, exist_ok=True)
+ self.token_path(substate_token).write_bytes(pickle_state)
+
+ for substate_substate in substate.substates.values():
+ await self.set_state_for_substate(client_token, substate_substate)
+
+ @override
+ async def set_state(self, token: str, state: BaseState):
+ """Set the state for a token.
+
+ Args:
+ token: The token to set the state for.
+ state: The state to set.
+ """
+ client_token, substate = _split_substate_key(token)
+ await self.set_state_for_substate(client_token, state)
+
+ @override
+ @contextlib.asynccontextmanager
+ async def modify_state(self, token: str) -> AsyncIterator[BaseState]:
+ """Modify the state for a token while holding exclusive lock.
+
+ Args:
+ token: The token to modify the state for.
+
+ Yields:
+ The state for the token.
+ """
+ # Memory state manager ignores the substate suffix and always returns the top-level state.
+ client_token, substate = _split_substate_key(token)
+ if client_token not in self._states_locks:
+ async with self._state_manager_lock:
+ if client_token not in self._states_locks:
+ self._states_locks[client_token] = asyncio.Lock()
+
+ async with self._states_locks[client_token]:
+ state = await self.get_state(token)
+ yield state
+ await self.set_state(token, state)
def _default_lock_expiration() -> int:
@@ -2505,13 +3268,13 @@ def _default_lock_expiration() -> int:
return get_config().redis_lock_expiration
-def _default_token_expiration() -> int:
- """Get the default token expiration time.
+def _default_lock_warning_threshold() -> int:
+ """Get the default lock warning threshold.
Returns:
- The default token expiration time.
+ The default lock warning threshold.
"""
- return get_config().redis_token_expiration
+ return get_config().redis_lock_warning_threshold
class StateManagerRedis(StateManager):
@@ -2526,6 +3289,11 @@ class StateManagerRedis(StateManager):
# The maximum time to hold a lock (ms).
lock_expiration: int = pydantic.Field(default_factory=_default_lock_expiration)
+ # The maximum time to hold a lock (ms) before warning.
+ lock_warning_threshold: int = pydantic.Field(
+ default_factory=_default_lock_warning_threshold
+ )
+
# The keyspace subscription string when redis is waiting for lock to be released
_redis_notify_keyspace_events: str = (
"K" # Enable keyspace notifications (target a particular key)
@@ -2542,27 +3310,14 @@ class StateManagerRedis(StateManager):
b"evicted",
}
- # Only warn about each state class size once.
- _warned_about_state_size: ClassVar[Set[str]] = set()
-
- def _get_root_state(self, state: BaseState) -> BaseState:
- """Chase parent_state pointers to find an instance of the top-level state.
-
- Args:
- state: The state to start from.
-
- Returns:
- An instance of the top-level state (self.state).
- """
- while type(state) != self.state and state.parent_state is not None:
- state = state.parent_state
- return state
-
- async def _get_parent_state(self, token: str) -> BaseState | None:
+ async def _get_parent_state(
+ self, token: str, state: BaseState | None = None
+ ) -> BaseState | None:
"""Get the parent state for the state requested in the token.
Args:
token: The token to get the state for (_substate_key).
+ state: The state instance to get parent state for.
Returns:
The parent state for the state requested by the token or None if there is no such parent.
@@ -2571,11 +3326,15 @@ class StateManagerRedis(StateManager):
client_token, state_path = _split_substate_key(token)
parent_state_name = state_path.rpartition(".")[0]
if parent_state_name:
+ cached_substates = None
+ if state is not None:
+ cached_substates = [state]
# Retrieve the parent state to populate event handlers onto this substate.
parent_state = await self.get_state(
token=_substate_key(client_token, parent_state_name),
top_level=False,
get_substates=False,
+ cached_substates=cached_substates,
)
return parent_state
@@ -2607,6 +3366,8 @@ class StateManagerRedis(StateManager):
tasks = {}
# Retrieve the necessary substates from redis.
for substate_cls in fetch_substates:
+ if substate_cls.get_name() in state.substates:
+ continue
substate_name = substate_cls.get_name()
tasks[substate_name] = asyncio.create_task(
self.get_state(
@@ -2620,16 +3381,14 @@ class StateManagerRedis(StateManager):
for substate_name, substate_task in tasks.items():
state.substates[substate_name] = await substate_task
- # async def print_all_keys(self):
- # for key in await self.redis.keys():
- # print(f"redis_key: {key}")
-
+ @override
async def get_state(
self,
token: str,
top_level: bool = True,
get_substates: bool = True,
parent_state: BaseState | None = None,
+ cached_substates: list[BaseState] | None = None,
) -> BaseState:
"""Get the state for a token.
@@ -2638,6 +3397,7 @@ class StateManagerRedis(StateManager):
top_level: If true, return an instance of the top-level state (self.state).
get_substates: If true, also retrieve substates.
parent_state: If provided, use this parent_state instead of getting it from redis.
+ cached_substates: If provided, attach these substates to the state.
Returns:
The state for the token.
@@ -2652,81 +3412,52 @@ class StateManagerRedis(StateManager):
state_cls = self.state.get_class_substate(state_path)
else:
raise RuntimeError(
- "StateManagerRedis requires token to be specified in the form of {token}_{state_full_name}"
+ f"StateManagerRedis requires token to be specified in the form of {{token}}_{{state_full_name}}, but got {token}"
)
if parent_state is None:
parent_state = await self._get_parent_state(token)
if parent_state is not None:
token = f"{parent_state._get_token(state_cls)}_{state_path}"
+ # The deserialized or newly created (sub)state instance.
+ state = None
+
# Fetch the serialized substate from redis.
redis_state = await self.redis.get(token)
if redis_state is not None:
# Deserialize the substate.
- state = dill.loads(redis_state)
-
- # Populate parent state if missing and requested.
- if parent_state is None:
- parent_state = await self._get_parent_state(token)
- # Set up Bidirectional linkage between this state and its parent.
- if parent_state is not None:
- parent_state.substates[state.get_name()] = state
- state.parent_state = parent_state
- # Populate substates if requested.
- await self._populate_substates(token, state, all_substates=get_substates)
-
- # To retain compatibility with previous implementation, by default, we return
- # the top-level state by chasing `parent_state` pointers up the tree.
- if top_level:
- return self._get_root_state(state)
- return state
-
- # TODO: dedupe the following logic with the above block
- # Key didn't exist so we have to create a new instance for this token.
+ with contextlib.suppress(StateSchemaMismatchError):
+ state = BaseState._deserialize(data=redis_state)
+ if state is None:
+ # Key didn't exist or schema mismatch so create a new instance for this token.
+ state = state_cls(
+ init_substates=False,
+ _reflex_internal_init=True,
+ )
+ # Populate parent state if missing and requested.
if parent_state is None:
- parent_state = await self._get_parent_state(token)
- # Instantiate the new state class (but don't persist it yet).
- state = state_cls(
- parent_state=parent_state,
- init_substates=False,
- _reflex_internal_init=True,
- )
+ parent_state = await self._get_parent_state(token, state)
# Set up Bidirectional linkage between this state and its parent.
if parent_state is not None:
parent_state.substates[state.get_name()] = state
state.parent_state = parent_state
- # Populate substates for the newly created state.
+ # Avoid fetching substates multiple times.
+ if cached_substates:
+ for substate in cached_substates:
+ state.substates[substate.get_name()] = substate
+ if substate.parent_state is None:
+ substate.parent_state = state
+ # Populate substates if requested.
await self._populate_substates(token, state, all_substates=get_substates)
+
# To retain compatibility with previous implementation, by default, we return
# the top-level state by chasing `parent_state` pointers up the tree.
if top_level:
- return self._get_root_state(state)
+ return state._get_root_state()
return state
- def _warn_if_too_large(
- self,
- state: BaseState,
- pickle_state_size: int,
- ):
- """Print a warning when the state is too large.
-
- Args:
- state: The state to check.
- pickle_state_size: The size of the pickled state.
- """
- state_full_name = state.get_full_name()
- if (
- state_full_name not in self._warned_about_state_size
- and pickle_state_size > TOO_LARGE_SERIALIZED_STATE
- and state.substates
- ):
- console.warn(
- f"State {state_full_name} serializes to {pickle_state_size} bytes "
- "which may present performance issues. Consider reducing the size of this state."
- )
- self._warned_about_state_size.add(state_full_name)
-
+ @override
async def set_state(
self,
token: str,
@@ -2752,8 +3483,19 @@ class StateManagerRedis(StateManager):
raise LockExpiredError(
f"Lock expired for token {token} while processing. Consider increasing "
f"`app.state_manager.lock_expiration` (currently {self.lock_expiration}) "
- "or use `@rx.background` decorator for long-running tasks."
+ "or use `@rx.event(background=True)` decorator for long-running tasks."
)
+ elif lock_id is not None:
+ time_taken = self.lock_expiration / 1000 - (
+ await self.redis.ttl(self._lock_key(token))
+ )
+ if time_taken > self.lock_warning_threshold / 1000:
+ console.warn(
+ f"Lock for token {token} was held too long {time_taken=}s, "
+ f"use `@rx.event(background=True)` decorator for long-running tasks.",
+ dedupe=True,
+ )
+
client_token, substate_name = _split_substate_key(token)
client_token = state._get_token()
@@ -2764,31 +3506,31 @@ class StateManagerRedis(StateManager):
)
# Recursively set_state on all known substates.
- tasks = []
- for substate in state.substates.values():
- tasks.append(
- asyncio.create_task(
- self.set_state(
- token=_substate_key(client_token, substate),
- state=substate,
- lock_id=lock_id,
- )
+ tasks = [
+ asyncio.create_task(
+ self.set_state(
+ _substate_key(client_token, substate),
+ substate,
+ lock_id,
)
)
+ for substate in state.substates.values()
+ ]
# Persist only the given state (parents or substates are excluded by BaseState.__getstate__).
if state._get_was_touched():
- pickle_state = dill.dumps(state, byref=True)
- self._warn_if_too_large(state, len(pickle_state))
- await self.redis.set(
- _substate_key(client_token, state),
- pickle_state,
- ex=self.token_expiration,
- )
+ pickle_state = state._serialize()
+ if pickle_state:
+ await self.redis.set(
+ _substate_key(client_token, state),
+ pickle_state,
+ ex=self.token_expiration,
+ )
# Wait for substates to be persisted.
for t in tasks:
await t
+ @override
@contextlib.asynccontextmanager
async def modify_state(self, token: str) -> AsyncIterator[BaseState]:
"""Modify the state for a token while holding exclusive lock.
@@ -2804,6 +3546,27 @@ class StateManagerRedis(StateManager):
yield state
await self.set_state(token, state, lock_id)
+ @validator("lock_warning_threshold")
+ @classmethod
+ def validate_lock_warning_threshold(cls, lock_warning_threshold: int, values):
+ """Validate the lock warning threshold.
+
+ Args:
+ lock_warning_threshold: The lock warning threshold.
+ values: The validated attributes.
+
+ Returns:
+ The lock warning threshold.
+
+ Raises:
+ InvalidLockWarningThresholdError: If the lock warning threshold is invalid.
+ """
+ if lock_warning_threshold >= (lock_expiration := values["lock_expiration"]):
+ raise InvalidLockWarningThresholdError(
+ f"The lock warning threshold({lock_warning_threshold}) must be less than the lock expiration time({lock_expiration})."
+ )
+ return lock_warning_threshold
+
@staticmethod
def _lock_key(token: str) -> bytes:
"""Get the redis key for a token's lock.
@@ -2835,6 +3598,35 @@ class StateManagerRedis(StateManager):
nx=True, # only set if it doesn't exist
)
+ async def _get_pubsub_message(
+ self, pubsub: PubSub, timeout: float | None = None
+ ) -> None:
+ """Get lock release events from the pubsub.
+
+ Args:
+ pubsub: The pubsub to get a message from.
+ timeout: Remaining time to wait for a message.
+
+ Returns:
+ The message.
+ """
+ if timeout is None:
+ timeout = self.lock_expiration / 1000.0
+
+ started = time.time()
+ message = await pubsub.get_message(
+ ignore_subscribe_messages=True,
+ timeout=timeout,
+ )
+ if (
+ message is None
+ or message["data"] not in self._redis_keyspace_lock_release_events
+ ):
+ remaining = timeout - (time.time() - started)
+ if remaining <= 0:
+ return
+ await self._get_pubsub_message(pubsub, timeout=remaining)
+
async def _wait_lock(self, lock_key: bytes, lock_id: bytes) -> None:
"""Wait for a redis lock to be released via pubsub.
@@ -2847,7 +3639,6 @@ class StateManagerRedis(StateManager):
Raises:
ResponseError: when the keyspace config cannot be set.
"""
- state_is_locked = False
lock_key_channel = f"__keyspace@0__:{lock_key.decode()}"
# Enable keyspace notifications for the lock key, so we know when it is available.
try:
@@ -2857,28 +3648,17 @@ class StateManagerRedis(StateManager):
)
except ResponseError:
# Some redis servers only allow out-of-band configuration, so ignore errors here.
- ignore_config_error = os.environ.get(
- "REFLEX_IGNORE_REDIS_CONFIG_ERROR",
- None,
- )
- if not ignore_config_error:
+ if not environment.REFLEX_IGNORE_REDIS_CONFIG_ERROR.get():
raise
async with self.redis.pubsub() as pubsub:
await pubsub.psubscribe(lock_key_channel)
- while not state_is_locked:
- # wait for the lock to be released
- while True:
- if not await self.redis.exists(lock_key):
- break # key was removed, try to get the lock again
- message = await pubsub.get_message(
- ignore_subscribe_messages=True,
- timeout=self.lock_expiration / 1000.0,
- )
- if message is None:
- continue
- if message["data"] in self._redis_keyspace_lock_release_events:
- break
- state_is_locked = await self._try_get_lock(lock_key, lock_id)
+ # wait for the lock to be released
+ while True:
+ # fast path
+ if await self._try_get_lock(lock_key, lock_id):
+ return
+ # wait for lock events
+ await self._get_pubsub_message(pubsub)
@contextlib.asynccontextmanager
async def _lock(self, token: str):
@@ -2933,181 +3713,50 @@ def get_state_manager() -> StateManager:
return app.state_manager
-class ClientStorageBase:
- """Base class for client-side storage."""
-
- def options(self) -> dict[str, Any]:
- """Get the options for the storage.
-
- Returns:
- All set options for the storage (not None).
- """
- return {
- format.to_camel_case(k): v for k, v in vars(self).items() if v is not None
- }
-
-
-class Cookie(ClientStorageBase, str):
- """Represents a state Var that is stored as a cookie in the browser."""
-
- name: str | None
- path: str
- max_age: int | None
- domain: str | None
- secure: bool | None
- same_site: str
-
- def __new__(
- cls,
- object: Any = "",
- encoding: str | None = None,
- errors: str | None = None,
- /,
- name: str | None = None,
- path: str = "/",
- max_age: int | None = None,
- domain: str | None = None,
- secure: bool | None = None,
- same_site: str = "lax",
- ):
- """Create a client-side Cookie (str).
-
- Args:
- object: The initial object.
- encoding: The encoding to use.
- errors: The error handling scheme to use.
- name: The name of the cookie on the client side.
- path: Cookie path. Use / as the path if the cookie should be accessible on all pages.
- max_age: Relative max age of the cookie in seconds from when the client receives it.
- domain: Domain for the cookie (sub.domain.com or .allsubdomains.com).
- secure: Is the cookie only accessible through HTTPS?
- same_site: Whether the cookie is sent with third party requests.
- One of (true|false|none|lax|strict)
-
- Returns:
- The client-side Cookie object.
-
- Note: expires (absolute Date) is not supported at this time.
- """
- if encoding or errors:
- inst = super().__new__(cls, object, encoding or "utf-8", errors or "strict")
- else:
- inst = super().__new__(cls, object)
- inst.name = name
- inst.path = path
- inst.max_age = max_age
- inst.domain = domain
- inst.secure = secure
- inst.same_site = same_site
- return inst
-
-
-class LocalStorage(ClientStorageBase, str):
- """Represents a state Var that is stored in localStorage in the browser."""
-
- name: str | None
- sync: bool = False
-
- def __new__(
- cls,
- object: Any = "",
- encoding: str | None = None,
- errors: str | None = None,
- /,
- name: str | None = None,
- sync: bool = False,
- ) -> "LocalStorage":
- """Create a client-side localStorage (str).
-
- Args:
- object: The initial object.
- encoding: The encoding to use.
- errors: The error handling scheme to use.
- name: The name of the storage key on the client side.
- sync: Whether changes should be propagated to other tabs.
-
- Returns:
- The client-side localStorage object.
- """
- if encoding or errors:
- inst = super().__new__(cls, object, encoding or "utf-8", errors or "strict")
- else:
- inst = super().__new__(cls, object)
- inst.name = name
- inst.sync = sync
- return inst
-
-
-class SessionStorage(ClientStorageBase, str):
- """Represents a state Var that is stored in sessionStorage in the browser."""
-
- name: str | None
-
- def __new__(
- cls,
- object: Any = "",
- encoding: str | None = None,
- errors: str | None = None,
- /,
- name: str | None = None,
- ) -> "SessionStorage":
- """Create a client-side sessionStorage (str).
-
- Args:
- object: The initial object.
- encoding: The encoding to use.
- errors: The error handling scheme to use
- name: The name of the storage on the client side
-
- Returns:
- The client-side sessionStorage object.
- """
- if encoding or errors:
- inst = super().__new__(cls, object, encoding or "utf-8", errors or "strict")
- else:
- inst = super().__new__(cls, object)
- inst.name = name
- return inst
-
-
class MutableProxy(wrapt.ObjectProxy):
"""A proxy for a mutable object that tracks changes."""
# Methods on wrapped objects which should mark the state as dirty.
- __mark_dirty_attrs__ = set(
- [
- "add",
- "append",
- "clear",
- "difference_update",
- "discard",
- "extend",
- "insert",
- "intersection_update",
- "pop",
- "popitem",
- "remove",
- "reverse",
- "setdefault",
- "sort",
- "symmetric_difference_update",
- "update",
- ]
- )
+ __mark_dirty_attrs__ = {
+ "add",
+ "append",
+ "clear",
+ "difference_update",
+ "discard",
+ "extend",
+ "insert",
+ "intersection_update",
+ "pop",
+ "popitem",
+ "remove",
+ "reverse",
+ "setdefault",
+ "sort",
+ "symmetric_difference_update",
+ "update",
+ }
+
# Methods on wrapped objects might return mutable objects that should be tracked.
- __wrap_mutable_attrs__ = set(
- [
- "get",
- "setdefault",
- ]
- )
+ __wrap_mutable_attrs__ = {
+ "get",
+ "setdefault",
+ }
# These internal attributes on rx.Base should NOT be wrapped in a MutableProxy.
__never_wrap_base_attrs__ = set(Base.__dict__) - {"set"} | set(
pydantic.BaseModel.__dict__
)
- __mutable_types__ = (list, dict, set, Base, DeclarativeBase)
+ # These types will be wrapped in MutableProxy
+ __mutable_types__ = (
+ list,
+ dict,
+ set,
+ Base,
+ DeclarativeBase,
+ BaseModelV2,
+ BaseModelV1,
+ )
def __init__(self, wrapped: Any, state: BaseState, field_name: str):
"""Create a proxy for a mutable object that tracks changes.
@@ -3122,11 +3771,19 @@ class MutableProxy(wrapt.ObjectProxy):
self._self_state = state
self._self_field_name = field_name
+ def __repr__(self) -> str:
+ """Get the representation of the wrapped object.
+
+ Returns:
+ The representation of the wrapped object.
+ """
+ return f"{type(self).__name__}({self.__wrapped__})"
+
def _mark_dirty(
self,
wrapped=None,
instance=None,
- args=tuple(),
+ args=(),
kwargs=None,
) -> Any:
"""Mark the state as dirty, then call a wrapped function.
@@ -3147,6 +3804,18 @@ class MutableProxy(wrapt.ObjectProxy):
if wrapped is not None:
return wrapped(*args, **(kwargs or {}))
+ @classmethod
+ def _is_mutable_type(cls, value: Any) -> bool:
+ """Check if a value is of a mutable type and should be wrapped.
+
+ Args:
+ value: The value to check.
+
+ Returns:
+ Whether the value is of a mutable type.
+ """
+ return isinstance(value, cls.__mutable_types__)
+
def _wrap_recursive(self, value: Any) -> Any:
"""Wrap a value recursively if it is mutable.
@@ -3157,9 +3826,7 @@ class MutableProxy(wrapt.ObjectProxy):
The wrapped value.
"""
# Recursively wrap mutable types, but do not re-wrap MutableProxy instances.
- if isinstance(value, self.__mutable_types__) and not isinstance(
- value, MutableProxy
- ):
+ if self._is_mutable_type(value) and not isinstance(value, MutableProxy):
return type(self)(
wrapped=value,
state=self._self_state,
@@ -3217,7 +3884,7 @@ class MutableProxy(wrapt.ObjectProxy):
self._wrap_recursive_decorator,
)
- if isinstance(value, self.__mutable_types__) and __name not in (
+ if self._is_mutable_type(value) and __name not in (
"__wrapped__",
"_self_state",
):
@@ -3326,22 +3993,39 @@ class MutableProxy(wrapt.ObjectProxy):
@serializer
-def serialize_mutable_proxy(mp: MutableProxy) -> SerializedType:
- """Serialize the wrapped value of a MutableProxy.
+def serialize_mutable_proxy(mp: MutableProxy):
+ """Return the wrapped value of a MutableProxy.
Args:
mp: The MutableProxy to serialize.
Returns:
- The serialized wrapped object.
-
- Raises:
- ValueError: when the wrapped object is not serializable.
+ The wrapped object.
"""
- value = serialize(mp.__wrapped__)
- if value is None:
- raise ValueError(f"Cannot serialize {type(mp.__wrapped__)}")
- return value
+ return mp.__wrapped__
+
+
+_orig_json_JSONEncoder_default = json.JSONEncoder.default
+
+
+def _json_JSONEncoder_default_wrapper(self: json.JSONEncoder, o: Any) -> Any:
+ """Wrap JSONEncoder.default to handle MutableProxy objects.
+
+ Args:
+ self: the JSONEncoder instance.
+ o: the object to serialize.
+
+ Returns:
+ A JSON-able object.
+ """
+ try:
+ return o.__wrapped__
+ except AttributeError:
+ pass
+ return _orig_json_JSONEncoder_default(self, o)
+
+
+json.JSONEncoder.default = _json_JSONEncoder_default_wrapper
class ImmutableMutableProxy(MutableProxy):
@@ -3355,7 +4039,7 @@ class ImmutableMutableProxy(MutableProxy):
self,
wrapped=None,
instance=None,
- args=tuple(),
+ args=(),
kwargs=None,
) -> Any:
"""Raise an exception when an attempt is made to modify the object.
@@ -3412,5 +4096,7 @@ def reload_state_module(
if subclass.__module__ == module and module is not None:
state.class_subclasses.remove(subclass)
state._always_dirty_substates.discard(subclass.get_name())
- state._init_var_dependency_dicts()
+ state._computed_var_dependencies = defaultdict(set)
+ state._substate_var_dependencies = defaultdict(set)
+ state._init_var_dependency_dicts()
state.get_class_substate.cache_clear()
diff --git a/reflex/style.py b/reflex/style.py
index 69e93ed39..a205cdc4a 100644
--- a/reflex/style.py
+++ b/reflex/style.py
@@ -6,12 +6,15 @@ from typing import Any, Literal, Tuple, Type
from reflex import constants
from reflex.components.core.breakpoints import Breakpoints, breakpoints_values
-from reflex.event import EventChain
+from reflex.event import EventChain, EventHandler
from reflex.utils import format
+from reflex.utils.exceptions import ReflexError
from reflex.utils.imports import ImportVar
-from reflex.vars import BaseVar, CallableVar, Var, VarData
-
-VarData.update_forward_refs() # Ensure all type definitions are resolved
+from reflex.utils.types import get_origin
+from reflex.vars import VarData
+from reflex.vars.base import CallableVar, LiteralVar, Var
+from reflex.vars.function import FunctionVar
+from reflex.vars.object import ObjectVar
SYSTEM_COLOR_MODE: str = "system"
LIGHT_COLOR_MODE: str = "light"
@@ -20,37 +23,35 @@ LiteralColorMode = Literal["system", "light", "dark"]
# Reference the global ColorModeContext
color_mode_imports = {
- f"/{constants.Dirs.CONTEXTS_PATH}": [ImportVar(tag="ColorModeContext")],
+ f"$/{constants.Dirs.CONTEXTS_PATH}": [ImportVar(tag="ColorModeContext")],
"react": [ImportVar(tag="useContext")],
}
-def _color_mode_var(_var_name: str, _var_type: Type = str) -> BaseVar:
- """Create a Var that destructs the _var_name from ColorModeContext.
+def _color_mode_var(_js_expr: str, _var_type: Type = str) -> Var:
+ """Create a Var that destructs the _js_expr from ColorModeContext.
Args:
- _var_name: The name of the variable to get from ColorModeContext.
+ _js_expr: The name of the variable to get from ColorModeContext.
_var_type: The type of the Var.
Returns:
- The BaseVar for accessing _var_name from ColorModeContext.
+ The Var that resolves to the color mode.
"""
- return BaseVar(
- _var_name=_var_name,
+ return Var(
+ _js_expr=_js_expr,
_var_type=_var_type,
- _var_is_local=False,
- _var_is_string=False,
_var_data=VarData(
imports=color_mode_imports,
- hooks={f"const {{ {_var_name} }} = useContext(ColorModeContext)": None},
+ hooks={f"const {{ {_js_expr} }} = useContext(ColorModeContext)": None},
),
- )
+ ).guess_type()
@CallableVar
def set_color_mode(
new_color_mode: LiteralColorMode | Var[LiteralColorMode] | None = None,
-) -> BaseVar[EventChain]:
+) -> Var[EventChain]:
"""Create an EventChain Var that sets the color mode to a specific value.
Note: `set_color_mode` is not a real event and cannot be triggered from a
@@ -63,27 +64,30 @@ def set_color_mode(
The EventChain Var that can be passed to an event trigger.
"""
base_setter = _color_mode_var(
- _var_name=constants.ColorMode.SET,
+ _js_expr=constants.ColorMode.SET,
_var_type=EventChain,
)
if new_color_mode is None:
return base_setter
if not isinstance(new_color_mode, Var):
- new_color_mode = Var.create_safe(new_color_mode, _var_is_string=True)
- return base_setter._replace(
- _var_name=f"() => {base_setter._var_name}({new_color_mode._var_name_unwrapped})",
- merge_var_data=new_color_mode._var_data,
- )
+ new_color_mode = LiteralVar.create(new_color_mode)
+
+ return Var(
+ f"() => {base_setter!s}({new_color_mode!s})",
+ _var_data=VarData.merge(
+ base_setter._get_all_var_data(), new_color_mode._get_all_var_data()
+ ),
+ ).to(FunctionVar, EventChain) # type: ignore
# Var resolves to the current color mode for the app ("light", "dark" or "system")
-color_mode = _color_mode_var(_var_name=constants.ColorMode.NAME)
+color_mode = _color_mode_var(_js_expr=constants.ColorMode.NAME)
# Var resolves to the resolved color mode for the app ("light" or "dark")
-resolved_color_mode = _color_mode_var(_var_name=constants.ColorMode.RESOLVED_NAME)
+resolved_color_mode = _color_mode_var(_js_expr=constants.ColorMode.RESOLVED_NAME)
# Var resolves to a function invocation that toggles the color mode
toggle_color_mode = _color_mode_var(
- _var_name=constants.ColorMode.TOGGLE,
+ _js_expr=constants.ColorMode.TOGGLE,
_var_type=EventChain,
)
@@ -111,7 +115,9 @@ def media_query(breakpoint_expr: str):
return f"@media screen and (min-width: {breakpoint_expr})"
-def convert_item(style_item: str | Var) -> tuple[str, VarData | None]:
+def convert_item(
+ style_item: int | str | Var,
+) -> tuple[str | Var, VarData | None]:
"""Format a single value in a style dictionary.
Args:
@@ -119,23 +125,28 @@ def convert_item(style_item: str | Var) -> tuple[str, VarData | None]:
Returns:
The formatted style item and any associated VarData.
+
+ Raises:
+ ReflexError: If an EventHandler is used as a style value
"""
+ if isinstance(style_item, EventHandler):
+ raise ReflexError(
+ "EventHandlers cannot be used as style values. "
+ "Please use a Var or a literal value."
+ )
+
if isinstance(style_item, Var):
- # If the value is a Var, extract the var_data and cast as str.
- return str(style_item), style_item._var_data
+ return style_item, style_item._get_all_var_data()
# Otherwise, convert to Var to collapse VarData encoded in f-string.
- new_var = Var.create(style_item, _var_is_string=False)
- if new_var is not None and new_var._var_data:
- # The wrapped backtick is used to identify the Var for interpolation.
- return f"`{str(new_var)}`", new_var._var_data
-
- return style_item, None
+ new_var = LiteralVar.create(style_item)
+ var_data = new_var._get_all_var_data() if new_var is not None else None
+ return new_var, var_data
def convert_list(
responsive_list: list[str | dict | Var],
-) -> tuple[list[str | dict], VarData | None]:
+) -> tuple[list[str | dict[str, Var | list | dict]], VarData | None]:
"""Format a responsive value list.
Args:
@@ -157,7 +168,9 @@ def convert_list(
return converted_value, VarData.merge(*item_var_datas)
-def convert(style_dict):
+def convert(
+ style_dict: dict[str, Var | dict | list | str],
+) -> tuple[dict[str, str | list | dict], VarData | None]:
"""Format a style dictionary.
Args:
@@ -174,8 +187,25 @@ def convert(style_dict):
out[k] = return_value
for key, value in style_dict.items():
- keys = format_style_key(key)
- if isinstance(value, dict):
+ keys = (
+ format_style_key(key)
+ if not isinstance(value, (dict, ObjectVar))
+ or (
+ isinstance(value, Breakpoints)
+ and all(not isinstance(v, dict) for v in value.values())
+ )
+ or (
+ isinstance(value, ObjectVar)
+ and not issubclass(get_origin(value._var_type) or value._var_type, dict)
+ )
+ else (key,)
+ )
+
+ if isinstance(value, Var):
+ return_val = value
+ new_var_data = value._get_all_var_data()
+ update_out_dict(return_val, keys)
+ elif isinstance(value, dict):
# Recursively format nested style dictionaries.
return_val, new_var_data = convert(value)
update_out_dict(return_val, keys)
@@ -254,10 +284,10 @@ class Style(dict):
value: The value to set.
"""
# Create a Var to collapse VarData encoded in f-string.
- _var = Var.create(value, _var_is_string=False)
+ _var = LiteralVar.create(value)
if _var is not None:
# Carry the imports/hooks when setting a Var as a value.
- self._var_data = VarData.merge(self._var_data, _var._var_data)
+ self._var_data = VarData.merge(self._var_data, _var._get_all_var_data())
super().__setitem__(key, value)
@@ -265,14 +295,13 @@ def _format_emotion_style_pseudo_selector(key: str) -> str:
"""Format a pseudo selector for emotion CSS-in-JS.
Args:
- key: Underscore-prefixed or colon-prefixed pseudo selector key (_hover).
+ key: Underscore-prefixed or colon-prefixed pseudo selector key (_hover/:hover).
Returns:
A self-referential pseudo selector key (&:hover).
"""
prefix = None
if key.startswith("_"):
- # Handle pseudo selectors in chakra style format.
prefix = "&:"
key = key[1:]
if key.startswith(":"):
diff --git a/reflex/testing.py b/reflex/testing.py
index c52396fc6..ca31054b3 100644
--- a/reflex/testing.py
+++ b/reflex/testing.py
@@ -8,7 +8,6 @@ import dataclasses
import functools
import inspect
import os
-import pathlib
import platform
import re
import signal
@@ -20,6 +19,7 @@ import threading
import time
import types
from http.server import SimpleHTTPRequestHandler
+from pathlib import Path
from typing import (
TYPE_CHECKING,
Any,
@@ -43,8 +43,11 @@ import reflex.utils.exec
import reflex.utils.format
import reflex.utils.prerequisites
import reflex.utils.processes
+from reflex.config import environment
from reflex.state import (
BaseState,
+ StateManager,
+ StateManagerDisk,
StateManagerMemory,
StateManagerRedis,
reload_state_module,
@@ -97,7 +100,7 @@ class chdir(contextlib.AbstractContextManager):
def __enter__(self):
"""Save current directory and perform chdir."""
- self._old_cwd.append(os.getcwd())
+ self._old_cwd.append(Path.cwd())
os.chdir(self.path)
def __exit__(self, *excinfo):
@@ -115,10 +118,10 @@ class AppHarness:
app_name: str
app_source: Optional[
- types.FunctionType | types.ModuleType | str | functools.partial[Any]
+ Callable[[], None] | types.ModuleType | str | functools.partial[Any]
]
- app_path: pathlib.Path
- app_module_path: pathlib.Path
+ app_path: Path
+ app_module_path: Path
app_module: Optional[types.ModuleType] = None
app_instance: Optional[reflex.App] = None
frontend_process: Optional[subprocess.Popen] = None
@@ -126,16 +129,16 @@ class AppHarness:
frontend_output_thread: Optional[threading.Thread] = None
backend_thread: Optional[threading.Thread] = None
backend: Optional[uvicorn.Server] = None
- state_manager: Optional[StateManagerMemory | StateManagerRedis] = None
+ state_manager: Optional[StateManager] = None
_frontends: list["WebDriver"] = dataclasses.field(default_factory=list)
_decorated_pages: list = dataclasses.field(default_factory=list)
@classmethod
def create(
cls,
- root: pathlib.Path,
+ root: Path,
app_source: Optional[
- types.FunctionType | types.ModuleType | str | functools.partial[Any]
+ Callable[[], None] | types.ModuleType | str | functools.partial[Any]
] = None,
app_name: Optional[str] = None,
) -> "AppHarness":
@@ -203,7 +206,7 @@ class AppHarness:
The full state name
"""
# NOTE: using State.get_name() somehow causes trouble here
- # path = [State.get_name()] + [self.get_state_name(p) for p in path]
+ # path = [State.get_name()] + [self.get_state_name(p) for p in path] # noqa: ERA001
path = ["reflex___state____state"] + [self.get_state_name(p) for p in path]
return ".".join(path)
@@ -247,7 +250,9 @@ class AppHarness:
return textwrap.dedent(source)
def _initialize_app(self):
- os.environ["TELEMETRY_ENABLED"] = "" # disable telemetry reporting for tests
+ # disable telemetry reporting for tests
+
+ os.environ["TELEMETRY_ENABLED"] = "false"
self.app_path.mkdir(parents=True, exist_ok=True)
if self.app_source is not None:
app_globals = self._get_globals_from_signature(self.app_source)
@@ -327,7 +332,8 @@ class AppHarness:
)
)
self.backend.shutdown = self._get_backend_shutdown_handler()
- self.backend_thread = threading.Thread(target=self.backend.run)
+ with chdir(self.app_path):
+ self.backend_thread = threading.Thread(target=self.backend.run)
self.backend_thread.start()
async def _reset_backend_state_manager(self):
@@ -335,6 +341,9 @@ class AppHarness:
This is necessary when the backend is restarted and the state manager is a
StateManagerRedis instance.
+
+ Raises:
+ RuntimeError: when the state manager cannot be reset
"""
if (
self.app_instance is not None
@@ -349,7 +358,8 @@ class AppHarness:
self.app_instance._state_manager = StateManagerRedis.create(
state=self.app_instance.state,
)
- assert isinstance(self.app_instance.state_manager, StateManagerRedis)
+ if not isinstance(self.app_instance.state_manager, StateManagerRedis):
+ raise RuntimeError("Failed to reset state manager.")
def _start_frontend(self):
# Set up the frontend.
@@ -387,9 +397,14 @@ class AppHarness:
def consume_frontend_output():
while True:
- line = (
- self.frontend_process.stdout.readline() # pyright: ignore [reportOptionalMemberAccess]
- )
+ try:
+ line = (
+ self.frontend_process.stdout.readline() # pyright: ignore [reportOptionalMemberAccess]
+ )
+ # catch I/O operation on closed file.
+ except ValueError as e:
+ print(e)
+ break
if not line:
break
print(line)
@@ -421,7 +436,6 @@ class AppHarness:
Returns:
The rendered app global code.
-
"""
if not inspect.isclass(value) and not inspect.isfunction(value):
return f"{key} = {value!r}"
@@ -602,10 +616,10 @@ class AppHarness:
if self.frontend_url is None:
raise RuntimeError("Frontend is not running.")
want_headless = False
- if os.environ.get("APP_HARNESS_HEADLESS"):
+ if environment.APP_HARNESS_HEADLESS.get():
want_headless = True
if driver_clz is None:
- requested_driver = os.environ.get("APP_HARNESS_DRIVER", "Chrome")
+ requested_driver = environment.APP_HARNESS_DRIVER.get()
driver_clz = getattr(webdriver, requested_driver)
if driver_options is None:
driver_options = getattr(webdriver, f"{requested_driver}Options")()
@@ -627,7 +641,7 @@ class AppHarness:
driver_options.add_argument("headless")
if driver_options is None:
raise RuntimeError(f"Could not determine options for {driver_clz}")
- if args := os.environ.get("APP_HARNESS_DRIVER_ARGS"):
+ if args := environment.APP_HARNESS_DRIVER_ARGS.get():
for arg in args.split(","):
driver_options.add_argument(arg)
if driver_option_args is not None:
@@ -782,13 +796,13 @@ class AppHarness:
Raises:
RuntimeError: when the app hasn't started running
TimeoutError: when the timeout expires before any states are seen
+ ValueError: when the state_manager is not a memory state manager
"""
if self.app_instance is None:
raise RuntimeError("App is not running.")
state_manager = self.app_instance.state_manager
- assert isinstance(
- state_manager, StateManagerMemory
- ), "Only works with memory state manager"
+ if not isinstance(state_manager, (StateManagerMemory, StateManagerDisk)):
+ raise ValueError("Only works with memory or disk state manager")
if not self._poll_for(
target=lambda: state_manager.states,
timeout=timeout,
@@ -800,7 +814,7 @@ class AppHarness:
class SimpleHTTPRequestHandlerCustomErrors(SimpleHTTPRequestHandler):
"""SimpleHTTPRequestHandler with custom error page handling."""
- def __init__(self, *args, error_page_map: dict[int, pathlib.Path], **kwargs):
+ def __init__(self, *args, error_page_map: dict[int, Path], **kwargs):
"""Initialize the handler.
Args:
@@ -843,8 +857,8 @@ class Subdir404TCPServer(socketserver.TCPServer):
def __init__(
self,
*args,
- root: pathlib.Path,
- error_page_map: dict[int, pathlib.Path] | None,
+ root: Path,
+ error_page_map: dict[int, Path] | None,
**kwargs,
):
"""Initialize the server.
@@ -864,7 +878,7 @@ class Subdir404TCPServer(socketserver.TCPServer):
Args:
request: the requesting socket
- client_address: (host, port) referring to the client’s address.
+ client_address: (host, port) referring to the client's address.
"""
self.RequestHandlerClass(
request,
@@ -931,7 +945,7 @@ class AppHarnessProd(AppHarness):
def _start_backend(self):
if self.app_instance is None:
raise RuntimeError("App was not initialized.")
- os.environ[reflex.constants.SKIP_COMPILE_ENV_VAR] = "yes"
+ environment.REFLEX_SKIP_COMPILE.set(True)
self.backend = uvicorn.Server(
uvicorn.Config(
app=self.app_instance,
@@ -948,7 +962,7 @@ class AppHarnessProd(AppHarness):
try:
return super()._poll_for_servers(timeout)
finally:
- os.environ.pop(reflex.constants.SKIP_COMPILE_ENV_VAR, None)
+ environment.REFLEX_SKIP_COMPILE.set(None)
def stop(self):
"""Stop the frontend python webserver."""
diff --git a/reflex/utils/build.py b/reflex/utils/build.py
index 7a67ec32e..e263374e1 100644
--- a/reflex/utils/build.py
+++ b/reflex/utils/build.py
@@ -23,18 +23,6 @@ def set_env_json():
)
-def set_os_env(**kwargs):
- """Set os environment variables.
-
- Args:
- kwargs: env key word args.
- """
- for key, value in kwargs.items():
- if not value:
- continue
- os.environ[key.upper()] = value
-
-
def generate_sitemap_config(deploy_url: str, export=False):
"""Generate the sitemap config file.
@@ -61,8 +49,8 @@ def generate_sitemap_config(deploy_url: str, export=False):
def _zip(
component_name: constants.ComponentName,
- target: str,
- root_dir: str,
+ target: str | Path,
+ root_dir: str | Path,
exclude_venv_dirs: bool,
upload_db_file: bool = False,
dirs_to_exclude: set[str] | None = None,
@@ -82,22 +70,22 @@ def _zip(
top_level_dirs_to_exclude: The top level directory names immediately under root_dir to exclude. Do not exclude folders by these names further in the sub-directories.
"""
+ target = Path(target)
+ root_dir = Path(root_dir)
dirs_to_exclude = dirs_to_exclude or set()
files_to_exclude = files_to_exclude or set()
files_to_zip: list[str] = []
# Traverse the root directory in a top-down manner. In this traversal order,
# we can modify the dirs list in-place to remove directories we don't want to include.
for root, dirs, files in os.walk(root_dir, topdown=True):
+ root = Path(root)
# Modify the dirs in-place so excluded and hidden directories are skipped in next traversal.
dirs[:] = [
d
for d in dirs
- if (basename := os.path.basename(os.path.normpath(d)))
- not in dirs_to_exclude
+ if (basename := Path(d).resolve().name) not in dirs_to_exclude
and not basename.startswith(".")
- and (
- not exclude_venv_dirs or not _looks_like_venv_dir(os.path.join(root, d))
- )
+ and (not exclude_venv_dirs or not _looks_like_venv_dir(root / d))
]
# If we are at the top level with root_dir, exclude the top level dirs.
if top_level_dirs_to_exclude and root == root_dir:
@@ -109,7 +97,7 @@ def _zip(
if not f.startswith(".") and (upload_db_file or not f.endswith(".db"))
]
files_to_zip += [
- os.path.join(root, file) for file in files if file not in files_to_exclude
+ str(root / file) for file in files if file not in files_to_exclude
]
# Create a progress bar for zipping the component.
@@ -126,13 +114,13 @@ def _zip(
for file in files_to_zip:
console.debug(f"{target}: {file}", progress=progress)
progress.advance(task)
- zipf.write(file, os.path.relpath(file, root_dir))
+ zipf.write(file, Path(file).relative_to(root_dir))
def zip_app(
frontend: bool = True,
backend: bool = True,
- zip_dest_dir: str = os.getcwd(),
+ zip_dest_dir: str | Path = Path.cwd(),
upload_db_file: bool = False,
):
"""Zip up the app.
@@ -143,6 +131,7 @@ def zip_app(
zip_dest_dir: The directory to export the zip file to.
upload_db_file: Whether to upload the database file.
"""
+ zip_dest_dir = Path(zip_dest_dir)
files_to_exclude = {
constants.ComponentName.FRONTEND.zip(),
constants.ComponentName.BACKEND.zip(),
@@ -151,8 +140,8 @@ def zip_app(
if frontend:
_zip(
component_name=constants.ComponentName.FRONTEND,
- target=os.path.join(zip_dest_dir, constants.ComponentName.FRONTEND.zip()),
- root_dir=str(prerequisites.get_web_dir() / constants.Dirs.STATIC),
+ target=zip_dest_dir / constants.ComponentName.FRONTEND.zip(),
+ root_dir=prerequisites.get_web_dir() / constants.Dirs.STATIC,
files_to_exclude=files_to_exclude,
exclude_venv_dirs=False,
)
@@ -160,8 +149,8 @@ def zip_app(
if backend:
_zip(
component_name=constants.ComponentName.BACKEND,
- target=os.path.join(zip_dest_dir, constants.ComponentName.BACKEND.zip()),
- root_dir=".",
+ target=zip_dest_dir / constants.ComponentName.BACKEND.zip(),
+ root_dir=Path.cwd(),
dirs_to_exclude={"__pycache__"},
files_to_exclude=files_to_exclude,
top_level_dirs_to_exclude={"assets"},
@@ -236,6 +225,9 @@ def setup_frontend(
# Set the environment variables in client (env.json).
set_env_json()
+ # update the last reflex run time.
+ prerequisites.set_last_reflex_run_time()
+
# Disable the Next telemetry.
if disable_telemetry:
processes.new_process(
@@ -266,5 +258,6 @@ def setup_frontend_prod(
build(deploy_url=get_config().deploy_url)
-def _looks_like_venv_dir(dir_to_check: str) -> bool:
- return os.path.exists(os.path.join(dir_to_check, "pyvenv.cfg"))
+def _looks_like_venv_dir(dir_to_check: str | Path) -> bool:
+ dir_to_check = Path(dir_to_check)
+ return (dir_to_check / "pyvenv.cfg").exists()
diff --git a/reflex/utils/compat.py b/reflex/utils/compat.py
index ef5fcd3e1..e63492a6b 100644
--- a/reflex/utils/compat.py
+++ b/reflex/utils/compat.py
@@ -19,10 +19,13 @@ async def windows_hot_reload_lifespan_hack():
import asyncio
import sys
- while True:
- sys.stderr.write("\0")
- sys.stderr.flush()
- await asyncio.sleep(0.5)
+ try:
+ while True:
+ sys.stderr.write("\0")
+ sys.stderr.flush()
+ await asyncio.sleep(0.5)
+ except asyncio.CancelledError:
+ pass
@contextlib.contextmanager
@@ -69,3 +72,19 @@ def pydantic_v1_patch():
with pydantic_v1_patch():
import sqlmodel as sqlmodel
+
+
+def sqlmodel_field_has_primary_key(field) -> bool:
+ """Determines if a field is a priamary.
+
+ Args:
+ field: a rx.model field
+
+ Returns:
+ If field is a primary key (Bool)
+ """
+ if getattr(field.field_info, "primary_key", None) is True:
+ return True
+ if getattr(field.field_info, "sa_column", None) is None:
+ return False
+ return bool(getattr(field.field_info.sa_column, "primary_key", None))
diff --git a/reflex/utils/console.py b/reflex/utils/console.py
index 69500b32f..be545140a 100644
--- a/reflex/utils/console.py
+++ b/reflex/utils/console.py
@@ -20,13 +20,46 @@ _EMITTED_DEPRECATION_WARNINGS = set()
# Info messages which have been printed.
_EMITTED_INFO = set()
+# Warnings which have been printed.
+_EMIITED_WARNINGS = set()
+
+# Errors which have been printed.
+_EMITTED_ERRORS = set()
+
+# Success messages which have been printed.
+_EMITTED_SUCCESS = set()
+
+# Debug messages which have been printed.
+_EMITTED_DEBUG = set()
+
+# Logs which have been printed.
+_EMITTED_LOGS = set()
+
+# Prints which have been printed.
+_EMITTED_PRINTS = set()
+
def set_log_level(log_level: LogLevel):
"""Set the log level.
Args:
log_level: The log level to set.
+
+ Raises:
+ ValueError: If the log level is invalid.
"""
+ if not isinstance(log_level, LogLevel):
+ deprecate(
+ feature_name="Passing a string to set_log_level",
+ reason="use reflex.constants.LogLevel enum instead",
+ deprecation_version="0.6.6",
+ removal_version="0.7.0",
+ )
+ try:
+ log_level = getattr(LogLevel, log_level.upper())
+ except AttributeError as ae:
+ raise ValueError(f"Invalid log level: {log_level}") from ae
+
global _LOG_LEVEL
_LOG_LEVEL = log_level
@@ -40,25 +73,37 @@ def is_debug() -> bool:
return _LOG_LEVEL <= LogLevel.DEBUG
-def print(msg: str, **kwargs):
+def print(msg: str, dedupe: bool = False, **kwargs):
"""Print a message.
Args:
msg: The message to print.
+ dedupe: If True, suppress multiple console logs of print message.
kwargs: Keyword arguments to pass to the print function.
"""
+ if dedupe:
+ if msg in _EMITTED_PRINTS:
+ return
+ else:
+ _EMITTED_PRINTS.add(msg)
_console.print(msg, **kwargs)
-def debug(msg: str, **kwargs):
+def debug(msg: str, dedupe: bool = False, **kwargs):
"""Print a debug message.
Args:
msg: The debug message.
+ dedupe: If True, suppress multiple console logs of debug message.
kwargs: Keyword arguments to pass to the print function.
"""
if is_debug():
- msg_ = f"[blue]Debug: {msg}[/blue]"
+ msg_ = f"[purple]Debug: {msg}[/purple]"
+ if dedupe:
+ if msg_ in _EMITTED_DEBUG:
+ return
+ else:
+ _EMITTED_DEBUG.add(msg_)
if progress := kwargs.pop("progress", None):
progress.console.print(msg_, **kwargs)
else:
@@ -82,25 +127,37 @@ def info(msg: str, dedupe: bool = False, **kwargs):
print(f"[cyan]Info: {msg}[/cyan]", **kwargs)
-def success(msg: str, **kwargs):
+def success(msg: str, dedupe: bool = False, **kwargs):
"""Print a success message.
Args:
msg: The success message.
+ dedupe: If True, suppress multiple console logs of success message.
kwargs: Keyword arguments to pass to the print function.
"""
if _LOG_LEVEL <= LogLevel.INFO:
+ if dedupe:
+ if msg in _EMITTED_SUCCESS:
+ return
+ else:
+ _EMITTED_SUCCESS.add(msg)
print(f"[green]Success: {msg}[/green]", **kwargs)
-def log(msg: str, **kwargs):
+def log(msg: str, dedupe: bool = False, **kwargs):
"""Takes a string and logs it to the console.
Args:
msg: The message to log.
+ dedupe: If True, suppress multiple console logs of log message.
kwargs: Keyword arguments to pass to the print function.
"""
if _LOG_LEVEL <= LogLevel.INFO:
+ if dedupe:
+ if msg in _EMITTED_LOGS:
+ return
+ else:
+ _EMITTED_LOGS.add(msg)
_console.log(msg, **kwargs)
@@ -114,14 +171,20 @@ def rule(title: str, **kwargs):
_console.rule(title, **kwargs)
-def warn(msg: str, **kwargs):
+def warn(msg: str, dedupe: bool = False, **kwargs):
"""Print a warning message.
Args:
msg: The warning message.
+ dedupe: If True, suppress multiple console logs of warning message.
kwargs: Keyword arguments to pass to the print function.
"""
if _LOG_LEVEL <= LogLevel.WARNING:
+ if dedupe:
+ if msg in _EMIITED_WARNINGS:
+ return
+ else:
+ _EMIITED_WARNINGS.add(msg)
print(f"[orange1]Warning: {msg}[/orange1]", **kwargs)
@@ -154,14 +217,20 @@ def deprecate(
_EMITTED_DEPRECATION_WARNINGS.add(feature_name)
-def error(msg: str, **kwargs):
+def error(msg: str, dedupe: bool = False, **kwargs):
"""Print an error message.
Args:
msg: The error message.
+ dedupe: If True, suppress multiple console logs of error message.
kwargs: Keyword arguments to pass to the print function.
"""
if _LOG_LEVEL <= LogLevel.ERROR:
+ if dedupe:
+ if msg in _EMITTED_ERRORS:
+ return
+ else:
+ _EMITTED_ERRORS.add(msg)
print(f"[red]{msg}[/red]", **kwargs)
@@ -191,7 +260,6 @@ def ask(
def progress():
"""Create a new progress bar.
-
Returns:
A new progress bar.
"""
diff --git a/reflex/utils/exceptions.py b/reflex/utils/exceptions.py
index d219dcf0c..ae5ec0168 100644
--- a/reflex/utils/exceptions.py
+++ b/reflex/utils/exceptions.py
@@ -1,10 +1,20 @@
"""Custom Exceptions."""
+from typing import NoReturn
+
class ReflexError(Exception):
"""Base exception for all Reflex exceptions."""
+class ConfigError(ReflexError):
+ """Custom exception for config related errors."""
+
+
+class InvalidStateManagerMode(ReflexError, ValueError):
+ """Raised when an invalid state manager mode is provided."""
+
+
class ReflexRuntimeError(ReflexError, RuntimeError):
"""Custom RuntimeError for Reflex."""
@@ -53,6 +63,10 @@ class UploadValueError(ReflexError, ValueError):
"""Custom ValueError for upload related errors."""
+class PageValueError(ReflexError, ValueError):
+ """Custom ValueError for page related errors."""
+
+
class RouteValueError(ReflexError, ValueError):
"""Custom ValueError for route related errors."""
@@ -79,3 +93,97 @@ class LockExpiredError(ReflexError):
class MatchTypeError(ReflexError, TypeError):
"""Raised when the return types of match cases are different."""
+
+
+class EventHandlerArgTypeMismatch(ReflexError, TypeError):
+ """Raised when the annotations of args accepted by an EventHandler differs from the spec of the event trigger."""
+
+
+class EventFnArgMismatch(ReflexError, TypeError):
+ """Raised when the number of args required by an event handler is more than provided by the event trigger."""
+
+
+class DynamicRouteArgShadowsStateVar(ReflexError, NameError):
+ """Raised when a dynamic route arg shadows a state var."""
+
+
+class ComputedVarShadowsStateVar(ReflexError, NameError):
+ """Raised when a computed var shadows a state var."""
+
+
+class ComputedVarShadowsBaseVars(ReflexError, NameError):
+ """Raised when a computed var shadows a base var."""
+
+
+class EventHandlerShadowsBuiltInStateMethod(ReflexError, NameError):
+ """Raised when an event handler shadows a built-in state method."""
+
+
+class GeneratedCodeHasNoFunctionDefs(ReflexError):
+ """Raised when refactored code generated with flexgen has no functions defined."""
+
+
+class PrimitiveUnserializableToJSON(ReflexError, ValueError):
+ """Raised when a primitive type is unserializable to JSON. Usually with NaN and Infinity."""
+
+
+class InvalidLifespanTaskType(ReflexError, TypeError):
+ """Raised when an invalid task type is registered as a lifespan task."""
+
+
+class DynamicComponentMissingLibrary(ReflexError, ValueError):
+ """Raised when a dynamic component is missing a library."""
+
+
+class SetUndefinedStateVarError(ReflexError, AttributeError):
+ """Raised when setting the value of a var without first declaring it."""
+
+
+class StateSchemaMismatchError(ReflexError, TypeError):
+ """Raised when the serialized schema of a state class does not match the current schema."""
+
+
+class EnvironmentVarValueError(ReflexError, ValueError):
+ """Raised when an environment variable is set to an invalid value."""
+
+
+class DynamicComponentInvalidSignature(ReflexError, TypeError):
+ """Raised when a dynamic component has an invalid signature."""
+
+
+class InvalidPropValueError(ReflexError):
+ """Raised when a prop value is invalid."""
+
+
+class StateTooLargeError(ReflexError):
+ """Raised when the state is too large to be serialized."""
+
+
+class StateSerializationError(ReflexError):
+ """Raised when the state cannot be serialized."""
+
+
+class SystemPackageMissingError(ReflexError):
+ """Raised when a system package is missing."""
+
+
+def raise_system_package_missing_error(package: str) -> NoReturn:
+ """Raise a SystemPackageMissingError.
+
+ Args:
+ package: The name of the missing system package.
+
+ Raises:
+ SystemPackageMissingError: The raised exception.
+ """
+ from reflex.constants import IS_MACOS
+
+ raise SystemPackageMissingError(
+ f"System package '{package}' is missing."
+ " Please install it through your system package manager."
+ + (f" You can do so by running 'brew install {package}'." if IS_MACOS else "")
+ )
+
+
+class InvalidLockWarningThresholdError(ReflexError):
+ """Raised when an invalid lock warning threshold is provided."""
diff --git a/reflex/utils/exec.py b/reflex/utils/exec.py
index 77df98116..621c4a608 100644
--- a/reflex/utils/exec.py
+++ b/reflex/utils/exec.py
@@ -15,26 +15,16 @@ from urllib.parse import urljoin
import psutil
from reflex import constants
-from reflex.config import get_config
+from reflex.config import environment, get_config
+from reflex.constants.base import LogLevel
from reflex.utils import console, path_ops
from reflex.utils.prerequisites import get_web_dir
-from reflex.utils.watch import AssetFolderWatch
# For uvicorn windows bug fix (#2335)
frontend_process = None
-def start_watching_assets_folder(root):
- """Start watching assets folder.
-
- Args:
- root: root path of the project.
- """
- asset_watch = AssetFolderWatch(root)
- asset_watch.start()
-
-
-def detect_package_change(json_file_path: str) -> str:
+def detect_package_change(json_file_path: Path) -> str:
"""Calculates the SHA-256 hash of a JSON file and returns it as a hexadecimal string.
Args:
@@ -47,7 +37,7 @@ def detect_package_change(json_file_path: str) -> str:
>>> detect_package_change("package.json")
'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2'
"""
- with open(json_file_path, "r") as file:
+ with json_file_path.open("r") as file:
json_data = json.load(file)
# Calculate the hash
@@ -71,6 +61,13 @@ def kill(proc_pid: int):
process.kill()
+def notify_backend():
+ """Output a string notifying where the backend is running."""
+ console.print(
+ f"Backend running at: [bold green]http://0.0.0.0:{get_config().backend_port}[/bold green]"
+ )
+
+
# run_process_and_launch_url is assumed to be used
# only to launch the frontend
# If this is not the case, might have to change the logic
@@ -84,7 +81,7 @@ def run_process_and_launch_url(run_command: list[str], backend_present=True):
from reflex.utils import processes
json_file_path = get_web_dir() / constants.PackageJson.PATH
- last_hash = detect_package_change(str(json_file_path))
+ last_hash = detect_package_change(json_file_path)
process = None
first_run = True
@@ -114,22 +111,20 @@ def run_process_and_launch_url(run_command: list[str], backend_present=True):
f"App running at: [bold green]{url}[/bold green]{' (Frontend-only mode)' if not backend_present else ''}"
)
if backend_present:
- console.print(
- f"Backend running at: [bold green]http://0.0.0.0:{get_config().backend_port}[/bold green]"
- )
+ notify_backend()
first_run = False
else:
console.print("New packages detected: Updating app...")
else:
if any(
- [x in line for x in ("bin executable does not exist on disk",)]
+ x in line for x in ("bin executable does not exist on disk",)
):
console.error(
"Try setting `REFLEX_USE_NPM=1` and re-running `reflex init` and `reflex run` to use npm instead of bun:\n"
"`REFLEX_USE_NPM=1 reflex init`\n"
"`REFLEX_USE_NPM=1 reflex run`"
)
- new_hash = detect_package_change(str(json_file_path))
+ new_hash = detect_package_change(json_file_path)
if new_hash != last_hash:
last_hash = new_hash
kill(process.pid)
@@ -149,8 +144,6 @@ def run_frontend(root: Path, port: str, backend_present=True):
"""
from reflex.utils import prerequisites
- # Start watching asset folder.
- start_watching_assets_folder(root)
# validate dependencies before run
prerequisites.validate_frontend_dependencies(init=False)
@@ -185,13 +178,71 @@ def run_frontend_prod(root: Path, port: str, backend_present=True):
)
+def should_use_granian():
+ """Whether to use Granian for backend.
+
+ Returns:
+ True if Granian should be used.
+ """
+ return environment.REFLEX_USE_GRANIAN.get()
+
+
+def get_app_module():
+ """Get the app module for the backend.
+
+ Returns:
+ The app module for the backend.
+ """
+ return f"reflex.app_module_for_backend:{constants.CompileVars.APP}"
+
+
+def get_granian_target():
+ """Get the Granian target for the backend.
+
+ Returns:
+ The Granian target for the backend.
+ """
+ import reflex
+
+ app_module_path = Path(reflex.__file__).parent / "app_module_for_backend.py"
+
+ return (
+ f"{app_module_path!s}:{constants.CompileVars.APP}.{constants.CompileVars.API}"
+ )
+
+
def run_backend(
host: str,
port: int,
loglevel: constants.LogLevel = constants.LogLevel.ERROR,
+ frontend_present: bool = False,
):
"""Run the backend.
+ Args:
+ host: The app host
+ port: The app port
+ loglevel: The log level.
+ frontend_present: Whether the frontend is present.
+ """
+ web_dir = get_web_dir()
+ # Create a .nocompile file to skip compile for backend.
+ if web_dir.exists():
+ (web_dir / constants.NOCOMPILE_FILE).touch()
+
+ if not frontend_present:
+ notify_backend()
+
+ # Run the backend in development mode.
+ if should_use_granian():
+ run_granian_backend(host, port, loglevel)
+ else:
+ run_uvicorn_backend(host, port, loglevel)
+
+
+def run_uvicorn_backend(host, port, loglevel: LogLevel):
+ """Run the backend in development mode using Uvicorn.
+
Args:
host: The app host
port: The app port
@@ -199,23 +250,55 @@ def run_backend(
"""
import uvicorn
- config = get_config()
- app_module = f"reflex.app_module_for_backend:{constants.CompileVars.APP}"
-
- web_dir = get_web_dir()
- # Create a .nocompile file to skip compile for backend.
- if web_dir.exists():
- (web_dir / constants.NOCOMPILE_FILE).touch()
-
- # Run the backend in development mode.
uvicorn.run(
- app=f"{app_module}.{constants.CompileVars.API}",
+ app=f"{get_app_module()}.{constants.CompileVars.API}",
host=host,
port=port,
log_level=loglevel.value,
reload=True,
- reload_dirs=[config.app_name],
- reload_excludes=[str(web_dir)],
+ reload_dirs=[get_config().app_name],
+ )
+
+
+def run_granian_backend(host, port, loglevel: LogLevel):
+ """Run the backend in development mode using Granian.
+
+ Args:
+ host: The app host
+ port: The app port
+ loglevel: The log level.
+ """
+ console.debug("Using Granian for backend")
+ try:
+ from granian import Granian # type: ignore
+ from granian.constants import Interfaces # type: ignore
+ from granian.log import LogLevels # type: ignore
+
+ Granian(
+ target=get_granian_target(),
+ address=host,
+ port=port,
+ interface=Interfaces.ASGI,
+ log_level=LogLevels(loglevel.value),
+ reload=True,
+ reload_paths=[Path(get_config().app_name)],
+ reload_ignore_dirs=[".web"],
+ ).serve()
+ except ImportError:
+ console.error(
+ 'InstallError: REFLEX_USE_GRANIAN is set but `granian` is not installed. (run `pip install "granian[reload]>=1.6.0"`)'
+ )
+ os._exit(1)
+
+
+def _get_backend_workers():
+ from reflex.utils import processes
+
+ config = get_config()
+ return (
+ processes.get_num_workers()
+ if not config.gunicorn_workers
+ else config.gunicorn_workers
)
@@ -223,9 +306,28 @@ def run_backend_prod(
host: str,
port: int,
loglevel: constants.LogLevel = constants.LogLevel.ERROR,
+ frontend_present: bool = False,
):
"""Run the backend.
+ Args:
+ host: The app host
+ port: The app port
+ loglevel: The log level.
+ frontend_present: Whether the frontend is present.
+ """
+ if not frontend_present:
+ notify_backend()
+
+ if should_use_granian():
+ run_granian_backend_prod(host, port, loglevel)
+ else:
+ run_uvicorn_backend_prod(host, port, loglevel)
+
+
+def run_uvicorn_backend_prod(host, port, loglevel):
+ """Run the backend in production mode using Uvicorn.
+
Args:
host: The app host
port: The app port
@@ -234,14 +336,11 @@ def run_backend_prod(
from reflex.utils import processes
config = get_config()
- num_workers = (
- processes.get_num_workers()
- if not config.gunicorn_workers
- else config.gunicorn_workers
- )
- RUN_BACKEND_PROD = f"gunicorn --worker-class {config.gunicorn_worker_class} --preload --timeout {config.timeout} --log-level critical".split()
- RUN_BACKEND_PROD_WINDOWS = f"uvicorn --timeout-keep-alive {config.timeout}".split()
- app_module = f"reflex.app_module_for_backend:{constants.CompileVars.APP}"
+
+ app_module = get_app_module()
+
+ RUN_BACKEND_PROD = f"gunicorn --worker-class {config.gunicorn_worker_class} --max-requests {config.gunicorn_max_requests} --max-requests-jitter {config.gunicorn_max_requests_jitter} --preload --timeout {config.timeout} --log-level critical".split()
+ RUN_BACKEND_PROD_WINDOWS = f"uvicorn --limit-max-requests {config.gunicorn_max_requests} --timeout-keep-alive {config.timeout}".split()
command = (
[
*RUN_BACKEND_PROD_WINDOWS,
@@ -257,7 +356,7 @@ def run_backend_prod(
"--bind",
f"{host}:{port}",
"--threads",
- str(num_workers),
+ str(_get_backend_workers()),
f"{app_module}()",
]
)
@@ -266,16 +365,59 @@ def run_backend_prod(
"--log-level",
loglevel.value,
"--workers",
- str(num_workers),
+ str(_get_backend_workers()),
]
processes.new_process(
command,
run=True,
show_logs=True,
- env={constants.SKIP_COMPILE_ENV_VAR: "yes"}, # skip compile for prod backend
+ env={
+ environment.REFLEX_SKIP_COMPILE.name: "true"
+ }, # skip compile for prod backend
)
+def run_granian_backend_prod(host, port, loglevel):
+ """Run the backend in production mode using Granian.
+
+ Args:
+ host: The app host
+ port: The app port
+ loglevel: The log level.
+ """
+ from reflex.utils import processes
+
+ try:
+ from granian.constants import Interfaces # type: ignore
+
+ command = [
+ "granian",
+ "--workers",
+ str(_get_backend_workers()),
+ "--log-level",
+ "critical",
+ "--host",
+ host,
+ "--port",
+ str(port),
+ "--interface",
+ str(Interfaces.ASGI),
+ get_granian_target(),
+ ]
+ processes.new_process(
+ command,
+ run=True,
+ show_logs=True,
+ env={
+ environment.REFLEX_SKIP_COMPILE.name: "true"
+ }, # skip compile for prod backend
+ )
+ except ImportError:
+ console.error(
+ 'InstallError: REFLEX_USE_GRANIAN is set but `granian` is not installed. (run `pip install "granian[reload]>=1.6.0"`)'
+ )
+
+
def output_system_info():
"""Show system information if the loglevel is in DEBUG."""
if console._LOG_LEVEL > constants.LogLevel.DEBUG:
@@ -289,7 +431,7 @@ def output_system_info():
except Exception:
config_file = None
- console.rule(f"System Info")
+ console.rule("System Info")
console.debug(f"Config file: {config_file!r}")
console.debug(f"Config: {config}")
@@ -300,10 +442,8 @@ def output_system_info():
system = platform.system()
- if (
- system != "Windows"
- or system == "Windows"
- and prerequisites.is_windows_bun_supported()
+ if system != "Windows" or (
+ system == "Windows" and prerequisites.is_windows_bun_supported()
):
dependencies.extend(
[
@@ -329,9 +469,11 @@ def output_system_info():
console.debug(f"{dep}")
console.debug(
- f"Using package installer at: {prerequisites.get_install_package_manager()}" # type: ignore
+ f"Using package installer at: {prerequisites.get_install_package_manager(on_failure_return_none=True)}" # type: ignore
)
- console.debug(f"Using package executer at: {prerequisites.get_package_manager()}") # type: ignore
+ console.debug(
+ f"Using package executer at: {prerequisites.get_package_manager(on_failure_return_none=True)}"
+ ) # type: ignore
if system != "Windows":
console.debug(f"Unzip path: {path_ops.which('unzip')}")
@@ -351,11 +493,38 @@ def is_prod_mode() -> bool:
Returns:
True if the app is running in production mode or False if running in dev mode.
"""
- current_mode = os.environ.get(
- constants.ENV_MODE_ENV_VAR,
- constants.Env.DEV.value,
+ current_mode = environment.REFLEX_ENV_MODE.get()
+ return current_mode == constants.Env.PROD
+
+
+def is_frontend_only() -> bool:
+ """Check if the app is running in frontend-only mode.
+
+ Returns:
+ True if the app is running in frontend-only mode.
+ """
+ console.deprecate(
+ "is_frontend_only() is deprecated and will be removed in a future release.",
+ reason="Use `environment.REFLEX_FRONTEND_ONLY.get()` instead.",
+ deprecation_version="0.6.5",
+ removal_version="0.7.0",
)
- return current_mode == constants.Env.PROD.value
+ return environment.REFLEX_FRONTEND_ONLY.get()
+
+
+def is_backend_only() -> bool:
+ """Check if the app is running in backend-only mode.
+
+ Returns:
+ True if the app is running in backend-only mode.
+ """
+ console.deprecate(
+ "is_backend_only() is deprecated and will be removed in a future release.",
+ reason="Use `environment.REFLEX_BACKEND_ONLY.get()` instead.",
+ deprecation_version="0.6.5",
+ removal_version="0.7.0",
+ )
+ return environment.REFLEX_BACKEND_ONLY.get()
def should_skip_compile() -> bool:
@@ -364,4 +533,10 @@ def should_skip_compile() -> bool:
Returns:
True if the app should skip compile.
"""
- return os.environ.get(constants.SKIP_COMPILE_ENV_VAR) == "yes"
+ console.deprecate(
+ "should_skip_compile() is deprecated and will be removed in a future release.",
+ reason="Use `environment.REFLEX_SKIP_COMPILE.get()` instead.",
+ deprecation_version="0.6.5",
+ removal_version="0.7.0",
+ )
+ return environment.REFLEX_SKIP_COMPILE.get()
diff --git a/reflex/utils/export.py b/reflex/utils/export.py
index 31ac0d0b5..2fbf633f6 100644
--- a/reflex/utils/export.py
+++ b/reflex/utils/export.py
@@ -1,6 +1,5 @@
"""Export utilities."""
-import os
from pathlib import Path
from typing import Optional
@@ -15,7 +14,7 @@ def export(
zipping: bool = True,
frontend: bool = True,
backend: bool = True,
- zip_dest_dir: str = os.getcwd(),
+ zip_dest_dir: str = str(Path.cwd()),
upload_db_file: bool = False,
api_url: Optional[str] = None,
deploy_url: Optional[str] = None,
diff --git a/reflex/utils/format.py b/reflex/utils/format.py
index 59bbbd91c..1d6671a0b 100644
--- a/reflex/utils/format.py
+++ b/reflex/utils/format.py
@@ -6,15 +6,16 @@ import inspect
import json
import os
import re
-from typing import TYPE_CHECKING, Any, Callable, List, Optional, Union
+from typing import TYPE_CHECKING, Any, List, Optional, Union
from reflex import constants
-from reflex.utils import exceptions, types
-from reflex.vars import BaseVar, Var
+from reflex.constants.state import FRONTEND_EVENT_STATE
+from reflex.utils import exceptions
+from reflex.utils.console import deprecate
if TYPE_CHECKING:
from reflex.components.component import ComponentStyle
- from reflex.event import ArgsSpec, EventChain, EventHandler, EventSpec
+ from reflex.event import ArgsSpec, EventChain, EventHandler, EventSpec, EventType
WRAP_MAP = {
"{": "}",
@@ -197,8 +198,16 @@ def make_default_page_title(app_name: str, route: str) -> str:
Returns:
The default page title.
"""
- title = constants.DefaultPage.TITLE.format(app_name, route)
- return to_title_case(title, " ")
+ route_parts = [
+ part
+ for part in route.split("/")
+ if part and not (part.startswith("[") and part.endswith("]"))
+ ]
+
+ title = constants.DefaultPage.TITLE.format(
+ app_name, route_parts[-1] if route_parts else constants.PageNames.INDEX_ROUTE
+ )
+ return to_title_case(title)
def _escape_js_string(string: str) -> str:
@@ -263,32 +272,6 @@ def format_string(string: str) -> str:
return _wrap_js_string(_escape_js_string(string))
-def format_f_string_prop(prop: BaseVar) -> str:
- """Format the string in a given prop as an f-string.
-
- Args:
- prop: The prop to format.
-
- Returns:
- The formatted string.
- """
- s = prop._var_full_name
- var_data = prop._var_data
- interps = var_data.interpolations if var_data else []
- parts: List[str] = []
-
- if interps:
- for i, (start, end) in enumerate(interps):
- prev_end = interps[i - 1][1] if i > 0 else 0
- parts.append(_escape_js_string(s[prev_end:start]))
- parts.append(s[start:end])
- parts.append(_escape_js_string(s[interps[-1][1] :]))
- else:
- parts.append(_escape_js_string(s))
-
- return _wrap_js_string("".join(parts))
-
-
def format_var(var: Var) -> str:
"""Format the given Var as a javascript value.
@@ -298,13 +281,7 @@ def format_var(var: Var) -> str:
Returns:
The formatted Var.
"""
- if not var._var_is_local or var._var_is_string:
- return str(var)
- if types._issubclass(var._var_type, str):
- return format_string(var._var_full_name)
- if is_wrapped(var._var_full_name, "{"):
- return var._var_full_name
- return json_dumps(var._var_full_name)
+ return str(var)
def format_route(route: str, format_case=True) -> str:
@@ -329,46 +306,11 @@ def format_route(route: str, format_case=True) -> str:
return route
-def format_cond(
+def format_match(
cond: str | Var,
- true_value: str | Var,
- false_value: str | Var = '""',
- is_prop=False,
+ match_cases: List[List[Var]],
+ default: Var,
) -> str:
- """Format a conditional expression.
-
- Args:
- cond: The cond.
- true_value: The value to return if the cond is true.
- false_value: The value to return if the cond is false.
- is_prop: Whether the cond is a prop
-
- Returns:
- The formatted conditional expression.
- """
- # Use Python truthiness.
- cond = f"isTrue({cond})"
-
- def create_var(cond_part):
- return Var.create_safe(cond_part, _var_is_string=isinstance(cond_part, str))
-
- # Format prop conds.
- if is_prop:
- true_value = create_var(true_value)
- prop1 = true_value._replace(
- _var_is_local=True,
- )
-
- false_value = create_var(false_value)
- prop2 = false_value._replace(_var_is_local=True)
- # unwrap '{}' to avoid f-string semantics for Var
- return f"{cond} ? {prop1._var_name_unwrapped} : {prop2._var_name_unwrapped}"
-
- # Format component conds.
- return wrap(f"{cond} ? {true_value} : {false_value}", "{")
-
-
-def format_match(cond: str | Var, match_cases: List[BaseVar], default: Var) -> str:
"""Format a match expression whose return type is a Var.
Args:
@@ -387,17 +329,12 @@ def format_match(cond: str | Var, match_cases: List[BaseVar], default: Var) -> s
return_value = case[-1]
case_conditions = " ".join(
- [
- f"case JSON.stringify({condition._var_name_unwrapped}):"
- for condition in conditions
- ]
- )
- case_code = (
- f"{case_conditions} return ({return_value._var_name_unwrapped}); break;"
+ [f"case JSON.stringify({condition!s}):" for condition in conditions]
)
+ case_code = f"{case_conditions} return ({return_value!s}); break;"
switch_code += case_code
- switch_code += f"default: return ({default._var_name_unwrapped}); break;"
+ switch_code += f"default: return ({default!s}); break;"
switch_code += "};})()"
return switch_code
@@ -417,37 +354,21 @@ def format_prop(
Raises:
exceptions.InvalidStylePropError: If the style prop value is not a valid type.
TypeError: If the prop is not valid.
+ ValueError: If the prop is not a string.
"""
# import here to avoid circular import.
from reflex.event import EventChain
from reflex.utils import serializers
+ from reflex.vars import Var
try:
# Handle var props.
if isinstance(prop, Var):
- if not prop._var_is_local or prop._var_is_string:
- return str(prop)
- if isinstance(prop, BaseVar) and types._issubclass(prop._var_type, str):
- if prop._var_data and prop._var_data.interpolations:
- return format_f_string_prop(prop)
- return format_string(prop._var_full_name)
- prop = prop._var_full_name
+ return str(prop)
# Handle event props.
- elif isinstance(prop, EventChain):
- sig = inspect.signature(prop.args_spec) # type: ignore
- if sig.parameters:
- arg_def = ",".join(f"_{p}" for p in sig.parameters)
- arg_def_expr = f"[{arg_def}]"
- else:
- # add a default argument for addEvents if none were specified in prop.args_spec
- # used to trigger the preventDefault() on the event.
- arg_def = "...args"
- arg_def_expr = "args"
-
- chain = ",".join([format_event(event) for event in prop.events])
- event = f"addEvents([{chain}], {arg_def_expr}, {json_dumps(prop.event_actions)})"
- prop = f"({arg_def}) => {event}"
+ if isinstance(prop, EventChain):
+ return str(Var.create(prop))
# Handle other types.
elif isinstance(prop, str):
@@ -468,7 +389,8 @@ def format_prop(
raise TypeError(f"Could not format prop: {prop} of type {type(prop)}") from e
# Wrap the variable in braces.
- assert isinstance(prop, str), "The prop must be a string."
+ if not isinstance(prop, str):
+ raise ValueError(f"Invalid prop: {prop}. Expected a string.")
return wrap(prop, "{", check_first=False)
@@ -483,11 +405,15 @@ def format_props(*single_props, **key_value_props) -> list[str]:
The formatted props list.
"""
# Format all the props.
+ from reflex.vars.base import LiteralVar, Var
+
return [
- f"{name}={format_prop(prop)}"
+ (
+ f"{name}={{{format_prop(prop if isinstance(prop, Var) else LiteralVar.create(prop))}}}"
+ )
for name, prop in sorted(key_value_props.items())
if prop is not None
- ] + [str(prop) for prop in single_props]
+ ] + [(f"{LiteralVar.create(prop)!s}") for prop in single_props]
def get_event_handler_parts(handler: EventHandler) -> tuple[str, str]:
@@ -502,19 +428,19 @@ def get_event_handler_parts(handler: EventHandler) -> tuple[str, str]:
# Get the class that defines the event handler.
parts = handler.fn.__qualname__.split(".")
- # If there's no enclosing class, just return the function name.
- if len(parts) == 1:
- return ("", parts[-1])
-
# Get the state full name
state_full_name = handler.state_full_name
+ # If there's no enclosing class, just return the function name.
+ if not state_full_name:
+ return ("", parts[-1])
+
# Get the function name
name = parts[-1]
from reflex.state import State
- if state_full_name == "state" and name not in State.__dict__:
+ if state_full_name == FRONTEND_EVENT_STATE and name not in State.__dict__:
return ("", to_snake_case(handler.fn.__qualname__))
return (state_full_name, name)
@@ -548,14 +474,14 @@ def format_event(event_spec: EventSpec) -> str:
[
":".join(
(
- name._var_name,
+ name._js_expr,
(
wrap(
- json.dumps(val._var_name).strip('"').replace("`", "\\`"),
+ json.dumps(val._js_expr).strip('"').replace("`", "\\`"),
"`",
)
if val._var_is_string
- else val._var_full_name
+ else str(val)
),
)
)
@@ -572,52 +498,43 @@ def format_event(event_spec: EventSpec) -> str:
return f"Event({', '.join(event_args)})"
+if TYPE_CHECKING:
+ from reflex.vars import Var
+
+
def format_event_chain(
event_chain: EventChain | Var[EventChain],
event_arg: Var | None = None,
) -> str:
- """Format an event chain as a javascript invocation.
+ """DEPRECATED: format an event chain as a javascript invocation.
+
+ Use str(rx.Var.create(event_chain)) instead.
Args:
- event_chain: The event chain to queue on the frontend.
- event_arg: The browser-native event (only used to preventDefault).
+ event_chain: The event chain to format.
+ event_arg: this argument is ignored.
Returns:
Compiled javascript code to queue the given event chain on the frontend.
-
- Raises:
- ValueError: When the given event chain is not a valid event chain.
"""
- if isinstance(event_chain, Var):
- from reflex.event import EventChain
-
- if event_chain._var_type is not EventChain:
- raise ValueError(f"Invalid event chain: {event_chain}")
- return "".join(
- [
- "(() => {",
- format_var(event_chain),
- f"; preventDefault({format_var(event_arg)})" if event_arg else "",
- "})()",
- ]
- )
-
- chain = ",".join([format_event(event) for event in event_chain.events])
- return "".join(
- [
- f"addEvents([{chain}]",
- f", {format_var(event_arg)}" if event_arg else "",
- ")",
- ]
+ deprecate(
+ feature_name="format_event_chain",
+ reason="Use str(rx.Var.create(event_chain)) instead",
+ deprecation_version="0.6.0",
+ removal_version="0.7.0",
)
+ from reflex.vars import Var
+ from reflex.vars.function import ArgsFunctionOperation
+
+ result = Var.create(event_chain)
+ if isinstance(result, ArgsFunctionOperation):
+ result = result._return_expr
+ return str(result)
+
def format_queue_events(
- events: EventSpec
- | EventHandler
- | Callable
- | List[EventSpec | EventHandler | Callable]
- | None = None,
+ events: EventType | None = None,
args_spec: Optional[ArgsSpec] = None,
) -> Var[EventChain]:
"""Format a list of event handler / event spec as a javascript callback.
@@ -645,11 +562,10 @@ def format_queue_events(
call_event_fn,
call_event_handler,
)
+ from reflex.vars import FunctionVar, Var
if not events:
- return Var.create_safe(
- "() => null", _var_is_string=False, _var_is_local=False
- ).to(EventChain)
+ return Var("(() => null)").to(FunctionVar, EventChain) # type: ignore
# If no spec is provided, the function will take no arguments.
def _default_args_spec():
@@ -682,12 +598,10 @@ def format_queue_events(
# Return the final code snippet, expecting queueEvents, processEvent, and socket to be in scope.
# Typically this snippet will _only_ run from within an rx.call_script eval context.
- return Var.create_safe(
+ return Var(
f"{arg_def} => {{queueEvents([{','.join(payloads)}], {constants.CompileVars.SOCKET}); "
f"processEvent({constants.CompileVars.SOCKET})}}",
- _var_is_string=False,
- _var_is_local=False,
- ).to(EventChain)
+ ).to(FunctionVar, EventChain) # type: ignore
def format_query_params(router_data: dict[str, Any]) -> dict[str, str]:
@@ -703,48 +617,6 @@ def format_query_params(router_data: dict[str, Any]) -> dict[str, str]:
return {k.replace("-", "_"): v for k, v in params.items()}
-def format_state(value: Any, key: Optional[str] = None) -> Any:
- """Recursively format values in the given state.
-
- Args:
- value: The state to format.
- key: The key associated with the value (optional).
-
- Returns:
- The formatted state.
-
- Raises:
- TypeError: If the given value is not a valid state.
- """
- from reflex.utils import serializers
-
- # Handle dicts.
- if isinstance(value, dict):
- return {k: format_state(v, k) for k, v in value.items()}
-
- # Handle lists, sets, typles.
- if isinstance(value, types.StateIterBases):
- return [format_state(v) for v in value]
-
- # Return state vars as is.
- if isinstance(value, types.StateBases):
- return value
-
- # Serialize the value.
- serialized = serializers.serialize(value)
- if serialized is not None:
- return serialized
-
- if key is None:
- raise TypeError(
- f"No JSON serializer found for var {value} of type {type(value)}."
- )
- else:
- raise TypeError(
- f"No JSON serializer found for State Var '{key}' of value {value} of type {type(value)}."
- )
-
-
def format_state_name(state_name: str) -> str:
"""Format a state name, replacing dots with double underscore.
@@ -774,41 +646,6 @@ def format_ref(ref: str) -> str:
return f"ref_{clean_ref}"
-def format_array_ref(refs: str, idx: Var | None) -> str:
- """Format a ref accessed by array.
-
- Args:
- refs : The ref array to access.
- idx : The index of the ref in the array.
-
- Returns:
- The formatted ref.
- """
- clean_ref = re.sub(r"[^\w]+", "_", refs)
- if idx is not None:
- idx._var_is_local = True
- return f"refs_{clean_ref}[{idx}]"
- return f"refs_{clean_ref}"
-
-
-def format_breadcrumbs(route: str) -> list[tuple[str, str]]:
- """Take a route and return a list of tuple for use in breadcrumb.
-
- Args:
- route: The route to transform.
-
- Returns:
- list[tuple[str, str]]: the list of tuples for the breadcrumb.
- """
- route_parts = route.lstrip("/").split("/")
-
- # create and return breadcrumbs
- return [
- (part, "/".join(["", *route_parts[: i + 1]]))
- for i, part in enumerate(route_parts)
- ]
-
-
def format_library_name(library_fullname: str):
"""Format the name of a library.
@@ -818,6 +655,8 @@ def format_library_name(library_fullname: str):
Returns:
The name without the @version if it was part of the name
"""
+ if library_fullname.startswith("https://"):
+ return library_fullname
lib, at, version = library_fullname.rpartition("@")
if not lib:
lib = at + version
@@ -825,54 +664,22 @@ def format_library_name(library_fullname: str):
return lib
-def json_dumps(obj: Any) -> str:
+def json_dumps(obj: Any, **kwargs) -> str:
"""Takes an object and returns a jsonified string.
Args:
obj: The object to be serialized.
+ kwargs: Additional keyword arguments to pass to json.dumps.
Returns:
A string
"""
from reflex.utils import serializers
- return json.dumps(obj, ensure_ascii=False, default=serializers.serialize)
+ kwargs.setdefault("ensure_ascii", False)
+ kwargs.setdefault("default", serializers.serialize)
-
-def unwrap_vars(value: str) -> str:
- """Unwrap var values from a JSON string.
-
- For example, "{var}" will be unwrapped to "var".
-
- Args:
- value: The JSON string to unwrap.
-
- Returns:
- The unwrapped JSON string.
- """
-
- def unescape_double_quotes_in_var(m: re.Match) -> str:
- prefix = m.group(1) or ""
- # Since the outer quotes are removed, the inner escaped quotes must be unescaped.
- return prefix + re.sub('\\\\"', '"', m.group(2))
-
- # This substitution is necessary to unwrap var values.
- return (
- re.sub(
- pattern=r"""
- (?.*?)? # Optional encoded VarData (non-greedy)
- {(.*?)} # extract the value between curly braces (non-greedy)
- " # match must end with an unescaped double quote
- """,
- repl=unescape_double_quotes_in_var,
- string=value,
- flags=re.VERBOSE,
- )
- .replace('"`', "`")
- .replace('`"', "`")
- )
+ return json.dumps(obj, **kwargs)
def collect_form_dict_names(form_dict: dict[str, Any]) -> dict[str, Any]:
@@ -897,6 +704,22 @@ def collect_form_dict_names(form_dict: dict[str, Any]) -> dict[str, Any]:
return collapsed
+def format_array_ref(refs: str, idx: Var | None) -> str:
+ """Format a ref accessed by array.
+
+ Args:
+ refs : The ref array to access.
+ idx : The index of the ref in the array.
+
+ Returns:
+ The formatted ref.
+ """
+ clean_ref = re.sub(r"[^\w]+", "_", refs)
+ if idx is not None:
+ return f"refs_{clean_ref}[{idx!s}]"
+ return f"refs_{clean_ref}"
+
+
def format_data_editor_column(col: str | dict):
"""Format a given column into the proper format.
@@ -909,6 +732,8 @@ def format_data_editor_column(col: str | dict):
Returns:
The formatted column.
"""
+ from reflex.vars import Var
+
if isinstance(col, str):
return {"title": col, "id": col.lower(), "type": "str"}
@@ -921,7 +746,7 @@ def format_data_editor_column(col: str | dict):
col["overlayIcon"] = None
return col
- if isinstance(col, BaseVar):
+ if isinstance(col, Var):
return col
raise ValueError(
@@ -938,7 +763,9 @@ def format_data_editor_cell(cell: Any):
Returns:
The formatted cell.
"""
+ from reflex.vars.base import Var
+
return {
- "kind": Var.create(value="GridCellKind.Text", _var_is_string=False),
+ "kind": Var(_js_expr="GridCellKind.Text"),
"data": cell,
}
diff --git a/reflex/utils/imports.py b/reflex/utils/imports.py
index d58c2bf3f..bd422ecc0 100644
--- a/reflex/utils/imports.py
+++ b/reflex/utils/imports.py
@@ -2,10 +2,9 @@
from __future__ import annotations
+import dataclasses
from collections import defaultdict
-from typing import Dict, List, Optional, Tuple, Union
-
-from reflex.base import Base
+from typing import DefaultDict, Dict, List, Optional, Tuple, Union
def merge_imports(
@@ -19,12 +18,28 @@ def merge_imports(
Returns:
The merged import dicts.
"""
- all_imports = defaultdict(list)
+ all_imports: DefaultDict[str, List[ImportVar]] = defaultdict(list)
for import_dict in imports:
for lib, fields in (
import_dict if isinstance(import_dict, tuple) else import_dict.items()
):
- all_imports[lib].extend(fields)
+ # If the lib is an absolute path, we need to prefix it with a $
+ lib = (
+ "$" + lib
+ if lib.startswith(("/utils/", "/components/", "/styles/", "/public/"))
+ else lib
+ )
+ if isinstance(fields, (list, tuple, set)):
+ all_imports[lib].extend(
+ (
+ ImportVar(field) if isinstance(field, str) else field
+ for field in fields
+ )
+ )
+ else:
+ all_imports[lib].append(
+ ImportVar(fields) if isinstance(fields, str) else fields
+ )
return all_imports
@@ -75,7 +90,8 @@ def collapse_imports(
}
-class ImportVar(Base):
+@dataclasses.dataclass(order=True, frozen=True)
+class ImportVar:
"""An import var."""
# The name of the import tag.
@@ -111,73 +127,6 @@ class ImportVar(Base):
else:
return self.tag or ""
- def __lt__(self, other: ImportVar) -> bool:
- """Compare two ImportVar objects.
-
- Args:
- other: The other ImportVar object to compare.
-
- Returns:
- Whether this ImportVar object is less than the other.
- """
- return (
- self.tag,
- self.is_default,
- self.alias,
- self.install,
- self.render,
- self.transpile,
- ) < (
- other.tag,
- other.is_default,
- other.alias,
- other.install,
- other.render,
- other.transpile,
- )
-
- def __eq__(self, other: ImportVar) -> bool:
- """Check if two ImportVar objects are equal.
-
- Args:
- other: The other ImportVar object to compare.
-
- Returns:
- Whether the two ImportVar objects are equal.
- """
- return (
- self.tag,
- self.is_default,
- self.alias,
- self.install,
- self.render,
- self.transpile,
- ) == (
- other.tag,
- other.is_default,
- other.alias,
- other.install,
- other.render,
- other.transpile,
- )
-
- def __hash__(self) -> int:
- """Hash the ImportVar object.
-
- Returns:
- The hash of the ImportVar object.
- """
- return hash(
- (
- self.tag,
- self.is_default,
- self.alias,
- self.install,
- self.render,
- self.transpile,
- )
- )
-
ImportTypes = Union[str, ImportVar, List[Union[str, ImportVar]], List[ImportVar]]
ImportDict = Dict[str, ImportTypes]
diff --git a/reflex/utils/net.py b/reflex/utils/net.py
new file mode 100644
index 000000000..acc202912
--- /dev/null
+++ b/reflex/utils/net.py
@@ -0,0 +1,41 @@
+"""Helpers for downloading files from the network."""
+
+import httpx
+
+from ..config import environment
+from . import console
+
+
+def _httpx_verify_kwarg() -> bool:
+ """Get the value of the HTTPX verify keyword argument.
+
+ Returns:
+ True if SSL verification is enabled, False otherwise
+ """
+ return not environment.SSL_NO_VERIFY.get()
+
+
+def get(url: str, **kwargs) -> httpx.Response:
+ """Make an HTTP GET request.
+
+ Args:
+ url: The URL to request.
+ **kwargs: Additional keyword arguments to pass to httpx.get.
+
+ Returns:
+ The response object.
+
+ Raises:
+ httpx.ConnectError: If the connection cannot be established.
+ """
+ kwargs.setdefault("verify", _httpx_verify_kwarg())
+ try:
+ return httpx.get(url, **kwargs)
+ except httpx.ConnectError as err:
+ if "CERTIFICATE_VERIFY_FAILED" in str(err):
+ # If the error is a certificate verification error, recommend mitigating steps.
+ console.error(
+ f"Certificate verification failed for {url}. Set environment variable SSL_CERT_FILE to the "
+ "path of the certificate file or SSL_NO_VERIFY=1 to disable verification."
+ )
+ raise
diff --git a/reflex/utils/path_ops.py b/reflex/utils/path_ops.py
index 39f2138f8..38560977e 100644
--- a/reflex/utils/path_ops.py
+++ b/reflex/utils/path_ops.py
@@ -9,6 +9,7 @@ import shutil
from pathlib import Path
from reflex import constants
+from reflex.config import environment
# Shorthand for join.
join = os.linesep.join
@@ -81,6 +82,18 @@ def mkdir(path: str | Path):
Path(path).mkdir(parents=True, exist_ok=True)
+def ls(path: str | Path) -> list[Path]:
+ """List the contents of a directory.
+
+ Args:
+ path: The path to the directory.
+
+ Returns:
+ A list of paths to the contents of the directory.
+ """
+ return list(Path(path).iterdir())
+
+
def ln(src: str | Path, dest: str | Path, overwrite: bool = False) -> bool:
"""Create a symbolic link.
@@ -117,7 +130,25 @@ def which(program: str | Path) -> str | Path | None:
return shutil.which(str(program))
-def get_node_bin_path() -> str | None:
+def use_system_node() -> bool:
+ """Check if the system node should be used.
+
+ Returns:
+ Whether the system node should be used.
+ """
+ return environment.REFLEX_USE_SYSTEM_NODE.get()
+
+
+def use_system_bun() -> bool:
+ """Check if the system bun should be used.
+
+ Returns:
+ Whether the system bun should be used.
+ """
+ return environment.REFLEX_USE_SYSTEM_BUN.get()
+
+
+def get_node_bin_path() -> Path | None:
"""Get the node binary dir path.
Returns:
@@ -126,8 +157,8 @@ def get_node_bin_path() -> str | None:
bin_path = Path(constants.Node.BIN_PATH)
if not bin_path.exists():
str_path = which("node")
- return str(Path(str_path).parent.resolve()) if str_path else str_path
- return str(bin_path.resolve())
+ return Path(str_path).parent.resolve() if str_path else None
+ return bin_path.resolve()
def get_node_path() -> str | None:
@@ -137,8 +168,9 @@ def get_node_path() -> str | None:
The path to the node binary file.
"""
node_path = Path(constants.Node.PATH)
- if not node_path.exists():
- return str(which("node"))
+ if use_system_node() or not node_path.exists():
+ system_node_path = which("node")
+ return str(system_node_path) if system_node_path else None
return str(node_path)
@@ -149,8 +181,9 @@ def get_npm_path() -> str | None:
The path to the npm binary file.
"""
npm_path = Path(constants.Node.NPM_PATH)
- if not npm_path.exists():
- return str(which("npm"))
+ if use_system_node() or not npm_path.exists():
+ system_npm_path = which("npm")
+ return str(system_npm_path) if system_npm_path else None
return str(npm_path)
@@ -171,15 +204,15 @@ def update_json_file(file_path: str | Path, update_dict: dict[str, int | str]):
# Read the existing json object from the file.
json_object = {}
- if fp.stat().st_size == 0:
- with open(fp) as f:
+ if fp.stat().st_size:
+ with fp.open() as f:
json_object = json.load(f)
# Update the json object with the new data.
json_object.update(update_dict)
# Write the updated json object to the file
- with open(fp, "w") as f:
+ with fp.open("w") as f:
json.dump(json_object, f, ensure_ascii=False)
@@ -197,4 +230,4 @@ def find_replace(directory: str | Path, find: str, replace: str):
filepath = Path(root, file)
text = filepath.read_text(encoding="utf-8")
text = re.sub(find, replace, text)
- filepath.write_text(text)
+ filepath.write_text(text, encoding="utf-8")
diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py
index a80bcd814..797d28701 100644
--- a/reflex/utils/prerequisites.py
+++ b/reflex/utils/prerequisites.py
@@ -2,11 +2,11 @@
from __future__ import annotations
+import contextlib
+import dataclasses
import functools
-import glob
import importlib
import importlib.metadata
-import inspect
import json
import os
import platform
@@ -16,10 +16,9 @@ import shutil
import stat
import sys
import tempfile
-import textwrap
+import time
import zipfile
from datetime import datetime
-from fileinput import FileInput
from pathlib import Path
from types import ModuleType
from typing import Callable, List, Optional
@@ -29,21 +28,25 @@ import typer
from alembic.util.exc import CommandError
from packaging import version
from redis import Redis as RedisSync
+from redis import exceptions
from redis.asyncio import Redis
-import reflex
from reflex import constants, model
-from reflex.base import Base
from reflex.compiler import templates
-from reflex.config import Config, get_config
-from reflex.utils import console, path_ops, processes
+from reflex.config import Config, environment, get_config
+from reflex.utils import console, net, path_ops, processes, redir
+from reflex.utils.exceptions import (
+ GeneratedCodeHasNoFunctionDefs,
+ raise_system_package_missing_error,
+)
from reflex.utils.format import format_library_name
-from reflex.utils.registry import _get_best_registry
+from reflex.utils.registry import _get_npm_registry
CURRENTLY_INSTALLING_NODE = False
-class Template(Base):
+@dataclasses.dataclass(frozen=True)
+class Template:
"""A template for a Reflex app."""
name: str
@@ -52,7 +55,8 @@ class Template(Base):
demo_url: str
-class CpuInfo(Base):
+@dataclasses.dataclass(frozen=True)
+class CpuInfo:
"""Model to save cpu info."""
manufacturer_id: Optional[str]
@@ -68,8 +72,19 @@ def get_web_dir() -> Path:
Returns:
The working directory.
"""
- workdir = Path(os.getenv("REFLEX_WEB_WORKDIR", constants.Dirs.WEB))
- return workdir
+ return environment.REFLEX_WEB_WORKDIR.get()
+
+
+def _python_version_check():
+ """Emit deprecation warning for deprecated python versions."""
+ # Check for end-of-life python versions.
+ if sys.version_info < (3, 10):
+ console.deprecate(
+ feature_name="Support for Python 3.9 and older",
+ reason="please upgrade to Python 3.10 or newer",
+ deprecation_version="0.6.0",
+ removal_version="0.7.0",
+ )
def check_latest_package_version(package_name: str):
@@ -78,21 +93,24 @@ def check_latest_package_version(package_name: str):
Args:
package_name: The name of the package.
"""
+ if environment.REFLEX_CHECK_LATEST_VERSION.get() is False:
+ return
try:
# Get the latest version from PyPI
current_version = importlib.metadata.version(package_name)
url = f"https://pypi.org/pypi/{package_name}/json"
- response = httpx.get(url)
+ response = net.get(url)
latest_version = response.json()["info"]["version"]
- if (
- version.parse(current_version) < version.parse(latest_version)
- and not get_or_set_last_reflex_version_check_datetime()
- ):
- # only show a warning when the host version is outdated and
- # the last_version_check_datetime is not set in reflex.json
+ if get_or_set_last_reflex_version_check_datetime():
+ # Versions were already checked and saved in reflex.json, no need to warn again
+ return
+ if version.parse(current_version) < version.parse(latest_version):
+ # Show a warning when the host version is older than PyPI version
console.warn(
f"Your version ({current_version}) of {package_name} is out of date. Upgrade to {latest_version} with 'pip install {package_name} --upgrade'"
)
+ # Check for deprecated python versions
+ _python_version_check()
except Exception:
pass
@@ -117,6 +135,14 @@ def get_or_set_last_reflex_version_check_datetime():
return last_version_check_datetime
+def set_last_reflex_run_time():
+ """Set the last Reflex run time."""
+ path_ops.update_json_file(
+ get_web_dir() / constants.Reflex.JSON,
+ {"last_reflex_run_datetime": str(datetime.now())},
+ )
+
+
def check_node_version() -> bool:
"""Check the version of Node.js.
@@ -124,14 +150,9 @@ def check_node_version() -> bool:
Whether the version of Node.js is valid.
"""
current_version = get_node_version()
- if current_version:
- # Compare the version numbers
- return (
- current_version >= version.parse(constants.Node.MIN_VERSION)
- if constants.IS_WINDOWS
- else current_version == version.parse(constants.Node.VERSION)
- )
- return False
+ return current_version is not None and current_version >= version.parse(
+ constants.Node.MIN_VERSION
+ )
def get_node_version() -> version.Version | None:
@@ -177,7 +198,7 @@ def get_bun_version() -> version.Version | None:
"""
try:
# Run the bun -v command and capture the output
- result = processes.new_process([get_config().bun_path, "-v"], run=True)
+ result = processes.new_process([str(get_config().bun_path), "-v"], run=True)
return version.parse(result.stdout) # type: ignore
except FileNotFoundError:
return None
@@ -188,34 +209,44 @@ def get_bun_version() -> version.Version | None:
return None
-def get_install_package_manager() -> str | None:
+def get_install_package_manager(on_failure_return_none: bool = False) -> str | None:
"""Get the package manager executable for installation.
Currently, bun is used for installation only.
+ Args:
+ on_failure_return_none: Whether to return None on failure.
+
Returns:
The path to the package manager.
"""
- if (
- constants.IS_WINDOWS
- and not is_windows_bun_supported()
+ if constants.IS_WINDOWS and (
+ not is_windows_bun_supported()
or windows_check_onedrive_in_path()
or windows_npm_escape_hatch()
):
- return get_package_manager()
- return get_config().bun_path
+ return get_package_manager(on_failure_return_none)
+ return str(get_config().bun_path)
-def get_package_manager() -> str | None:
+def get_package_manager(on_failure_return_none: bool = False) -> str | None:
"""Get the package manager executable for running app.
Currently on unix systems, npm is used for running the app only.
+ Args:
+ on_failure_return_none: Whether to return None on failure.
+
Returns:
The path to the package manager.
+
+ Raises:
+ FileNotFoundError: If the package manager is not found.
"""
npm_path = path_ops.get_npm_path()
if npm_path is not None:
- npm_path = str(Path(npm_path).resolve())
- return npm_path
+ return str(Path(npm_path).resolve())
+ if on_failure_return_none:
+ return None
+ raise FileNotFoundError("NPM not found. You may need to run `reflex init`.")
def windows_check_onedrive_in_path() -> bool:
@@ -233,7 +264,7 @@ def windows_npm_escape_hatch() -> bool:
Returns:
If the user has set REFLEX_USE_NPM.
"""
- return os.environ.get("REFLEX_USE_NPM", "").lower() in ["true", "1", "yes"]
+ return environment.REFLEX_USE_NPM.get()
def get_app(reload: bool = False) -> ModuleType:
@@ -251,7 +282,7 @@ def get_app(reload: bool = False) -> ModuleType:
from reflex.utils import telemetry
try:
- os.environ[constants.RELOAD_CONFIG] = str(reload)
+ environment.RELOAD_CONFIG.set(reload)
config = get_config()
if not config.app_name:
raise RuntimeError(
@@ -259,7 +290,7 @@ def get_app(reload: bool = False) -> ModuleType:
"If this error occurs in a reflex test case, ensure that `get_app` is mocked."
)
module = config.module
- sys.path.insert(0, os.getcwd())
+ sys.path.insert(0, str(Path.cwd()))
app = __import__(module, fromlist=(constants.CompileVars.APP,))
if reload:
@@ -289,7 +320,7 @@ def get_compiled_app(reload: bool = False, export: bool = False) -> ModuleType:
"""
app_module = get_app(reload=reload)
app = getattr(app_module, constants.CompileVars.APP)
- # For py3.8 and py3.9 compatibility when redis is used, we MUST add any decorator pages
+ # For py3.9 compatibility when redis is used, we MUST add any decorator pages
# before compiling the app in a thread to avoid event loop error (REF-2172).
app._apply_decorated_pages()
app._compile(export=export)
@@ -326,24 +357,40 @@ def parse_redis_url() -> str | dict | None:
"""Parse the REDIS_URL in config if applicable.
Returns:
- If redis-py syntax, return the URL as it is. Otherwise, return the host/port/db as a dict.
+ If url is non-empty, return the URL as it is.
+
+ Raises:
+ ValueError: If the REDIS_URL is not a supported scheme.
"""
config = get_config()
if not config.redis_url:
return None
- if config.redis_url.startswith(("redis://", "rediss://", "unix://")):
- return config.redis_url
- console.deprecate(
- feature_name="host[:port] style redis urls",
- reason="redis-py url syntax is now being used",
- deprecation_version="0.3.6",
- removal_version="0.6.0",
- )
- redis_url, has_port, redis_port = config.redis_url.partition(":")
- if not has_port:
- redis_port = 6379
- console.info(f"Using redis at {config.redis_url}")
- return dict(host=redis_url, port=int(redis_port), db=0)
+ if not config.redis_url.startswith(("redis://", "rediss://", "unix://")):
+ raise ValueError(
+ "REDIS_URL must start with 'redis://', 'rediss://', or 'unix://'."
+ )
+ return config.redis_url
+
+
+async def get_redis_status() -> dict[str, bool | None]:
+ """Checks the status of the Redis connection.
+
+ Attempts to connect to Redis and send a ping command to verify connectivity.
+
+ Returns:
+ The status of the Redis connection.
+ """
+ try:
+ status = True
+ redis_client = get_redis_sync()
+ if redis_client is not None:
+ redis_client.ping()
+ else:
+ status = None
+ except exceptions.RedisError:
+ status = False
+
+ return {"redis": status}
def validate_app_name(app_name: str | None = None) -> str:
@@ -360,9 +407,7 @@ def validate_app_name(app_name: str | None = None) -> str:
Raises:
Exit: if the app directory name is reflex or if the name is not standard for a python package name.
"""
- app_name = (
- app_name if app_name else os.getcwd().split(os.path.sep)[-1].replace("-", "_")
- )
+ app_name = app_name if app_name else Path.cwd().name.replace("-", "_")
# Make sure the app is not named "reflex".
if app_name.lower() == constants.Reflex.MODULE_NAME:
console.error(
@@ -390,14 +435,16 @@ def create_config(app_name: str):
from reflex.compiler import templates
config_name = f"{re.sub(r'[^a-zA-Z]', '', app_name).capitalize()}Config"
- with open(constants.Config.FILE, "w") as f:
- console.debug(f"Creating {constants.Config.FILE}")
- f.write(templates.RXCONFIG.render(app_name=app_name, config_name=config_name))
+
+ console.debug(f"Creating {constants.Config.FILE}")
+ constants.Config.FILE.write_text(
+ templates.RXCONFIG.render(app_name=app_name, config_name=config_name)
+ )
def initialize_gitignore(
- gitignore_file: str = constants.GitIgnore.FILE,
- files_to_ignore: set[str] = constants.GitIgnore.DEFAULTS,
+ gitignore_file: Path = constants.GitIgnore.FILE,
+ files_to_ignore: set[str] | list[str] = constants.GitIgnore.DEFAULTS,
):
"""Initialize the template .gitignore file.
@@ -406,20 +453,20 @@ def initialize_gitignore(
files_to_ignore: The files to add to the .gitignore file.
"""
# Combine with the current ignored files.
- current_ignore: set[str] = set()
- if os.path.exists(gitignore_file):
- with open(gitignore_file, "r") as f:
- current_ignore |= set([line.strip() for line in f.readlines()])
+ current_ignore: list[str] = []
+ if gitignore_file.exists():
+ current_ignore = [ln.strip() for ln in gitignore_file.read_text().splitlines()]
if files_to_ignore == current_ignore:
console.debug(f"{gitignore_file} already up to date.")
return
- files_to_ignore |= current_ignore
+ files_to_ignore = [ln for ln in files_to_ignore if ln not in current_ignore]
+ files_to_ignore += current_ignore
# Write files to the .gitignore file.
- with open(gitignore_file, "w", newline="\n") as f:
- console.debug(f"Creating {gitignore_file}")
- f.write(f"{(path_ops.join(sorted(files_to_ignore))).lstrip()}\n")
+ gitignore_file.touch(exist_ok=True)
+ console.debug(f"Creating {gitignore_file}")
+ gitignore_file.write_text("\n".join(files_to_ignore) + "\n")
def initialize_requirements_txt():
@@ -446,14 +493,14 @@ def initialize_requirements_txt():
console.debug(f"Detected encoding for {fp} as {encoding}.")
try:
other_requirements_exist = False
- with open(fp, "r", encoding=encoding) as f:
- for req in f.readlines():
+ with fp.open("r", encoding=encoding) as f:
+ for req in f:
# Check if we have a package name that is reflex
if re.match(r"^reflex[^a-zA-Z0-9]", req):
console.debug(f"{fp} already has reflex as dependency.")
return
other_requirements_exist = True
- with open(fp, "a", encoding=encoding) as f:
+ with fp.open("a", encoding=encoding) as f:
preceding_newline = "\n" if other_requirements_exist else ""
f.write(
f"{preceding_newline}{constants.RequirementsTxt.DEFAULTS_STUB}{constants.Reflex.VERSION}\n"
@@ -512,8 +559,8 @@ def initialize_app_directory(
# Rename the template app to the app name.
path_ops.mv(template_code_dir_name, app_name)
path_ops.mv(
- os.path.join(app_name, template_name + constants.Ext.PY),
- os.path.join(app_name, app_name + constants.Ext.PY),
+ Path(app_name) / (template_name + constants.Ext.PY),
+ Path(app_name) / (app_name + constants.Ext.PY),
)
# Fix up the imports.
@@ -544,13 +591,15 @@ def initialize_web_directory():
"""Initialize the web directory on reflex init."""
console.log("Initializing the web directory.")
- # Re-use the hash if one is already created, so we don't over-write it when running reflex init
+ # Reuse the hash if one is already created, so we don't over-write it when running reflex init
project_hash = get_project_hash()
path_ops.cp(constants.Templates.Dirs.WEB_TEMPLATE, str(get_web_dir()))
initialize_package_json()
+ initialize_bun_config()
+
path_ops.mkdir(get_web_dir() / constants.Dirs.PUBLIC)
update_next_config()
@@ -575,23 +624,27 @@ def _compile_package_json():
def initialize_package_json():
"""Render and write in .web the package.json file."""
output_path = get_web_dir() / constants.PackageJson.PATH
- code = _compile_package_json()
- output_path.write_text(code)
+ output_path.write_text(_compile_package_json())
- best_registry = _get_best_registry()
+
+def initialize_bun_config():
+ """Initialize the bun config file."""
bun_config_path = get_web_dir() / constants.Bun.CONFIG_PATH
- bun_config_path.write_text(
- f"""
-[install]
-registry = "{best_registry}"
-"""
- )
+
+ if (custom_bunfig := Path(constants.Bun.CONFIG_PATH)).exists():
+ bunfig_content = custom_bunfig.read_text()
+ console.info(f"Copying custom bunfig.toml inside {get_web_dir()} folder")
+ else:
+ best_registry = _get_npm_registry()
+ bunfig_content = constants.Bun.DEFAULT_CONFIG.format(registry=best_registry)
+
+ bun_config_path.write_text(bunfig_content)
def init_reflex_json(project_hash: int | None):
"""Write the hash of the Reflex project to a REFLEX_JSON.
- Re-use the hash if one is already created, therefore do not
+ Reuse the hash if one is already created, therefore do not
overwrite it every time we run the reflex init command
.
@@ -641,10 +694,11 @@ def _update_next_config(
"compress": config.next_compression,
"reactStrictMode": config.react_strict_mode,
"trailingSlash": True,
+ "staticPageGenerationTimeout": config.static_page_generation_timeout,
}
if transpile_packages:
next_config["transpilePackages"] = list(
- set((format_library_name(p) for p in transpile_packages))
+ {format_library_name(p) for p in transpile_packages}
)
if export:
next_config["output"] = "export"
@@ -657,7 +711,7 @@ def _update_next_config(
def remove_existing_bun_installation():
"""Remove existing bun installation."""
console.debug("Removing existing bun installation.")
- if os.path.exists(get_config().bun_path):
+ if Path(get_config().bun_path).exists():
path_ops.rm(constants.Bun.ROOT_PATH)
@@ -672,18 +726,18 @@ def download_and_run(url: str, *args, show_status: bool = False, **env):
"""
# Download the script
console.debug(f"Downloading {url}")
- response = httpx.get(url)
+ response = net.get(url)
if response.status_code != httpx.codes.OK:
response.raise_for_status()
# Save the script to a temporary file.
- script = tempfile.NamedTemporaryFile()
- with open(script.name, "w") as f:
- f.write(response.text)
+ script = Path(tempfile.NamedTemporaryFile().name)
+
+ script.write_text(response.text)
# Run the script.
env = {**os.environ, **env}
- process = processes.new_process(["bash", f.name, *args], env=env)
+ process = processes.new_process(["bash", str(script), *args], env=env)
show = processes.show_status if show_status else processes.show_logs
show(f"Installing {url}", process)
@@ -697,16 +751,16 @@ def download_and_extract_fnm_zip():
# Download the zip file
url = constants.Fnm.INSTALL_URL
console.debug(f"Downloading {url}")
- fnm_zip_file = os.path.join(constants.Fnm.DIR, f"{constants.Fnm.FILENAME}.zip")
+ fnm_zip_file: Path = constants.Fnm.DIR / f"{constants.Fnm.FILENAME}.zip"
# Function to download and extract the FNM zip release.
try:
# Download the FNM zip release.
# TODO: show progress to improve UX
- with httpx.stream("GET", url, follow_redirects=True) as response:
- response.raise_for_status()
- with open(fnm_zip_file, "wb") as output_file:
- for chunk in response.iter_bytes():
- output_file.write(chunk)
+ response = net.get(url, follow_redirects=True)
+ response.raise_for_status()
+ with fnm_zip_file.open("wb") as output_file:
+ for chunk in response.iter_bytes():
+ output_file.write(chunk)
# Extract the downloaded zip file.
with zipfile.ZipFile(fnm_zip_file, "r") as zip_ref:
@@ -736,7 +790,7 @@ def install_node():
return
path_ops.mkdir(constants.Fnm.DIR)
- if not os.path.exists(constants.Fnm.EXE):
+ if not constants.Fnm.EXE.exists():
download_and_extract_fnm_zip()
if constants.IS_WINDOWS:
@@ -752,7 +806,7 @@ def install_node():
)
else: # All other platforms (Linux, MacOS).
# Add execute permissions to fnm executable.
- os.chmod(constants.Fnm.EXE, stat.S_IXUSR)
+ constants.Fnm.EXE.chmod(stat.S_IXUSR)
# Install node.
# Specify arm64 arch explicitly for M1s and M2s.
architecture_arg = (
@@ -775,14 +829,10 @@ def install_node():
def install_bun():
- """Install bun onto the user's system.
-
- Raises:
- FileNotFoundError: If required packages are not found.
- """
+ """Install bun onto the user's system."""
win_supported = is_windows_bun_supported()
one_drive_in_path = windows_check_onedrive_in_path()
- if constants.IS_WINDOWS and not win_supported or one_drive_in_path:
+ if constants.IS_WINDOWS and (not win_supported or one_drive_in_path):
if not win_supported:
console.warn(
"Bun for Windows is currently only available for x86 64-bit Windows. Installation will fall back on npm."
@@ -793,7 +843,7 @@ def install_bun():
)
# Skip if bun is already installed.
- if os.path.exists(get_config().bun_path) and get_bun_version() == version.parse(
+ if Path(get_config().bun_path).exists() and get_bun_version() == version.parse(
constants.Bun.VERSION
):
console.debug("Skipping bun installation as it is already installed.")
@@ -808,7 +858,7 @@ def install_bun():
f"irm {constants.Bun.WINDOWS_INSTALL_URL}|iex",
],
env={
- "BUN_INSTALL": constants.Bun.ROOT_PATH,
+ "BUN_INSTALL": str(constants.Bun.ROOT_PATH),
"BUN_VERSION": constants.Bun.VERSION,
},
shell=True,
@@ -818,31 +868,32 @@ def install_bun():
else:
unzip_path = path_ops.which("unzip")
if unzip_path is None:
- raise FileNotFoundError("Reflex requires unzip to be installed.")
+ raise_system_package_missing_error("unzip")
# Run the bun install script.
download_and_run(
constants.Bun.INSTALL_URL,
f"bun-v{constants.Bun.VERSION}",
- BUN_INSTALL=constants.Bun.ROOT_PATH,
+ BUN_INSTALL=str(constants.Bun.ROOT_PATH),
)
-def _write_cached_procedure_file(payload: str, cache_file: str):
- with open(cache_file, "w") as f:
- f.write(payload)
+def _write_cached_procedure_file(payload: str, cache_file: str | Path):
+ cache_file = Path(cache_file)
+ cache_file.write_text(payload)
-def _read_cached_procedure_file(cache_file: str) -> str | None:
- if os.path.exists(cache_file):
- with open(cache_file, "r") as f:
- return f.read()
+def _read_cached_procedure_file(cache_file: str | Path) -> str | None:
+ cache_file = Path(cache_file)
+ if cache_file.exists():
+ return cache_file.read_text()
return None
-def _clear_cached_procedure_file(cache_file: str):
- if os.path.exists(cache_file):
- os.remove(cache_file)
+def _clear_cached_procedure_file(cache_file: str | Path):
+ cache_file = Path(cache_file)
+ if cache_file.exists():
+ cache_file.unlink()
def cached_procedure(cache_file: str, payload_fn: Callable[..., str]):
@@ -873,7 +924,7 @@ def cached_procedure(cache_file: str, payload_fn: Callable[..., str]):
@cached_procedure(
cache_file=str(get_web_dir() / "reflex.install_frontend_packages.cached"),
- payload_fn=lambda p, c: f"{repr(sorted(list(p)))},{c.json()}",
+ payload_fn=lambda p, c: f"{sorted(p)!r},{c.json()}",
)
def install_frontend_packages(packages: set[str], config: Config):
"""Installs the base and custom frontend packages.
@@ -882,20 +933,42 @@ def install_frontend_packages(packages: set[str], config: Config):
packages: A list of package names to be installed.
config: The config object.
+ Raises:
+ FileNotFoundError: If the package manager is not found.
+
Example:
>>> install_frontend_packages(["react", "react-dom"], get_config())
"""
# unsupported archs(arm and 32bit machines) will use npm anyway. so we dont have to run npm twice
fallback_command = (
- get_package_manager()
- if not constants.IS_WINDOWS
- or constants.IS_WINDOWS
- and is_windows_bun_supported()
- and not windows_check_onedrive_in_path()
+ get_package_manager(on_failure_return_none=True)
+ if (
+ not constants.IS_WINDOWS
+ or (
+ constants.IS_WINDOWS
+ and (
+ is_windows_bun_supported() and not windows_check_onedrive_in_path()
+ )
+ )
+ )
else None
)
+
+ install_package_manager = (
+ get_install_package_manager(on_failure_return_none=True) or fallback_command
+ )
+
+ if install_package_manager is None:
+ raise FileNotFoundError(
+ "Could not find a package manager to install frontend packages. You may need to run `reflex init`."
+ )
+
+ fallback_command = (
+ fallback_command if fallback_command is not install_package_manager else None
+ )
+
processes.run_process_with_fallback(
- [get_install_package_manager(), "install"], # type: ignore
+ [install_package_manager, "install"], # type: ignore
fallback=fallback_command,
analytics_enabled=True,
show_status_message="Installing base frontend packages",
@@ -906,7 +979,7 @@ def install_frontend_packages(packages: set[str], config: Config):
if config.tailwind is not None:
processes.run_process_with_fallback(
[
- get_install_package_manager(),
+ install_package_manager,
"add",
"-d",
constants.Tailwind.VERSION,
@@ -922,7 +995,7 @@ def install_frontend_packages(packages: set[str], config: Config):
# Install custom packages defined in frontend_packages
if len(packages) > 0:
processes.run_process_with_fallback(
- [get_install_package_manager(), "add", *packages],
+ [install_package_manager, "add", *packages],
fallback=fallback_command,
analytics_enabled=True,
show_status_message="Installing frontend packages from config and components",
@@ -943,7 +1016,7 @@ def needs_reinit(frontend: bool = True) -> bool:
Raises:
Exit: If the app is not initialized.
"""
- if not os.path.exists(constants.Config.FILE):
+ if not constants.Config.FILE.exists():
console.error(
f"[cyan]{constants.Config.FILE}[/cyan] not found. Move to the root folder of your project, or run [bold]{constants.Reflex.MODULE_NAME} init[/bold] to start a new project."
)
@@ -954,7 +1027,7 @@ def needs_reinit(frontend: bool = True) -> bool:
return False
# Make sure the .reflex directory exists.
- if not os.path.exists(constants.Reflex.DIR):
+ if not environment.REFLEX_DIR.get().exists():
return True
# Make sure the .web directory exists in frontend mode.
@@ -1000,6 +1073,8 @@ def validate_bun():
# if a custom bun path is provided, make sure its valid
# This is specific to non-FHS OS
bun_path = get_config().bun_path
+ if path_ops.use_system_bun():
+ bun_path = path_ops.which("bun")
if bun_path != constants.Bun.DEFAULT_PATH:
console.info(f"Using custom Bun path: {bun_path}")
bun_version = get_bun_version()
@@ -1057,25 +1132,21 @@ def ensure_reflex_installation_id() -> Optional[int]:
"""
try:
initialize_reflex_user_directory()
- installation_id_file = os.path.join(constants.Reflex.DIR, "installation_id")
+ installation_id_file = environment.REFLEX_DIR.get() / "installation_id"
installation_id = None
- if os.path.exists(installation_id_file):
- try:
- with open(installation_id_file, "r") as f:
- installation_id = int(f.read())
- except Exception:
+ if installation_id_file.exists():
+ with contextlib.suppress(Exception):
+ installation_id = int(installation_id_file.read_text())
# If anything goes wrong at all... just regenerate.
# Like what? Examples:
# - file not exists
# - file not readable
# - content not parseable as an int
- pass
if installation_id is None:
installation_id = random.getrandbits(128)
- with open(installation_id_file, "w") as f:
- f.write(str(installation_id))
+ installation_id_file.write_text(str(installation_id))
# If we get here, installation_id is definitely set
return installation_id
except Exception as e:
@@ -1086,7 +1157,7 @@ def ensure_reflex_installation_id() -> Optional[int]:
def initialize_reflex_user_directory():
"""Initialize the reflex user directory."""
# Create the reflex directory.
- path_ops.mkdir(constants.Reflex.DIR)
+ path_ops.mkdir(environment.REFLEX_DIR.get())
def initialize_frontend_dependencies():
@@ -1103,13 +1174,34 @@ def initialize_frontend_dependencies():
initialize_web_directory()
+def check_db_used() -> bool:
+ """Check if the database is used.
+
+ Returns:
+ True if the database is used.
+ """
+ return bool(get_config().db_url)
+
+
+def check_redis_used() -> bool:
+ """Check if Redis is used.
+
+ Returns:
+ True if Redis is used.
+ """
+ return bool(get_config().redis_url)
+
+
def check_db_initialized() -> bool:
"""Check if the database migrations are initialized.
Returns:
True if alembic is initialized (or if database is not used).
"""
- if get_config().db_url is not None and not Path(constants.ALEMBIC_CONFIG).exists():
+ if (
+ get_config().db_url is not None
+ and not environment.ALEMBIC_CONFIG.get().exists()
+ ):
console.error(
"Database is not initialized. Run [bold]reflex db init[/bold] first."
)
@@ -1119,7 +1211,7 @@ def check_db_initialized() -> bool:
def check_schema_up_to_date():
"""Check if the sqlmodel metadata matches the current database schema."""
- if get_config().db_url is None or not Path(constants.ALEMBIC_CONFIG).exists():
+ if get_config().db_url is None or not environment.ALEMBIC_CONFIG.get().exists():
return
with model.Model.get_db_engine().connect() as connection:
try:
@@ -1138,7 +1230,7 @@ def check_schema_up_to_date():
)
-def prompt_for_template(templates: list[Template]) -> str:
+def prompt_for_template_options(templates: list[Template]) -> str:
"""Prompt the user to specify a template.
Args:
@@ -1150,9 +1242,14 @@ def prompt_for_template(templates: list[Template]) -> str:
# Show the user the URLs of each template to preview.
console.print("\nGet started with a template:")
+ def format_demo_url_str(url: str) -> str:
+ return f" ({url})" if url else ""
+
# Prompt the user to select a template.
id_to_name = {
- str(idx): f"{template.name} ({template.demo_url}) - {template.description}"
+ str(
+ idx
+ ): f"{template.name.replace('_', ' ').replace('-', ' ')}{format_demo_url_str(template.demo_url)} - {template.description}"
for idx, template in enumerate(templates)
}
for id in range(len(id_to_name)):
@@ -1169,158 +1266,6 @@ def prompt_for_template(templates: list[Template]) -> str:
return templates[int(template)].name
-def should_show_rx_chakra_migration_instructions() -> bool:
- """Should we show the migration instructions for rx.chakra.* => rx.*?.
-
- Returns:
- bool: True if we should show the migration instructions.
- """
- if os.getenv("REFLEX_PROMPT_MIGRATE_TO_RX_CHAKRA") == "yes":
- return True
-
- if not Path(constants.Config.FILE).exists():
- # They are running reflex init for the first time.
- return False
-
- existing_init_reflex_version = None
- reflex_json = get_web_dir() / constants.Dirs.REFLEX_JSON
- if reflex_json.exists():
- with reflex_json.open("r") as f:
- data = json.load(f)
- existing_init_reflex_version = data.get("version", None)
-
- if existing_init_reflex_version is None:
- # They clone a reflex app from git for the first time.
- # That app may or may not be 0.4 compatible.
- # So let's just show these instructions THIS TIME.
- return True
-
- if constants.Reflex.VERSION < "0.4":
- return False
- else:
- return existing_init_reflex_version < "0.4"
-
-
-def show_rx_chakra_migration_instructions():
- """Show the migration instructions for rx.chakra.* => rx.*."""
- console.log(
- "Prior to reflex 0.4.0, rx.* components are based on Chakra UI. They are now based on Radix UI. To stick to Chakra UI, use rx.chakra.*."
- )
- console.log("")
- console.log(
- "[bold]Run `reflex script keep-chakra` to automatically update your app."
- )
- console.log("")
- console.log(
- "For more details, please see https://reflex.dev/blog/2024-02-16-reflex-v0.4.0/"
- )
-
-
-def migrate_to_rx_chakra():
- """Migrate rx.button => r.chakra.button, etc."""
- file_pattern = os.path.join(get_config().app_name, "**/*.py")
- file_list = glob.glob(file_pattern, recursive=True)
-
- # Populate with all rx. components that have been moved to rx.chakra.
- patterns = {
- rf"\brx\.{name}\b": f"rx.chakra.{name}"
- for name in _get_rx_chakra_component_to_migrate()
- }
-
- for file_path in file_list:
- with FileInput(file_path, inplace=True) as file:
- for _line_num, line in enumerate(file):
- for old, new in patterns.items():
- line = re.sub(old, new, line)
- print(line, end="")
-
-
-def _get_rx_chakra_component_to_migrate() -> set[str]:
- from reflex.components.chakra import ChakraComponent
-
- rx_chakra_names = set(dir(reflex.chakra))
-
- names_to_migrate = set()
-
- # whitelist names will always be rewritten as rx.chakra.
- whitelist = {
- "ColorModeIcon",
- "MultiSelect",
- "MultiSelectOption",
- "color_mode_icon",
- "multi_select",
- "multi_select_option",
- }
-
- for rx_chakra_name in sorted(rx_chakra_names):
- if rx_chakra_name.startswith("_"):
- continue
-
- rx_chakra_object = getattr(reflex.chakra, rx_chakra_name)
- try:
- if (
- (
- inspect.ismethod(rx_chakra_object)
- and inspect.isclass(rx_chakra_object.__self__)
- and issubclass(rx_chakra_object.__self__, ChakraComponent)
- )
- or (
- inspect.isclass(rx_chakra_object)
- and issubclass(rx_chakra_object, ChakraComponent)
- )
- or rx_chakra_name in whitelist
- ):
- names_to_migrate.add(rx_chakra_name)
-
- except Exception:
- raise
- return names_to_migrate
-
-
-def migrate_to_reflex():
- """Migration from Pynecone to Reflex."""
- # Check if the old config file exists.
- if not os.path.exists(constants.Config.PREVIOUS_FILE):
- return
-
- # Ask the user if they want to migrate.
- action = console.ask(
- "Pynecone project detected. Automatically upgrade to Reflex?",
- choices=["y", "n"],
- )
- if action == "n":
- return
-
- # Rename pcconfig to rxconfig.
- console.log(
- f"[bold]Renaming {constants.Config.PREVIOUS_FILE} to {constants.Config.FILE}"
- )
- os.rename(constants.Config.PREVIOUS_FILE, constants.Config.FILE)
-
- # Find all python files in the app directory.
- file_pattern = os.path.join(get_config().app_name, "**/*.py")
- file_list = glob.glob(file_pattern, recursive=True)
-
- # Add the config file to the list of files to be migrated.
- file_list.append(constants.Config.FILE)
-
- # Migrate all files.
- updates = {
- "Pynecone": "Reflex",
- "pynecone as pc": "reflex as rx",
- "pynecone.io": "reflex.dev",
- "pynecone": "reflex",
- "pc.": "rx.",
- "pcconfig": "rxconfig",
- }
- for file_path in file_list:
- with FileInput(file_path, inplace=True) as file:
- for line in file:
- for old, new in updates.items():
- line = line.replace(old, new)
- print(line, end="")
-
-
def fetch_app_templates(version: str) -> dict[str, Template]:
"""Fetch a dict of templates from the templates repo using github API.
@@ -1332,7 +1277,7 @@ def fetch_app_templates(version: str) -> dict[str, Template]:
"""
def get_release_by_tag(tag: str) -> dict | None:
- response = httpx.get(constants.Reflex.RELEASES_URL)
+ response = net.get(constants.Reflex.RELEASES_URL)
response.raise_for_status()
releases = response.json()
for release in releases:
@@ -1353,7 +1298,7 @@ def fetch_app_templates(version: str) -> dict[str, Template]:
else:
templates_url = asset["browser_download_url"]
- templates_data = httpx.get(templates_url, follow_redirects=True).json()["templates"]
+ templates_data = net.get(templates_url, follow_redirects=True).json()["templates"]
for template in templates_data:
if template["name"] == "blank":
@@ -1367,11 +1312,16 @@ def fetch_app_templates(version: str) -> dict[str, Template]:
),
None,
)
- return {
- tp["name"]: Template.parse_obj(tp)
- for tp in templates_data
- if not tp["hidden"] and tp["code_url"] is not None
- }
+
+ filtered_templates = {}
+ for tp in templates_data:
+ if tp["hidden"] or tp["code_url"] is None:
+ continue
+ known_fields = {f.name for f in dataclasses.fields(Template)}
+ filtered_templates[tp["name"]] = Template(
+ **{k: v for k, v in tp.items() if k in known_fields}
+ )
+ return filtered_templates
def create_config_init_app_from_remote_template(app_name: str, template_url: str):
@@ -1393,19 +1343,18 @@ def create_config_init_app_from_remote_template(app_name: str, template_url: str
raise typer.Exit(1) from ose
# Use httpx GET with redirects to download the zip file.
- zip_file_path = Path(temp_dir) / "template.zip"
+ zip_file_path: Path = Path(temp_dir) / "template.zip"
try:
# Note: following redirects can be risky. We only allow this for reflex built templates at the moment.
- response = httpx.get(template_url, follow_redirects=True)
+ response = net.get(template_url, follow_redirects=True)
console.debug(f"Server responded download request: {response}")
response.raise_for_status()
except httpx.HTTPError as he:
console.error(f"Failed to download the template: {he}")
raise typer.Exit(1) from he
try:
- with open(zip_file_path, "wb") as f:
- f.write(response.content)
- console.debug(f"Downloaded the zip to {zip_file_path}")
+ zip_file_path.write_bytes(response.content)
+ console.debug(f"Downloaded the zip to {zip_file_path}")
except OSError as ose:
console.error(f"Unable to write the downloaded zip to disk {ose}")
raise typer.Exit(1) from ose
@@ -1454,70 +1403,197 @@ def create_config_init_app_from_remote_template(app_name: str, template_url: str
shutil.rmtree(unzip_dir)
-def initialize_app(app_name: str, template: str | None = None):
+def initialize_default_app(app_name: str):
+ """Initialize the default app.
+
+ Args:
+ app_name: The name of the app.
+ """
+ create_config(app_name)
+ initialize_app_directory(app_name)
+
+
+def validate_and_create_app_using_remote_template(app_name, template, templates):
+ """Validate and create an app using a remote template.
+
+ Args:
+ app_name: The name of the app.
+ template: The name of the template.
+ templates: The available templates.
+
+ Raises:
+ Exit: If the template is not found.
+ """
+ # If user selects a template, it needs to exist.
+ if template in templates:
+ from reflex_cli.v2.utils import hosting
+
+ authenticated_token = hosting.authenticated_token()
+ if not authenticated_token or not authenticated_token[0]:
+ console.print(
+ f"Please use `reflex login` to access the '{template}' template."
+ )
+ raise typer.Exit(3)
+
+ template_url = templates[template].code_url
+ else:
+ # Check if the template is a github repo.
+ if template.startswith("https://github.com"):
+ template_url = f"{template.strip('/').replace('.git', '')}/archive/main.zip"
+ else:
+ console.error(f"Template `{template}` not found or invalid.")
+ raise typer.Exit(1)
+
+ if template_url is None:
+ return
+
+ create_config_init_app_from_remote_template(
+ app_name=app_name, template_url=template_url
+ )
+
+
+def generate_template_using_ai(template: str | None = None) -> str:
+ """Generate a template using AI(Flexgen).
+
+ Args:
+ template: The name of the template.
+
+ Returns:
+ The generation hash.
+
+ Raises:
+ Exit: If the template and ai flags are used.
+ """
+ if template is None:
+ # If AI is requested and no template specified, redirect the user to reflex.build.
+ return redir.reflex_build_redirect()
+ elif is_generation_hash(template):
+ # Otherwise treat the template as a generation hash.
+ return template
+ else:
+ console.error(
+ "Cannot use `--template` option with `--ai` option. Please remove `--template` option."
+ )
+ raise typer.Exit(2)
+
+
+def fetch_remote_templates(
+ template: str,
+) -> tuple[str, dict[str, Template]]:
+ """Fetch the available remote templates.
+
+ Args:
+ template: The name of the template.
+
+ Returns:
+ The selected template and the available templates.
+ """
+ available_templates = {}
+
+ try:
+ # Get the available templates
+ available_templates = fetch_app_templates(constants.Reflex.VERSION)
+ except Exception as e:
+ console.warn("Failed to fetch templates. Falling back to default template.")
+ console.debug(f"Error while fetching templates: {e}")
+ template = constants.Templates.DEFAULT
+
+ return template, available_templates
+
+
+def initialize_app(
+ app_name: str, template: str | None = None, ai: bool = False
+) -> str | None:
"""Initialize the app either from a remote template or a blank app. If the config file exists, it is considered as reinit.
Args:
app_name: The name of the app.
template: The name of the template to use.
+ ai: Whether to use AI to generate the template.
+
+ Returns:
+ The name of the template.
Raises:
- Exit: If template is directly provided in the command flag and is invalid.
+ Exit: If the template is not valid or unspecified.
"""
# Local imports to avoid circular imports.
from reflex.utils import telemetry
# Check if the app is already initialized.
- if os.path.exists(constants.Config.FILE):
+ if constants.Config.FILE.exists():
telemetry.send("reinit")
return
+ generation_hash = None
+ if ai:
+ generation_hash = generate_template_using_ai(template)
+ template = constants.Templates.DEFAULT
+
templates: dict[str, Template] = {}
# Don't fetch app templates if the user directly asked for DEFAULT.
- if template is None or (template != constants.Templates.DEFAULT):
- try:
- # Get the available templates
- templates = fetch_app_templates(constants.Reflex.VERSION)
- if template is None and len(templates) > 0:
- template = prompt_for_template(list(templates.values()))
- except Exception as e:
- console.warn("Failed to fetch templates. Falling back to default template.")
- console.debug(f"Error while fetching templates: {e}")
- finally:
- template = template or constants.Templates.DEFAULT
+ if template is not None and (template not in (constants.Templates.DEFAULT,)):
+ template, templates = fetch_remote_templates(template)
+
+ if template is None:
+ template = prompt_for_template_options(get_init_cli_prompt_options())
+ if template == constants.Templates.AI:
+ generation_hash = generate_template_using_ai()
+ # change to the default to allow creation of default app
+ template = constants.Templates.DEFAULT
+ elif template == constants.Templates.CHOOSE_TEMPLATES:
+ console.print(
+ f"Go to the templates page ({constants.Templates.REFLEX_TEMPLATES_URL}) and copy the command to init with a template."
+ )
+ raise typer.Exit(0)
# If the blank template is selected, create a blank app.
- if template == constants.Templates.DEFAULT:
+ if template in (constants.Templates.DEFAULT,):
# Default app creation behavior: a blank app.
- create_config(app_name)
- initialize_app_directory(app_name)
+ initialize_default_app(app_name)
else:
- # Fetch App templates from the backend server.
- console.debug(f"Available templates: {templates}")
-
- # If user selects a template, it needs to exist.
- if template in templates:
- template_url = templates[template].code_url
- else:
- # Check if the template is a github repo.
- if template.startswith("https://github.com"):
- template_url = (
- f"{template.strip('/').replace('.git', '')}/archive/main.zip"
- )
- else:
- console.error(f"Template `{template}` not found.")
- raise typer.Exit(1)
-
- if template_url is None:
- return
-
- create_config_init_app_from_remote_template(
- app_name=app_name, template_url=template_url
+ validate_and_create_app_using_remote_template(
+ app_name=app_name, template=template, templates=templates
)
+ # If a reflex.build generation hash is available, download the code and apply it to the main module.
+ if generation_hash:
+ initialize_main_module_index_from_generation(
+ app_name, generation_hash=generation_hash
+ )
telemetry.send("init", template=template)
+ return template
+
+
+def get_init_cli_prompt_options() -> list[Template]:
+ """Get the CLI options for initializing a Reflex app.
+
+ Returns:
+ The CLI options.
+ """
+ return [
+ Template(
+ name=constants.Templates.DEFAULT,
+ description="A blank Reflex app.",
+ demo_url=constants.Templates.DEFAULT_TEMPLATE_URL,
+ code_url="",
+ ),
+ Template(
+ name=constants.Templates.AI,
+ description="Generate a template using AI [Experimental]",
+ demo_url="",
+ code_url="",
+ ),
+ Template(
+ name=constants.Templates.CHOOSE_TEMPLATES,
+ description="Choose an existing template.",
+ demo_url="",
+ code_url="",
+ ),
+ ]
+
def initialize_main_module_index_from_generation(app_name: str, generation_hash: str):
"""Overwrite the `index` function in the main module with reflex.build generated code.
@@ -1525,19 +1601,37 @@ def initialize_main_module_index_from_generation(app_name: str, generation_hash:
Args:
app_name: The name of the app.
generation_hash: The generation hash from reflex.build.
+
+ Raises:
+ GeneratedCodeHasNoFunctionDefs: If the fetched code has no function definitions
+ (the refactored reflex code is expected to have at least one root function defined).
"""
# Download the reflex code for the generation.
- resp = httpx.get(
- constants.Templates.REFLEX_BUILD_CODE_URL.format(
- generation_hash=generation_hash
+ url = constants.Templates.REFLEX_BUILD_CODE_URL.format(
+ generation_hash=generation_hash
+ )
+ resp = net.get(url)
+ while resp.status_code == httpx.codes.SERVICE_UNAVAILABLE:
+ console.debug("Waiting for the code to be generated...")
+ time.sleep(1)
+ resp = net.get(url)
+ resp.raise_for_status()
+
+ # Determine the name of the last function, which renders the generated code.
+ defined_funcs = re.findall(r"def ([a-zA-Z_]+)\(", resp.text)
+ if not defined_funcs:
+ raise GeneratedCodeHasNoFunctionDefs(
+ f"No function definitions found in generated code from {url!r}."
)
- ).raise_for_status()
+ render_func_name = defined_funcs[-1]
def replace_content(_match):
return "\n".join(
[
- "def index() -> rx.Component:",
- textwrap.indent("return " + resp.text, " "),
+ resp.text,
+ "",
+ "" "def index() -> rx.Component:",
+ f" return {render_func_name}()",
"",
"",
],
@@ -1545,13 +1639,20 @@ def initialize_main_module_index_from_generation(app_name: str, generation_hash:
main_module_path = Path(app_name, app_name + constants.Ext.PY)
main_module_code = main_module_path.read_text()
- main_module_path.write_text(
- re.sub(
- r"def index\(\).*:\n([^\n]\s+.*\n+)+",
- replace_content,
- main_module_code,
- )
+
+ main_module_code = re.sub(
+ r"def index\(\).*:\n([^\n]\s+.*\n+)+",
+ replace_content,
+ main_module_code,
)
+ # Make the app use light mode until flexgen enforces the conversion of
+ # tailwind colors to radix colors.
+ main_module_code = re.sub(
+ r"app\s*=\s*rx\.App\(\s*\)",
+ 'app = rx.App(theme=rx.theme(color_mode="light"))',
+ main_module_code,
+ )
+ main_module_path.write_text(main_module_code)
def format_address_width(address_width) -> int | None:
diff --git a/reflex/utils/processes.py b/reflex/utils/processes.py
index c435af7d0..871b5f323 100644
--- a/reflex/utils/processes.py
+++ b/reflex/utils/processes.py
@@ -58,7 +58,9 @@ def get_process_on_port(port) -> Optional[psutil.Process]:
The process on the given port.
"""
for proc in psutil.process_iter(["pid", "name", "cmdline"]):
- try:
+ with contextlib.suppress(
+ psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess
+ ):
if importlib.metadata.version("psutil") >= "6.0.0":
conns = proc.net_connections(kind="inet") # type: ignore
else:
@@ -66,8 +68,6 @@ def get_process_on_port(port) -> Optional[psutil.Process]:
for conn in conns:
if conn.laddr.port == int(port):
return proc
- except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
- pass
return None
@@ -118,7 +118,7 @@ def handle_port(service_name: str, port: str, default_port: str) -> str:
"""Change port if the specified port is in use and is not explicitly specified as a CLI arg or config arg.
otherwise tell the user the port is in use and exit the app.
- We make an assumption that when port is the default port,then it hasnt been explicitly set since its not straightforward
+ We make an assumption that when port is the default port,then it hasn't been explicitly set since its not straightforward
to know whether a port was explicitly provided by the user unless its any other than the default.
Args:
@@ -156,7 +156,7 @@ def new_process(args, run: bool = False, show_logs: bool = False, **kwargs):
Raises:
Exit: When attempting to run a command with a None value.
"""
- node_bin_path = path_ops.get_node_bin_path()
+ node_bin_path = str(path_ops.get_node_bin_path())
if not node_bin_path and not prerequisites.CURRENTLY_INSTALLING_NODE:
console.warn(
"The path to the Node binary could not be found. Please ensure that Node is properly "
@@ -167,7 +167,7 @@ def new_process(args, run: bool = False, show_logs: bool = False, **kwargs):
console.error(f"Invalid command: {args}")
raise typer.Exit(1)
# Add the node bin path to the PATH environment variable.
- env = {
+ env: dict[str, str] = {
**os.environ,
"PATH": os.pathsep.join(
[node_bin_path if node_bin_path else "", os.environ["PATH"]]
@@ -351,7 +351,7 @@ def atexit_handler():
def get_command_with_loglevel(command: list[str]) -> list[str]:
"""Add the right loglevel flag to the designated command.
- npm uses --loglevel , Bun doesnt use the --loglevel flag and
+ npm uses --loglevel , Bun doesn't use the --loglevel flag and
runs in debug mode by default.
Args:
@@ -364,7 +364,7 @@ def get_command_with_loglevel(command: list[str]) -> list[str]:
npm_path = str(Path(npm_path).resolve()) if npm_path else npm_path
if command[0] == npm_path:
- return command + ["--loglevel", "silly"]
+ return [*command, "--loglevel", "silly"]
return command
diff --git a/reflex/utils/pyi_generator.py b/reflex/utils/pyi_generator.py
index d279e3910..6a4bd63f8 100644
--- a/reflex/utils/pyi_generator.py
+++ b/reflex/utils/pyi_generator.py
@@ -16,15 +16,15 @@ from itertools import chain
from multiprocessing import Pool, cpu_count
from pathlib import Path
from types import ModuleType, SimpleNamespace
-from typing import Any, Callable, Iterable, Type, get_args
+from typing import Any, Callable, Iterable, Sequence, Type, get_args, get_origin
from reflex.components.component import Component
from reflex.utils import types as rx_types
-from reflex.vars import Var
+from reflex.vars.base import Var
logger = logging.getLogger("pyi_generator")
-PWD = Path(".").resolve()
+PWD = Path.cwd()
EXCLUDED_FILES = [
"app.py",
@@ -69,10 +69,17 @@ DEFAULT_TYPING_IMPORTS = {
# TODO: fix import ordering and unused imports with ruff later
DEFAULT_IMPORTS = {
"typing": sorted(DEFAULT_TYPING_IMPORTS),
- "reflex.vars": ["Var", "BaseVar", "ComputedVar"],
"reflex.components.core.breakpoints": ["Breakpoints"],
- "reflex.event": ["EventChain", "EventHandler", "EventSpec"],
+ "reflex.event": [
+ "EventChain",
+ "EventHandler",
+ "EventSpec",
+ "EventType",
+ "BASE_STATE",
+ "KeyInputInfo",
+ ],
"reflex.style": ["Style"],
+ "reflex.vars.base": ["Var"],
}
@@ -150,7 +157,7 @@ def _get_type_hint(value, type_hint_globals, is_optional=True) -> str:
if args:
inner_container_type_args = (
- [repr(arg) for arg in args]
+ sorted((repr(arg) for arg in args))
if rx_types.is_literal(value)
else [
_get_type_hint(arg, type_hint_globals, is_optional=False)
@@ -184,17 +191,12 @@ def _get_type_hint(value, type_hint_globals, is_optional=True) -> str:
if arg is not type(None)
]
if len(types) > 1:
- res = ", ".join(types)
+ res = ", ".join(sorted(types))
res = f"Union[{res}]"
elif isinstance(value, str):
ev = eval(value, type_hint_globals)
if rx_types.is_optional(ev):
- # hints = {
- # _get_type_hint(arg, type_hint_globals, is_optional=False)
- # for arg in ev.__args__
- # }
return _get_type_hint(ev, type_hint_globals, is_optional=False)
- # return f"Optional[{', '.join(hints)}]"
if rx_types.is_union(ev):
res = [
@@ -214,7 +216,9 @@ def _get_type_hint(value, type_hint_globals, is_optional=True) -> str:
return res
-def _generate_imports(typing_imports: Iterable[str]) -> list[ast.ImportFrom]:
+def _generate_imports(
+ typing_imports: Iterable[str],
+) -> list[ast.ImportFrom | ast.Import]:
"""Generate the import statements for the stub file.
Args:
@@ -228,6 +232,7 @@ def _generate_imports(typing_imports: Iterable[str]) -> list[ast.ImportFrom]:
ast.ImportFrom(module=name, names=[ast.alias(name=val) for val in values])
for name, values in DEFAULT_IMPORTS.items()
],
+ ast.Import([ast.alias("reflex")]),
]
@@ -250,8 +255,15 @@ def _generate_docstrings(clzs: list[Type[Component]], props: list[str]) -> str:
# We've reached the functions, so stop.
break
+ if line == "":
+ # We hit a blank line, so clear comments to avoid commented out prop appearing in next prop docs.
+ comments.clear()
+ continue
+
# Get comments for prop
if line.strip().startswith("#"):
+ # Remove noqa from the comments.
+ line = line.partition(" # noqa")[0]
comments.append(line)
continue
@@ -275,10 +287,9 @@ def _generate_docstrings(clzs: list[Type[Component]], props: list[str]) -> str:
for line in (clz.create.__doc__ or "").splitlines():
if "**" in line:
indent = line.split("**")[0]
- for nline in [
- f"{indent}{n}:{' '.join(c)}" for n, c in props_comments.items()
- ]:
- new_docstring.append(nline)
+ new_docstring.extend(
+ [f"{indent}{n}:{' '.join(c)}" for n, c in props_comments.items()]
+ )
new_docstring.append(line)
return "\n".join(new_docstring)
@@ -372,6 +383,64 @@ def _extract_class_props_as_ast_nodes(
return kwargs
+def type_to_ast(typ, cls: type) -> ast.AST:
+ """Converts any type annotation into its AST representation.
+ Handles nested generic types, unions, etc.
+
+ Args:
+ typ: The type annotation to convert.
+ cls: The class where the type annotation is used.
+
+ Returns:
+ The AST representation of the type annotation.
+ """
+ if typ is type(None):
+ return ast.Name(id="None")
+
+ origin = get_origin(typ)
+
+ # Handle plain types (int, str, custom classes, etc.)
+ if origin is None:
+ if hasattr(typ, "__name__"):
+ if typ.__module__.startswith("reflex."):
+ typ_parts = typ.__module__.split(".")
+ cls_parts = cls.__module__.split(".")
+
+ zipped = list(zip(typ_parts, cls_parts, strict=False))
+
+ if all(a == b for a, b in zipped) and len(typ_parts) == len(cls_parts):
+ return ast.Name(id=typ.__name__)
+
+ return ast.Name(id=typ.__module__ + "." + typ.__name__)
+ return ast.Name(id=typ.__name__)
+ elif hasattr(typ, "_name"):
+ return ast.Name(id=typ._name)
+ return ast.Name(id=str(typ))
+
+ # Get the base type name (List, Dict, Optional, etc.)
+ base_name = origin._name if hasattr(origin, "_name") else origin.__name__
+
+ # Get type arguments
+ args = get_args(typ)
+
+ # Handle empty type arguments
+ if not args:
+ return ast.Name(id=base_name)
+
+ # Convert all type arguments recursively
+ arg_nodes = [type_to_ast(arg, cls) for arg in args]
+
+ # Special case for single-argument types (like List[T] or Optional[T])
+ if len(arg_nodes) == 1:
+ slice_value = arg_nodes[0]
+ else:
+ slice_value = ast.Tuple(elts=arg_nodes, ctx=ast.Load())
+
+ return ast.Subscript(
+ value=ast.Name(id=base_name), slice=ast.Index(value=slice_value), ctx=ast.Load()
+ )
+
+
def _get_parent_imports(func):
_imports = {"reflex.vars": ["Var"]}
for type_hint in inspect.get_annotations(func).values():
@@ -427,19 +496,117 @@ def _generate_component_create_functiondef(
all_props = [arg[0].arg for arg in prop_kwargs]
kwargs.extend(prop_kwargs)
+ def figure_out_return_type(annotation: Any):
+ if inspect.isclass(annotation) and issubclass(annotation, inspect._empty):
+ return ast.Name(id="EventType[..., BASE_STATE]")
+
+ if not isinstance(annotation, str) and get_origin(annotation) is tuple:
+ arguments = get_args(annotation)
+
+ arguments_without_var = [
+ get_args(argument)[0] if get_origin(argument) == Var else argument
+ for argument in arguments
+ ]
+
+ # Convert each argument type to its AST representation
+ type_args = [type_to_ast(arg, cls=clz) for arg in arguments_without_var]
+
+ # Get all prefixes of the type arguments
+ all_count_args_type = [
+ ast.Name(
+ f"EventType[[{', '.join([ast.unparse(arg) for arg in type_args[:i]])}], BASE_STATE]"
+ )
+ for i in range(len(type_args) + 1)
+ ]
+
+ # Create EventType using the joined string
+ return ast.Name(
+ id=f"Union[{', '.join(map(ast.unparse, all_count_args_type))}]"
+ )
+
+ if isinstance(annotation, str) and annotation.startswith("Tuple["):
+ inside_of_tuple = annotation.removeprefix("Tuple[").removesuffix("]")
+
+ if inside_of_tuple == "()":
+ return ast.Name(id="EventType[[], BASE_STATE]")
+
+ arguments = [""]
+
+ bracket_count = 0
+
+ for char in inside_of_tuple:
+ if char == "[":
+ bracket_count += 1
+ elif char == "]":
+ bracket_count -= 1
+
+ if char == "," and bracket_count == 0:
+ arguments.append("")
+ else:
+ arguments[-1] += char
+
+ arguments = [argument.strip() for argument in arguments]
+
+ arguments_without_var = [
+ argument.removeprefix("Var[").removesuffix("]")
+ if argument.startswith("Var[")
+ else argument
+ for argument in arguments
+ ]
+
+ all_count_args_type = [
+ ast.Name(
+ f"EventType[[{', '.join(arguments_without_var[:i])}], BASE_STATE]"
+ )
+ for i in range(len(arguments) + 1)
+ ]
+
+ return ast.Name(
+ id=f"Union[{', '.join(map(ast.unparse, all_count_args_type))}]"
+ )
+ return ast.Name(id="EventType[..., BASE_STATE]")
+
+ event_triggers = clz().get_event_triggers()
+
# event handler kwargs
kwargs.extend(
(
ast.arg(
arg=trigger,
- annotation=ast.Name(
- id="Optional[Union[EventHandler, EventSpec, list, Callable, BaseVar]]"
+ annotation=ast.Subscript(
+ ast.Name("Optional"),
+ ast.Index( # type: ignore
+ value=ast.Name(
+ id=ast.unparse(
+ figure_out_return_type(
+ inspect.signature(event_specs).return_annotation
+ )
+ if not isinstance(
+ event_specs := event_triggers[trigger], Sequence
+ )
+ else ast.Subscript(
+ ast.Name("Union"),
+ ast.Tuple(
+ [
+ figure_out_return_type(
+ inspect.signature(
+ event_spec
+ ).return_annotation
+ )
+ for event_spec in event_specs
+ ]
+ ),
+ )
+ )
+ )
+ ),
),
),
ast.Constant(value=None),
)
- for trigger in sorted(clz().get_event_triggers())
+ for trigger in sorted(event_triggers)
)
+
logger.debug(f"Generated {clz.__name__}.create method with {len(kwargs)} kwargs")
create_args = ast.arguments(
args=[ast.arg(arg="cls")],
@@ -450,12 +617,17 @@ def _generate_component_create_functiondef(
kwarg=ast.arg(arg="props"),
defaults=[],
)
+
definition = ast.FunctionDef(
name="create",
args=create_args,
body=[
ast.Expr(
- value=ast.Constant(value=_generate_docstrings(all_classes, all_props))
+ value=ast.Constant(
+ value=_generate_docstrings(
+ all_classes, [*all_props, *event_triggers]
+ )
+ ),
),
ast.Expr(
value=ast.Ellipsis(),
@@ -664,7 +836,7 @@ class StubGenerator(ast.NodeTransformer):
self.inserted_imports = True
default_imports = _generate_imports(self.typing_imports)
self.import_statements.extend(ast.unparse(i) for i in default_imports)
- return default_imports + [node]
+ return [*default_imports, node]
return node
def visit_ImportFrom(
@@ -851,7 +1023,7 @@ class InitStubGenerator(StubGenerator):
class PyiGenerator:
"""A .pyi file generator that will scan all defined Component in Reflex and
- generate the approriate stub.
+ generate the appropriate stub.
"""
modules: list = []
@@ -902,7 +1074,13 @@ class PyiGenerator:
# construct the import statement and handle special cases for aliases
sub_mod_attrs_imports = [
f"from .{path} import {mod if not isinstance(mod, tuple) else mod[0]} as {mod if not isinstance(mod, tuple) else mod[1]}"
- + (" # type: ignore" if mod in pyright_ignore_imports else "")
+ + (
+ " # type: ignore"
+ if mod in pyright_ignore_imports
+ else " # noqa" # ignore ruff formatting here for cases like rx.list.
+ if isinstance(mod, tuple)
+ else ""
+ )
for mod, path in sub_mod_attrs.items()
]
sub_mod_attrs_imports.append("")
diff --git a/reflex/utils/redir.py b/reflex/utils/redir.py
index 1dbd989e9..b35cbe26e 100644
--- a/reflex/utils/redir.py
+++ b/reflex/utils/redir.py
@@ -10,6 +10,18 @@ from .. import constants
from . import console
+def open_browser(target_url: str) -> None:
+ """Open a browser window to target_url.
+
+ Args:
+ target_url: The URL to open in the browser.
+ """
+ if not webbrowser.open(target_url):
+ console.warn(
+ f"Unable to automatically open the browser. Please navigate to {target_url} in your browser."
+ )
+
+
def open_browser_and_wait(
target_url: str, poll_url: str, interval: int = 2
) -> httpx.Response:
@@ -23,10 +35,7 @@ def open_browser_and_wait(
Returns:
The response from the poll_url.
"""
- if not webbrowser.open(target_url):
- console.warn(
- f"Unable to automatically open the browser. Please navigate to {target_url} in your browser."
- )
+ open_browser(target_url)
console.info("[b]Complete the workflow in the browser to continue.[/b]")
while True:
try:
diff --git a/reflex/utils/registry.py b/reflex/utils/registry.py
index 551292f2d..d98178c61 100644
--- a/reflex/utils/registry.py
+++ b/reflex/utils/registry.py
@@ -2,7 +2,8 @@
import httpx
-from reflex.utils import console
+from reflex.config import environment
+from reflex.utils import console, net
def latency(registry: str) -> int:
@@ -15,7 +16,7 @@ def latency(registry: str) -> int:
int: The latency of the registry in microseconds.
"""
try:
- return httpx.get(registry).elapsed.microseconds
+ return net.get(registry).elapsed.microseconds
except httpx.HTTPError:
console.info(f"Failed to connect to {registry}.")
return 10_000_000
@@ -34,7 +35,7 @@ def average_latency(registry, attempts: int = 3) -> int:
return sum(latency(registry) for _ in range(attempts)) // attempts
-def _get_best_registry() -> str:
+def get_best_registry() -> str:
"""Get the best registry based on latency.
Returns:
@@ -46,3 +47,12 @@ def _get_best_registry() -> str:
]
return min(registries, key=average_latency)
+
+
+def _get_npm_registry() -> str:
+ """Get npm registry. If environment variable is set, use it first.
+
+ Returns:
+ str:
+ """
+ return environment.NPM_CONFIG_REGISTRY.get() or get_best_registry()
diff --git a/reflex/utils/serializers.py b/reflex/utils/serializers.py
index 6c36647cc..4bb8dea92 100644
--- a/reflex/utils/serializers.py
+++ b/reflex/utils/serializers.py
@@ -2,9 +2,9 @@
from __future__ import annotations
+import dataclasses
import functools
import json
-import types as builtin_types
import warnings
from datetime import date, datetime, time, timedelta
from enum import Enum
@@ -12,13 +12,13 @@ from pathlib import Path
from typing import (
Any,
Callable,
- Dict,
List,
Literal,
Optional,
Set,
Tuple,
Type,
+ TypeVar,
Union,
get_type_hints,
overload,
@@ -26,24 +26,40 @@ from typing import (
from reflex.base import Base
from reflex.constants.colors import Color, format_color
-from reflex.utils import exceptions, types
+from reflex.utils import types
# Mapping from type to a serializer.
# The serializer should convert the type to a JSON object.
-SerializedType = Union[str, bool, int, float, list, dict]
+SerializedType = Union[str, bool, int, float, list, dict, None]
-Serializer = Callable[[Type], SerializedType]
+Serializer = Callable[[Any], SerializedType]
SERIALIZERS: dict[Type, Serializer] = {}
SERIALIZER_TYPES: dict[Type, Type] = {}
+SERIALIZED_FUNCTION = TypeVar("SERIALIZED_FUNCTION", bound=Serializer)
+
+
+@overload
+def serializer(
+ fn: None = None,
+ to: Type[SerializedType] | None = None,
+) -> Callable[[SERIALIZED_FUNCTION], SERIALIZED_FUNCTION]: ...
+
+
+@overload
+def serializer(
+ fn: SERIALIZED_FUNCTION,
+ to: Type[SerializedType] | None = None,
+) -> SERIALIZED_FUNCTION: ...
+
def serializer(
- fn: Serializer | None = None,
- to: Type | None = None,
-) -> Serializer:
+ fn: SERIALIZED_FUNCTION | None = None,
+ to: Any = None,
+) -> SERIALIZED_FUNCTION | Callable[[SERIALIZED_FUNCTION], SERIALIZED_FUNCTION]:
"""Decorator to add a serializer for a given type.
Args:
@@ -52,43 +68,44 @@ def serializer(
Returns:
The decorated function.
-
- Raises:
- ValueError: If the function does not take a single argument.
"""
- if fn is None:
- # If the function is not provided, return a partial that acts as a decorator.
- return functools.partial(serializer, to=to) # type: ignore
- # Check the type hints to get the type of the argument.
- type_hints = get_type_hints(fn)
- args = [arg for arg in type_hints if arg != "return"]
+ def wrapper(fn: SERIALIZED_FUNCTION) -> SERIALIZED_FUNCTION:
+ # Check the type hints to get the type of the argument.
+ type_hints = get_type_hints(fn)
+ args = [arg for arg in type_hints if arg != "return"]
- # Make sure the function takes a single argument.
- if len(args) != 1:
- raise ValueError("Serializer must take a single argument.")
+ # Make sure the function takes a single argument.
+ if len(args) != 1:
+ raise ValueError("Serializer must take a single argument.")
- # Get the type of the argument.
- type_ = type_hints[args[0]]
+ # Get the type of the argument.
+ type_ = type_hints[args[0]]
- # Make sure the type is not already registered.
- registered_fn = SERIALIZERS.get(type_)
- if registered_fn is not None and registered_fn != fn:
- raise ValueError(
- f"Serializer for type {type_} is already registered as {registered_fn.__qualname__}."
- )
+ # Make sure the type is not already registered.
+ registered_fn = SERIALIZERS.get(type_)
+ if registered_fn is not None and registered_fn != fn:
+ raise ValueError(
+ f"Serializer for type {type_} is already registered as {registered_fn.__qualname__}."
+ )
- # Apply type transformation if requested
- if to is not None:
- SERIALIZER_TYPES[type_] = to
- get_serializer_type.cache_clear()
+ to_type = to or type_hints.get("return")
- # Register the serializer.
- SERIALIZERS[type_] = fn
- get_serializer.cache_clear()
+ # Apply type transformation if requested
+ if to_type:
+ SERIALIZER_TYPES[type_] = to_type
+ get_serializer_type.cache_clear()
- # Return the function.
- return fn
+ # Register the serializer.
+ SERIALIZERS[type_] = fn
+ get_serializer.cache_clear()
+
+ # Return the function.
+ return fn
+
+ if fn is not None:
+ return wrapper(fn)
+ return wrapper
@overload
@@ -125,6 +142,9 @@ def serialize(
# If there is no serializer, return None.
if serializer is None:
+ if dataclasses.is_dataclass(value) and not isinstance(value, type):
+ return {k.name: getattr(value, k.name) for k in dataclasses.fields(value)}
+
if get_type:
return None, None
return None
@@ -187,16 +207,37 @@ def get_serializer_type(type_: Type) -> Optional[Type]:
return None
-def has_serializer(type_: Type) -> bool:
+def has_serializer(type_: Type, into_type: Type | None = None) -> bool:
"""Check if there is a serializer for the type.
Args:
type_: The type to check.
+ into_type: The type to serialize into.
Returns:
Whether there is a serializer for the type.
"""
- return get_serializer(type_) is not None
+ serializer_for_type = get_serializer(type_)
+ return serializer_for_type is not None and (
+ into_type is None or get_serializer_type(type_) == into_type
+ )
+
+
+def can_serialize(type_: Type, into_type: Type | None = None) -> bool:
+ """Check if there is a serializer for the type.
+
+ Args:
+ type_: The type to check.
+ into_type: The type to serialize into.
+
+ Returns:
+ Whether there is a serializer for the type.
+ """
+ return has_serializer(type_, into_type) or (
+ isinstance(type_, type)
+ and dataclasses.is_dataclass(type_)
+ and (into_type is None or into_type is dict)
+ )
@serializer(to=str)
@@ -212,36 +253,8 @@ def serialize_type(value: type) -> str:
return value.__name__
-@serializer
-def serialize_str(value: str) -> str:
- """Serialize a string.
-
- Args:
- value: The string to serialize.
-
- Returns:
- The serialized string.
- """
- return value
-
-
-@serializer
-def serialize_primitive(value: Union[bool, int, float, None]) -> str:
- """Serialize a primitive type.
-
- Args:
- value: The number/bool/None to serialize.
-
- Returns:
- The serialized number/bool/None.
- """
- from reflex.utils import format
-
- return format.json_dumps(value)
-
-
-@serializer
-def serialize_base(value: Base) -> str:
+@serializer(to=dict)
+def serialize_base(value: Base) -> dict:
"""Serialize a Base instance.
Args:
@@ -250,61 +263,71 @@ def serialize_base(value: Base) -> str:
Returns:
The serialized Base.
"""
- return value.json()
+ from reflex.vars.base import Var
+
+ return {
+ k: v for k, v in value.dict().items() if isinstance(v, Var) or not callable(v)
+ }
+
+
+try:
+ from pydantic.v1 import BaseModel as BaseModelV1
+
+ @serializer(to=dict)
+ def serialize_base_model_v1(model: BaseModelV1) -> dict:
+ """Serialize a pydantic v1 BaseModel instance.
+
+ Args:
+ model: The BaseModel to serialize.
+
+ Returns:
+ The serialized BaseModel.
+ """
+ return model.dict()
+
+ from pydantic import BaseModel as BaseModelV2
+
+ if BaseModelV1 is not BaseModelV2:
+
+ @serializer(to=dict)
+ def serialize_base_model_v2(model: BaseModelV2) -> dict:
+ """Serialize a pydantic v2 BaseModel instance.
+
+ Args:
+ model: The BaseModel to serialize.
+
+ Returns:
+ The serialized BaseModel.
+ """
+ return model.model_dump()
+except ImportError:
+ # Older pydantic v1 import
+ from pydantic import BaseModel as BaseModelV1
+
+ @serializer(to=dict)
+ def serialize_base_model_v1(model: BaseModelV1) -> dict:
+ """Serialize a pydantic v1 BaseModel instance.
+
+ Args:
+ model: The BaseModel to serialize.
+
+ Returns:
+ The serialized BaseModel.
+ """
+ return model.dict()
@serializer
-def serialize_list(value: Union[List, Tuple, Set]) -> str:
- """Serialize a list to a JSON string.
+def serialize_set(value: Set) -> list:
+ """Serialize a set to a JSON serializable list.
Args:
- value: The list to serialize.
+ value: The set to serialize.
Returns:
The serialized list.
"""
- from reflex.utils import format
-
- # Dump the list to a string.
- fprop = format.json_dumps(list(value))
-
- # Unwrap var values.
- return format.unwrap_vars(fprop)
-
-
-@serializer
-def serialize_dict(prop: Dict[str, Any]) -> str:
- """Serialize a dictionary to a JSON string.
-
- Args:
- prop: The dictionary to serialize.
-
- Returns:
- The serialized dictionary.
-
- Raises:
- InvalidStylePropError: If the style prop is invalid.
- """
- # Import here to avoid circular imports.
- from reflex.event import EventHandler
- from reflex.utils import format
-
- prop_dict = {}
-
- for key, value in prop.items():
- if types._issubclass(type(value), Callable):
- raise exceptions.InvalidStylePropError(
- f"The style prop `{format.to_snake_case(key)}` cannot have " # type: ignore
- f"`{value.fn.__qualname__ if isinstance(value, EventHandler) else value.__qualname__ if isinstance(value, builtin_types.FunctionType) else value}`, "
- f"an event handler or callable as its value"
- )
- prop_dict[key] = value
-
- # Dump the dict to a string.
- fprop = format.json_dumps(prop_dict)
-
- # Unwrap var values.
- return format.unwrap_vars(fprop)
+ return list(value)
@serializer(to=str)
diff --git a/reflex/utils/telemetry.py b/reflex/utils/telemetry.py
index e027ed81a..fc90932a6 100644
--- a/reflex/utils/telemetry.py
+++ b/reflex/utils/telemetry.py
@@ -3,9 +3,13 @@
from __future__ import annotations
import asyncio
+import dataclasses
import multiprocessing
import platform
import warnings
+from contextlib import suppress
+
+from reflex.config import environment
try:
from datetime import UTC, datetime
@@ -19,7 +23,6 @@ import psutil
from reflex import constants
from reflex.utils import console
-from reflex.utils.exec import should_skip_compile
from reflex.utils.prerequisites import ensure_reflex_installation_id, get_project_hash
POSTHOG_API_URL: str = "https://app.posthog.com/capture/"
@@ -49,7 +52,8 @@ def get_python_version() -> str:
Returns:
The Python version.
"""
- return platform.python_version()
+ # Remove the "+" from the version string in case user is using a pre-release version.
+ return platform.python_version().rstrip("+")
def get_reflex_version() -> str:
@@ -93,9 +97,7 @@ def _raise_on_missing_project_hash() -> bool:
False when compilation should be skipped (i.e. no .web directory is required).
Otherwise return True.
"""
- if should_skip_compile():
- return False
- return True
+ return not environment.REFLEX_SKIP_COMPILE.get()
def _prepare_event(event: str, **kwargs) -> dict:
@@ -120,7 +122,7 @@ def _prepare_event(event: str, **kwargs) -> dict:
return {}
if UTC is None:
- # for python 3.8, 3.9 & 3.10
+ # for python 3.9 & 3.10
stamp = datetime.utcnow().isoformat()
else:
# for python 3.11 & 3.12
@@ -128,7 +130,7 @@ def _prepare_event(event: str, **kwargs) -> dict:
cpuinfo = get_cpu_info()
- additional_keys = ["template", "context", "detail"]
+ additional_keys = ["template", "context", "detail", "user_uuid"]
additional_fields = {
key: value for key in additional_keys if (value := kwargs.get(key)) is not None
}
@@ -144,7 +146,7 @@ def _prepare_event(event: str, **kwargs) -> dict:
"python_version": get_python_version(),
"cpu_count": get_cpu_count(),
"memory": get_memory(),
- "cpu_info": dict(cpuinfo) if cpuinfo else {},
+ "cpu_info": dataclasses.asdict(cpuinfo) if cpuinfo else {},
**additional_fields,
},
"timestamp": stamp,
@@ -170,10 +172,11 @@ def _send(event, telemetry_enabled, **kwargs):
if not telemetry_enabled:
return False
- event_data = _prepare_event(event, **kwargs)
- if not event_data:
- return False
- return _send_event(event_data)
+ with suppress(Exception):
+ event_data = _prepare_event(event, **kwargs)
+ if not event_data:
+ return False
+ return _send_event(event_data)
def send(event: str, telemetry_enabled: bool | None = None, **kwargs):
diff --git a/reflex/utils/types.py b/reflex/utils/types.py
index 3bb5eae35..b8bcbf2d6 100644
--- a/reflex/utils/types.py
+++ b/reflex/utils/types.py
@@ -3,29 +3,35 @@
from __future__ import annotations
import contextlib
+import dataclasses
import inspect
import sys
import types
-from functools import cached_property, wraps
+from functools import cached_property, lru_cache, wraps
from typing import (
+ TYPE_CHECKING,
Any,
Callable,
ClassVar,
Dict,
+ FrozenSet,
Iterable,
List,
Literal,
+ Mapping,
Optional,
+ Sequence,
Tuple,
Type,
Union,
_GenericAlias, # type: ignore
get_args,
- get_origin,
get_type_hints,
)
+from typing import get_origin as get_origin_og
import sqlalchemy
+from typing_extensions import is_typeddict
import reflex
from reflex.components.core.breakpoints import Breakpoints
@@ -37,19 +43,14 @@ except ModuleNotFoundError:
from sqlalchemy.ext.associationproxy import AssociationProxyInstance
from sqlalchemy.ext.hybrid import hybrid_property
-from sqlalchemy.orm import (
- DeclarativeBase,
- Mapped,
- QueryableAttribute,
- Relationship,
-)
+from sqlalchemy.orm import DeclarativeBase, Mapped, QueryableAttribute, Relationship
from reflex import constants
from reflex.base import Base
from reflex.utils import console
if sys.version_info >= (3, 12):
- from typing import override
+ from typing import override as override
else:
def override(func: Callable) -> Callable:
@@ -93,8 +94,21 @@ PrimitiveType = Union[int, float, bool, str, list, dict, set, tuple]
StateVar = Union[PrimitiveType, Base, None]
StateIterVar = Union[list, set, tuple]
-# ArgsSpec = Callable[[Var], list[Var]]
-ArgsSpec = Callable
+if TYPE_CHECKING:
+ from reflex.vars.base import Var
+
+ ArgsSpec = (
+ Callable[[], Sequence[Var]]
+ | Callable[[Var], Sequence[Var]]
+ | Callable[[Var, Var], Sequence[Var]]
+ | Callable[[Var, Var, Var], Sequence[Var]]
+ | Callable[[Var, Var, Var, Var], Sequence[Var]]
+ | Callable[[Var, Var, Var, Var, Var], Sequence[Var]]
+ | Callable[[Var, Var, Var, Var, Var, Var], Sequence[Var]]
+ | Callable[[Var, Var, Var, Var, Var, Var, Var], Sequence[Var]]
+ )
+else:
+ ArgsSpec = Callable[..., List[Any]]
PrimitiveToAnnotation = {
@@ -109,6 +123,11 @@ RESERVED_BACKEND_VAR_NAMES = {
"_was_touched",
}
+if sys.version_info >= (3, 11):
+ from typing import Self as Self
+else:
+ from typing_extensions import Self as Self
+
class Unset:
"""A class to represent an unset value.
@@ -133,6 +152,20 @@ class Unset:
return False
+@lru_cache()
+def get_origin(tp):
+ """Get the origin of a class.
+
+ Args:
+ tp: The class to get the origin of.
+
+ Returns:
+ The origin of the class.
+ """
+ return get_origin_og(tp)
+
+
+@lru_cache()
def is_generic_alias(cls: GenericType) -> bool:
"""Check whether the class is a generic alias.
@@ -145,6 +178,26 @@ def is_generic_alias(cls: GenericType) -> bool:
return isinstance(cls, GenericAliasTypes)
+def unionize(*args: GenericType) -> Type:
+ """Unionize the types.
+
+ Args:
+ args: The types to unionize.
+
+ Returns:
+ The unionized types.
+ """
+ if not args:
+ return Any
+ if len(args) == 1:
+ return args[0]
+ # We are bisecting the args list here to avoid hitting the recursion limit
+ # In Python versions >= 3.11, we can simply do `return Union[*args]`
+ midpoint = len(args) // 2
+ first_half, second_half = args[:midpoint], args[midpoint:]
+ return Union[unionize(*first_half), unionize(*second_half)]
+
+
def is_none(cls: GenericType) -> bool:
"""Check if a class is None.
@@ -157,6 +210,7 @@ def is_none(cls: GenericType) -> bool:
return cls is type(None) or cls is None
+@lru_cache()
def is_union(cls: GenericType) -> bool:
"""Check if a class is a Union.
@@ -169,6 +223,7 @@ def is_union(cls: GenericType) -> bool:
return get_origin(cls) in UnionTypes
+@lru_cache()
def is_literal(cls: GenericType) -> bool:
"""Check if a class is a Literal.
@@ -181,6 +236,27 @@ def is_literal(cls: GenericType) -> bool:
return get_origin(cls) is Literal
+def has_args(cls) -> bool:
+ """Check if the class has generic parameters.
+
+ Args:
+ cls: The class to check.
+
+ Returns:
+ Whether the class has generic
+ """
+ if get_args(cls):
+ return True
+
+ # Check if the class inherits from a generic class (using __orig_bases__)
+ if hasattr(cls, "__orig_bases__"):
+ for base in cls.__orig_bases__:
+ if get_args(base):
+ return True
+
+ return False
+
+
def is_optional(cls: GenericType) -> bool:
"""Check if a class is an Optional.
@@ -193,6 +269,20 @@ def is_optional(cls: GenericType) -> bool:
return is_union(cls) and type(None) in get_args(cls)
+def value_inside_optional(cls: GenericType) -> GenericType:
+ """Get the value inside an Optional type or the original type.
+
+ Args:
+ cls: The class to check.
+
+ Returns:
+ The value inside the Optional type or the original type.
+ """
+ if is_union(cls) and len(args := get_args(cls)) >= 2 and type(None) in args:
+ return unionize(*[arg for arg in args if arg is not type(None)])
+ return cls
+
+
def get_property_hint(attr: Any | None) -> GenericType | None:
"""Check if an attribute is a property and return its type hint.
@@ -222,9 +312,14 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None
"""
from reflex.model import Model
- attr = getattr(cls, name, None)
+ try:
+ attr = getattr(cls, name, None)
+ except NotImplementedError:
+ attr = None
+
if hint := get_property_hint(attr):
return hint
+
if (
hasattr(cls, "__fields__")
and name in cls.__fields__
@@ -235,7 +330,11 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None
type_ = field.outer_type_
if isinstance(type_, ModelField):
type_ = type_.type_
- if not field.required and field.default is None:
+ if (
+ not field.required
+ and field.default is None
+ and field.default_factory is None
+ ):
# Ensure frontend uses null coalescing when accessing.
type_ = Optional[type_]
return type_
@@ -293,11 +392,9 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None
return type_
elif is_union(cls):
# Check in each arg of the annotation.
- for arg in get_args(cls):
- type_ = get_attribute_access_type(arg, name)
- if type_ is not None:
- # Return the first attribute type that is accessible.
- return type_
+ return unionize(
+ *(get_attribute_access_type(arg, name) for arg in get_args(cls))
+ )
elif isinstance(cls, type):
# Bare class
if sys.version_info >= (3, 10):
@@ -314,6 +411,7 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None
return None # Attribute is not accessible.
+@lru_cache()
def get_base_class(cls: GenericType) -> Type:
"""Get the base class of a class.
@@ -329,7 +427,7 @@ def get_base_class(cls: GenericType) -> Type:
if is_literal(cls):
# only literals of the same type are supported.
arg_type = type(get_args(cls)[0])
- if not all(type(arg) == arg_type for arg in get_args(cls)):
+ if not all(type(arg) is arg_type for arg in get_args(cls)):
raise TypeError("only literals of the same type are supported")
return type(get_args(cls)[0])
@@ -402,6 +500,14 @@ def _issubclass(cls: GenericType, cls_check: GenericType, instance: Any = None)
if isinstance(instance, Breakpoints):
return _breakpoints_satisfies_typing(cls_check, instance)
+ if isinstance(cls_check_base, tuple):
+ cls_check_base = tuple(
+ cls_check_one if not is_typeddict(cls_check_one) else dict
+ for cls_check_one in cls_check_base
+ )
+ if is_typeddict(cls_check_base):
+ cls_check_base = dict
+
# Check if the types match.
try:
return cls_check_base == Any or issubclass(cls_base, cls_check_base)
@@ -411,16 +517,112 @@ def _issubclass(cls: GenericType, cls_check: GenericType, instance: Any = None)
raise TypeError(f"Invalid type for issubclass: {cls_base}") from te
-def _isinstance(obj: Any, cls: GenericType) -> bool:
+def does_obj_satisfy_typed_dict(obj: Any, cls: GenericType) -> bool:
+ """Check if an object satisfies a typed dict.
+
+ Args:
+ obj: The object to check.
+ cls: The typed dict to check against.
+
+ Returns:
+ Whether the object satisfies the typed dict.
+ """
+ if not isinstance(obj, Mapping):
+ return False
+
+ key_names_to_values = get_type_hints(cls)
+ required_keys: FrozenSet[str] = getattr(cls, "__required_keys__", frozenset())
+
+ if not all(
+ isinstance(key, str)
+ and key in key_names_to_values
+ and _isinstance(value, key_names_to_values[key])
+ for key, value in obj.items()
+ ):
+ return False
+
+ # TODO in 3.14: Implement https://peps.python.org/pep-0728/ if it's approved
+
+ # required keys are all present
+ return required_keys.issubset(required_keys)
+
+
+def _isinstance(obj: Any, cls: GenericType, nested: bool = False) -> bool:
"""Check if an object is an instance of a class.
Args:
obj: The object to check.
cls: The class to check against.
+ nested: Whether the check is nested.
Returns:
Whether the object is an instance of the class.
"""
+ if cls is Any:
+ return True
+
+ if cls is None or cls is type(None):
+ return obj is None
+
+ if is_literal(cls):
+ return obj in get_args(cls)
+
+ if is_union(cls):
+ return any(_isinstance(obj, arg) for arg in get_args(cls))
+
+ origin = get_origin(cls)
+
+ if origin is None:
+ # cls is a typed dict
+ if is_typeddict(cls):
+ if nested:
+ return does_obj_satisfy_typed_dict(obj, cls)
+ return isinstance(obj, dict)
+
+ # cls is a float
+ if cls is float:
+ return isinstance(obj, (float, int))
+
+ # cls is a simple class
+ return isinstance(obj, cls)
+
+ args = get_args(cls)
+
+ if not args:
+ # cls is a simple generic class
+ return isinstance(obj, origin)
+
+ if nested and args:
+ if origin is list:
+ return isinstance(obj, list) and all(
+ _isinstance(item, args[0]) for item in obj
+ )
+ if origin is tuple:
+ if args[-1] is Ellipsis:
+ return isinstance(obj, tuple) and all(
+ _isinstance(item, args[0]) for item in obj
+ )
+ return (
+ isinstance(obj, tuple)
+ and len(obj) == len(args)
+ and all(_isinstance(item, arg) for item, arg in zip(obj, args))
+ )
+ if origin in (dict, Breakpoints):
+ return isinstance(obj, dict) and all(
+ _isinstance(key, args[0]) and _isinstance(value, args[1])
+ for key, value in obj.items()
+ )
+ if origin is set:
+ return isinstance(obj, set) and all(
+ _isinstance(item, args[0]) for item in obj
+ )
+
+ if args:
+ from reflex.vars import Field
+
+ if origin is Field:
+ return _isinstance(obj, args[0])
+
return isinstance(obj, get_base_class(cls))
@@ -451,7 +653,11 @@ def is_valid_var_type(type_: Type) -> bool:
if is_union(type_):
return all((is_valid_var_type(arg) for arg in get_args(type_)))
- return _issubclass(type_, StateVar) or serializers.has_serializer(type_)
+ return (
+ _issubclass(type_, StateVar)
+ or serializers.has_serializer(type_)
+ or dataclasses.is_dataclass(type_)
+ )
def is_backend_base_variable(name: str, cls: Type) -> bool:
@@ -476,7 +682,11 @@ def is_backend_base_variable(name: str, cls: Type) -> bool:
if name.startswith(f"_{cls.__name__}__"):
return False
- hints = get_type_hints(cls)
+ # Extract the namespace of the original module if defined (dynamic substates).
+ if callable(getattr(cls, "_get_type_hints", None)):
+ hints = cls._get_type_hints()
+ else:
+ hints = get_type_hints(cls)
if name in hints:
hint = get_origin(hints[name])
if hint == ClassVar:
@@ -485,17 +695,23 @@ def is_backend_base_variable(name: str, cls: Type) -> bool:
if name in cls.inherited_backend_vars:
return False
+ from reflex.vars.base import is_computed_var
+
if name in cls.__dict__:
value = cls.__dict__[name]
- if type(value) == classmethod:
+ if type(value) is classmethod:
return False
if callable(value):
return False
- from reflex.vars import ComputedVar
if isinstance(
- value, (types.FunctionType, property, cached_property, ComputedVar)
- ):
+ value,
+ (
+ types.FunctionType,
+ property,
+ cached_property,
+ ),
+ ) or is_computed_var(value):
return False
return True
@@ -570,7 +786,7 @@ def validate_literal(key: str, value: Any, expected_type: Type, comp_name: str):
)
value_str = f"'{value}'" if isinstance(value, str) else value
raise ValueError(
- f"prop value for {str(key)} of the `{comp_name}` component should be one of the following: {allowed_value_str}. Got {value_str} instead"
+ f"prop value for {key!s} of the `{comp_name}` component should be one of the following: {allowed_value_str}. Got {value_str} instead"
)
@@ -611,3 +827,69 @@ def validate_parameter_literals(func):
# Store this here for performance.
StateBases = get_base_class(StateVar)
StateIterBases = get_base_class(StateIterVar)
+
+
+def typehint_issubclass(possible_subclass: Any, possible_superclass: Any) -> bool:
+ """Check if a type hint is a subclass of another type hint.
+
+ Args:
+ possible_subclass: The type hint to check.
+ possible_superclass: The type hint to check against.
+
+ Returns:
+ Whether the type hint is a subclass of the other type hint.
+ """
+ if possible_superclass is Any:
+ return True
+ if possible_subclass is Any:
+ return False
+
+ provided_type_origin = get_origin(possible_subclass)
+ accepted_type_origin = get_origin(possible_superclass)
+
+ if provided_type_origin is None and accepted_type_origin is None:
+ # In this case, we are dealing with a non-generic type, so we can use issubclass
+ return issubclass(possible_subclass, possible_superclass)
+
+ # Remove this check when Python 3.10 is the minimum supported version
+ if hasattr(types, "UnionType"):
+ provided_type_origin = (
+ Union if provided_type_origin is types.UnionType else provided_type_origin
+ )
+ accepted_type_origin = (
+ Union if accepted_type_origin is types.UnionType else accepted_type_origin
+ )
+
+ # Get type arguments (e.g., [float, int] for Dict[float, int])
+ provided_args = get_args(possible_subclass)
+ accepted_args = get_args(possible_superclass)
+
+ if accepted_type_origin is Union:
+ if provided_type_origin is not Union:
+ return any(
+ typehint_issubclass(possible_subclass, accepted_arg)
+ for accepted_arg in accepted_args
+ )
+ return all(
+ any(
+ typehint_issubclass(provided_arg, accepted_arg)
+ for accepted_arg in accepted_args
+ )
+ for provided_arg in provided_args
+ )
+
+ # Check if the origin of both types is the same (e.g., list for List[int])
+ # This probably should be issubclass instead of ==
+ if (provided_type_origin or possible_subclass) != (
+ accepted_type_origin or possible_superclass
+ ):
+ return False
+
+ # Ensure all specific types are compatible with accepted types
+ # Note this is not necessarily correct, as it doesn't check against contravariance and covariance
+ # It also ignores when the length of the arguments is different
+ return all(
+ typehint_issubclass(provided_arg, accepted_arg)
+ for provided_arg, accepted_arg in zip(provided_args, accepted_args)
+ if accepted_arg is not Any
+ )
diff --git a/reflex/utils/watch.py b/reflex/utils/watch.py
deleted file mode 100644
index 39b177695..000000000
--- a/reflex/utils/watch.py
+++ /dev/null
@@ -1,96 +0,0 @@
-"""General utility functions."""
-
-import contextlib
-import os
-import shutil
-import time
-
-from watchdog.events import FileSystemEvent, FileSystemEventHandler
-from watchdog.observers import Observer
-
-from reflex.constants import Dirs
-from reflex.utils.prerequisites import get_web_dir
-
-
-class AssetFolderWatch:
- """Asset folder watch class."""
-
- def __init__(self, root):
- """Initialize the Watch Class.
-
- Args:
- root: root path of the public.
- """
- self.path = str(root / Dirs.APP_ASSETS)
- self.event_handler = AssetFolderHandler(root)
-
- def start(self):
- """Start watching asset folder."""
- self.observer = Observer()
- self.observer.schedule(self.event_handler, self.path, recursive=True)
- self.observer.start()
-
-
-class AssetFolderHandler(FileSystemEventHandler):
- """Asset folder event handler."""
-
- def __init__(self, root):
- """Initialize the AssetFolderHandler Class.
-
- Args:
- root: root path of the public.
- """
- super().__init__()
- self.root = root
-
- def on_modified(self, event: FileSystemEvent):
- """Event handler when a file or folder was modified.
-
- This is called every time after a file is created, modified and deleted.
-
- Args:
- event: Event information.
- """
- dest_path = self.get_dest_path(event.src_path)
-
- # wait 1 sec for fully saved
- time.sleep(1)
-
- if os.path.isfile(event.src_path):
- with contextlib.suppress(PermissionError):
- shutil.copyfile(event.src_path, dest_path)
- if os.path.isdir(event.src_path):
- if os.path.exists(dest_path):
- shutil.rmtree(dest_path)
- with contextlib.suppress(PermissionError):
- shutil.copytree(event.src_path, dest_path)
-
- def on_deleted(self, event: FileSystemEvent):
- """Event hander when a file or folder was deleted.
-
- Args:
- event: Event infomation.
- """
- dest_path = self.get_dest_path(event.src_path)
-
- if os.path.isfile(dest_path):
- # when event is about a file, pass
- # this will be deleted at on_modified function
- return
-
- if os.path.exists(dest_path):
- shutil.rmtree(dest_path)
-
- def get_dest_path(self, src_path: str) -> str:
- """Get public file path.
-
- Args:
- src_path: The asset file path.
-
- Returns:
- The public file path.
- """
- return src_path.replace(
- str(self.root / Dirs.APP_ASSETS),
- str(self.root / get_web_dir() / Dirs.PUBLIC),
- )
diff --git a/reflex/vars.py b/reflex/vars.py
deleted file mode 100644
index 057e74e78..000000000
--- a/reflex/vars.py
+++ /dev/null
@@ -1,2608 +0,0 @@
-"""Define a state var."""
-
-from __future__ import annotations
-
-import contextlib
-import dataclasses
-import datetime
-import dis
-import functools
-import inspect
-import json
-import random
-import re
-import string
-import sys
-from types import CodeType, FunctionType
-from typing import (
- TYPE_CHECKING,
- Any,
- Callable,
- Dict,
- Iterable,
- List,
- Literal,
- Optional,
- Tuple,
- Type,
- Union,
- _GenericAlias, # type: ignore
- cast,
- get_args,
- get_origin,
- get_type_hints,
-)
-
-from reflex import constants
-from reflex.base import Base
-from reflex.utils import console, imports, serializers, types
-from reflex.utils.exceptions import (
- VarAttributeError,
- VarDependencyError,
- VarTypeError,
- VarValueError,
-)
-
-# This module used to export ImportVar itself, so we still import it for export here
-from reflex.utils.imports import (
- ImmutableParsedImportDict,
- ImportDict,
- ImportVar,
- ParsedImportDict,
- parse_imports,
-)
-from reflex.utils.types import override
-
-if TYPE_CHECKING:
- from reflex.state import BaseState
-
-
-# Set of unique variable names.
-USED_VARIABLES = set()
-
-# Supported operators for all types.
-ALL_OPS = ["==", "!=", "!==", "===", "&&", "||"]
-# Delimiters used between function args or operands.
-DELIMITERS = [","]
-# Mapping of valid operations for different type combinations.
-OPERATION_MAPPING = {
- (int, int): {
- "+",
- "-",
- "/",
- "//",
- "*",
- "%",
- "**",
- ">",
- "<",
- "<=",
- ">=",
- "|",
- "&",
- },
- (int, str): {"*"},
- (int, list): {"*"},
- (str, str): {"+", ">", "<", "<=", ">="},
- (float, float): {"+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="},
- (float, int): {"+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="},
- (list, list): {"+", ">", "<", "<=", ">="},
-}
-
-# These names were changed in reflex 0.3.0
-REPLACED_NAMES = {
- "full_name": "_var_full_name",
- "name": "_var_name",
- "state": "_var_data.state",
- "type_": "_var_type",
- "is_local": "_var_is_local",
- "is_string": "_var_is_string",
- "set_state": "_var_set_state",
- "deps": "_deps",
-}
-
-PYTHON_JS_TYPE_MAP = {
- (int, float): "number",
- (str,): "string",
- (bool,): "boolean",
- (list, tuple): "Array",
- (dict,): "Object",
- (None,): "null",
-}
-
-
-def get_unique_variable_name() -> str:
- """Get a unique variable name.
-
- Returns:
- The unique variable name.
- """
- name = "".join([random.choice(string.ascii_lowercase) for _ in range(8)])
- if name not in USED_VARIABLES:
- USED_VARIABLES.add(name)
- return name
- return get_unique_variable_name()
-
-
-class VarData(Base):
- """Metadata associated with a Var."""
-
- # The name of the enclosing state.
- state: str = ""
-
- # Imports needed to render this var
- imports: ParsedImportDict = {}
-
- # Hooks that need to be present in the component to render this var
- hooks: Dict[str, None] = {}
-
- # Positions of interpolated strings. This is used by the decoder to figure
- # out where the interpolations are and only escape the non-interpolated
- # segments.
- interpolations: List[Tuple[int, int]] = []
-
- def __init__(
- self, imports: Union[ImportDict, ParsedImportDict] | None = None, **kwargs: Any
- ):
- """Initialize the var data.
-
- Args:
- imports: The imports needed to render this var.
- **kwargs: The var data fields.
- """
- if imports:
- kwargs["imports"] = parse_imports(imports)
- super().__init__(**kwargs)
-
- @classmethod
- def merge(cls, *others: ImmutableVarData | VarData | None) -> VarData | None:
- """Merge multiple var data objects.
-
- Args:
- *others: The var data objects to merge.
-
- Returns:
- The merged var data object.
- """
- state = ""
- _imports = {}
- hooks = {}
- interpolations = []
- for var_data in others:
- if var_data is None:
- continue
- state = state or var_data.state
- _imports = imports.merge_imports(_imports, var_data.imports)
- hooks.update(
- var_data.hooks
- if isinstance(var_data.hooks, dict)
- else {k: None for k in var_data.hooks}
- )
- interpolations += (
- var_data.interpolations if isinstance(var_data, VarData) else []
- )
-
- return (
- cls(
- state=state,
- imports=_imports,
- hooks=hooks,
- interpolations=interpolations,
- )
- or None
- )
-
- def __bool__(self) -> bool:
- """Check if the var data is non-empty.
-
- Returns:
- True if any field is set to a non-default value.
- """
- return bool(self.state or self.imports or self.hooks or self.interpolations)
-
- def __eq__(self, other: Any) -> bool:
- """Check if two var data objects are equal.
-
- Args:
- other: The other var data object to compare.
-
- Returns:
- True if all fields are equal and collapsed imports are equal.
- """
- if not isinstance(other, VarData):
- return False
-
- # Don't compare interpolations - that's added in by the decoder, and
- # not part of the vardata itself.
- return (
- self.state == other.state
- and self.hooks.keys() == other.hooks.keys()
- and imports.collapse_imports(self.imports)
- == imports.collapse_imports(other.imports)
- )
-
- def dict(self) -> dict:
- """Convert the var data to a dictionary.
-
- Returns:
- The var data dictionary.
- """
- return {
- "state": self.state,
- "interpolations": list(self.interpolations),
- "imports": {
- lib: [import_var.dict() for import_var in import_vars]
- for lib, import_vars in self.imports.items()
- },
- "hooks": self.hooks,
- }
-
-
-@dataclasses.dataclass(
- eq=True,
- frozen=True,
-)
-class ImmutableVarData:
- """Metadata associated with a Var."""
-
- # The name of the enclosing state.
- state: str = dataclasses.field(default="")
-
- # Imports needed to render this var
- imports: ImmutableParsedImportDict = dataclasses.field(default_factory=tuple)
-
- # Hooks that need to be present in the component to render this var
- hooks: Tuple[str, ...] = dataclasses.field(default_factory=tuple)
-
- def __init__(
- self,
- state: str = "",
- imports: ImportDict | ParsedImportDict | None = None,
- hooks: dict[str, None] | None = None,
- ):
- """Initialize the var data.
-
- Args:
- state: The name of the enclosing state.
- imports: Imports needed to render this var.
- hooks: Hooks that need to be present in the component to render this var.
- """
- immutable_imports: ImmutableParsedImportDict = tuple(
- sorted(
- ((k, tuple(sorted(v))) for k, v in parse_imports(imports or {}).items())
- )
- )
- object.__setattr__(self, "state", state)
- object.__setattr__(self, "imports", immutable_imports)
- object.__setattr__(self, "hooks", tuple(hooks or {}))
-
- @classmethod
- def merge(
- cls, *others: ImmutableVarData | VarData | None
- ) -> ImmutableVarData | None:
- """Merge multiple var data objects.
-
- Args:
- *others: The var data objects to merge.
-
- Returns:
- The merged var data object.
- """
- state = ""
- _imports = {}
- hooks = {}
- for var_data in others:
- if var_data is None:
- continue
- state = state or var_data.state
- _imports = imports.merge_imports(_imports, var_data.imports)
- hooks.update(
- var_data.hooks
- if isinstance(var_data.hooks, dict)
- else {k: None for k in var_data.hooks}
- )
-
- return (
- ImmutableVarData(
- state=state,
- imports=_imports,
- hooks=hooks,
- )
- or None
- )
-
- def __bool__(self) -> bool:
- """Check if the var data is non-empty.
-
- Returns:
- True if any field is set to a non-default value.
- """
- return bool(self.state or self.imports or self.hooks)
-
- def __eq__(self, other: Any) -> bool:
- """Check if two var data objects are equal.
-
- Args:
- other: The other var data object to compare.
-
- Returns:
- True if all fields are equal and collapsed imports are equal.
- """
- if not isinstance(other, (ImmutableVarData, VarData)):
- return False
-
- # Don't compare interpolations - that's added in by the decoder, and
- # not part of the vardata itself.
- return (
- self.state == other.state
- and self.hooks
- == (
- other.hooks
- if isinstance(other, ImmutableVarData)
- else tuple(other.hooks.keys())
- )
- and imports.collapse_imports(self.imports)
- == imports.collapse_imports(other.imports)
- )
-
-
-def _decode_var_immutable(value: str) -> tuple[ImmutableVarData | None, str]:
- """Decode the state name from a formatted var.
-
- Args:
- value: The value to extract the state name from.
-
- Returns:
- The extracted state name and the value without the state name.
- """
- var_datas = []
- if isinstance(value, str):
- # fast path if there is no encoded VarData
- if constants.REFLEX_VAR_OPENING_TAG not in value:
- return None, value
-
- offset = 0
-
- # Initialize some methods for reading json.
- var_data_config = VarData().__config__
-
- def json_loads(s):
- try:
- return var_data_config.json_loads(s)
- except json.decoder.JSONDecodeError:
- return var_data_config.json_loads(var_data_config.json_loads(f'"{s}"'))
-
- # Find all tags.
- while m := _decode_var_pattern.search(value):
- start, end = m.span()
- value = value[:start] + value[end:]
-
- serialized_data = m.group(1)
-
- if serialized_data.isnumeric() or (
- serialized_data[0] == "-" and serialized_data[1:].isnumeric()
- ):
- # This is a global immutable var.
- var = _global_vars[int(serialized_data)]
- var_data = var._var_data
-
- if var_data is not None:
- realstart = start + offset
-
- var_datas.append(var_data)
- else:
- # Read the JSON, pull out the string length, parse the rest as VarData.
- data = json_loads(serialized_data)
- string_length = data.pop("string_length", None)
- var_data = VarData.parse_obj(data)
-
- # Use string length to compute positions of interpolations.
- if string_length is not None:
- realstart = start + offset
- var_data.interpolations = [(realstart, realstart + string_length)]
-
- var_datas.append(var_data)
- offset += end - start
-
- return ImmutableVarData.merge(*var_datas) if var_datas else None, value
-
-
-def _encode_var(value: Var) -> str:
- """Encode the state name into a formatted var.
-
- Args:
- value: The value to encode the state name into.
-
- Returns:
- The encoded var.
- """
- if value._var_data:
- from reflex.utils.serializers import serialize
-
- final_value = str(value)
- data = value._var_data.dict()
- data["string_length"] = len(final_value)
- data_json = value._var_data.__config__.json_dumps(data, default=serialize)
-
- return (
- f"{constants.REFLEX_VAR_OPENING_TAG}{data_json}{constants.REFLEX_VAR_CLOSING_TAG}"
- + final_value
- )
-
- return str(value)
-
-
-# Compile regex for finding reflex var tags.
-_decode_var_pattern_re = (
- rf"{constants.REFLEX_VAR_OPENING_TAG}(.*?){constants.REFLEX_VAR_CLOSING_TAG}"
-)
-_decode_var_pattern = re.compile(_decode_var_pattern_re, flags=re.DOTALL)
-
-# Defined global immutable vars.
-_global_vars: Dict[int, Var] = {}
-
-
-def _decode_var(value: str) -> tuple[VarData | None, str]:
- """Decode the state name from a formatted var.
-
- Args:
- value: The value to extract the state name from.
-
- Returns:
- The extracted state name and the value without the state name.
- """
- var_datas = []
- if isinstance(value, str):
- # fast path if there is no encoded VarData
- if constants.REFLEX_VAR_OPENING_TAG not in value:
- return None, value
-
- offset = 0
-
- # Initialize some methods for reading json.
- var_data_config = VarData().__config__
-
- def json_loads(s):
- try:
- return var_data_config.json_loads(s)
- except json.decoder.JSONDecodeError:
- return var_data_config.json_loads(var_data_config.json_loads(f'"{s}"'))
-
- # Find all tags.
- while m := _decode_var_pattern.search(value):
- start, end = m.span()
- value = value[:start] + value[end:]
-
- serialized_data = m.group(1)
-
- if serialized_data.isnumeric() or (
- serialized_data[0] == "-" and serialized_data[1:].isnumeric()
- ):
- # This is a global immutable var.
- var = _global_vars[int(serialized_data)]
- var_data = var._var_data
-
- if var_data is not None:
- realstart = start + offset
-
- var_datas.append(var_data)
- else:
- # Read the JSON, pull out the string length, parse the rest as VarData.
- data = json_loads(serialized_data)
- string_length = data.pop("string_length", None)
- var_data = VarData.parse_obj(data)
-
- # Use string length to compute positions of interpolations.
- if string_length is not None:
- realstart = start + offset
- var_data.interpolations = [(realstart, realstart + string_length)]
-
- var_datas.append(var_data)
- offset += end - start
-
- return VarData.merge(*var_datas) if var_datas else None, value
-
-
-def _extract_var_data(value: Iterable) -> list[VarData | None]:
- """Extract the var imports and hooks from an iterable containing a Var.
-
- Args:
- value: The iterable to extract the VarData from
-
- Returns:
- The extracted VarDatas.
- """
- from reflex.style import Style
-
- var_datas = []
- with contextlib.suppress(TypeError):
- for sub in value:
- if isinstance(sub, Var):
- var_datas.append(sub._var_data)
- elif not isinstance(sub, str):
- # Recurse into dict values.
- if hasattr(sub, "values") and callable(sub.values):
- var_datas.extend(_extract_var_data(sub.values()))
- # Recurse into iterable values (or dict keys).
- var_datas.extend(_extract_var_data(sub))
-
- # Style objects should already have _var_data.
- if isinstance(value, Style):
- var_datas.append(value._var_data)
- else:
- # Recurse when value is a dict itself.
- values = getattr(value, "values", None)
- if callable(values):
- var_datas.extend(_extract_var_data(values()))
- return var_datas
-
-
-class Var:
- """An abstract var."""
-
- # The name of the var.
- _var_name: str
-
- # The type of the var.
- _var_type: Type
-
- # Whether this is a local javascript variable.
- _var_is_local: bool
-
- # Whether the var is a string literal.
- _var_is_string: bool
-
- # _var_full_name should be prefixed with _var_state
- _var_full_name_needs_state_prefix: bool
-
- # Extra metadata associated with the Var
- _var_data: Optional[VarData]
-
- _var_is_scope: bool = False
-
- @classmethod
- def create(
- cls,
- value: Any,
- _var_is_local: bool = True,
- _var_is_string: bool | None = None,
- _var_data: Optional[VarData] = None,
- _var_is_scope: bool = False,
- ) -> Var | None:
- """Create a var from a value.
-
- Args:
- value: The value to create the var from.
- _var_is_local: Whether the var is local.
- _var_is_string: Whether the var is a string literal.
- _var_data: Additional hooks and imports associated with the Var.
-
- Returns:
- The var.
-
- Raises:
- VarTypeError: If the value is JSON-unserializable.
- """
- from reflex.utils import format
-
- # Check for none values.
- if value is None:
- return None
-
- # If the value is already a var, do nothing.
- if isinstance(value, Var):
- return value
-
- # Try to pull the imports and hooks from contained values.
- if not isinstance(value, str):
- _var_data = VarData.merge(*_extract_var_data(value), _var_data)
-
- # Try to serialize the value.
- type_ = type(value)
- if type_ in types.JSONType:
- name = value
- else:
- name, serialized_type = serializers.serialize(value, get_type=True)
- if (
- serialized_type is not None
- and _var_is_string is None
- and issubclass(serialized_type, str)
- ):
- _var_is_string = True
- if name is None:
- raise VarTypeError(
- f"No JSON serializer found for var {value} of type {type_}."
- )
- name = name if isinstance(name, str) else format.json_dumps(name)
-
- if _var_is_string is None and type_ is str:
- console.deprecate(
- feature_name=f"Creating a Var ({value}) from a string without specifying _var_is_string",
- reason=(
- "Specify _var_is_string=False to create a Var that is not a string literal. "
- "In the future, creating a Var from a string will be treated as a string literal "
- "by default."
- ),
- deprecation_version="0.5.4",
- removal_version="0.6.0",
- )
-
- return BaseVar(
- _var_name=name,
- _var_type=type_,
- _var_is_local=_var_is_local,
- _var_is_string=_var_is_string if _var_is_string is not None else False,
- _var_data=_var_data,
- _var_is_scope=_var_is_scope,
- )
-
- @classmethod
- def create_safe(
- cls,
- value: Any,
- _var_is_local: bool = True,
- _var_is_string: bool | None = None,
- _var_data: Optional[VarData] = None,
- ) -> Var:
- """Create a var from a value, asserting that it is not None.
-
- Args:
- value: The value to create the var from.
- _var_is_local: Whether the var is local.
- _var_is_string: Whether the var is a string literal.
- _var_data: Additional hooks and imports associated with the Var.
-
- Returns:
- The var.
- """
- var = cls.create(
- value,
- _var_is_local=_var_is_local,
- _var_is_string=_var_is_string,
- _var_data=_var_data,
- )
- assert var is not None
- return var
-
- @classmethod
- def __class_getitem__(cls, type_: str) -> _GenericAlias:
- """Get a typed var.
-
- Args:
- type_: The type of the var.
-
- Returns:
- The var class item.
- """
- return _GenericAlias(cls, type_)
-
- def __post_init__(self) -> None:
- """Post-initialize the var."""
- # Decode any inline Var markup and apply it to the instance
- _var_data, _var_name = _decode_var(self._var_name)
- if _var_data:
- self._var_name = _var_name
- self._var_data = VarData.merge(self._var_data, _var_data)
-
- def _replace(self, merge_var_data=None, **kwargs: Any) -> BaseVar:
- """Make a copy of this Var with updated fields.
-
- Args:
- merge_var_data: VarData to merge into the existing VarData.
- **kwargs: Var fields to update.
-
- Returns:
- A new BaseVar with the updated fields overwriting the corresponding fields in this Var.
-
- Raises:
- TypeError: If kwargs contains keys that are not allowed.
- """
- field_values = dict(
- _var_name=kwargs.pop("_var_name", self._var_name),
- _var_type=kwargs.pop("_var_type", self._var_type),
- _var_is_local=kwargs.pop("_var_is_local", self._var_is_local),
- _var_is_string=kwargs.pop("_var_is_string", self._var_is_string),
- _var_full_name_needs_state_prefix=kwargs.pop(
- "_var_full_name_needs_state_prefix",
- self._var_full_name_needs_state_prefix,
- ),
- _var_data=VarData.merge(
- kwargs.pop("_var_data", self._var_data), merge_var_data
- ),
- )
-
- if kwargs:
- unexpected_kwargs = ", ".join(kwargs.keys())
- raise TypeError(f"Unexpected keyword arguments: {unexpected_kwargs}")
-
- return BaseVar(**field_values)
-
- def _decode(self) -> Any:
- """Decode Var as a python value.
-
- Note that Var with state set cannot be decoded python-side and will be
- returned as full_name.
-
- Returns:
- The decoded value or the Var name.
- """
- if self._var_is_string:
- return self._var_name
- try:
- return json.loads(self._var_name)
- except ValueError:
- return self._var_name
-
- def equals(self, other: Var) -> bool:
- """Check if two vars are equal.
-
- Args:
- other: The other var to compare.
-
- Returns:
- Whether the vars are equal.
- """
- return (
- self._var_name == other._var_name
- and self._var_type == other._var_type
- and self._var_is_local == other._var_is_local
- and self._var_full_name_needs_state_prefix
- == other._var_full_name_needs_state_prefix
- and self._var_data == other._var_data
- )
-
- def _merge(self, other) -> Var:
- """Merge two or more dicts.
-
- Args:
- other: The other var to merge.
-
- Returns:
- The merged var.
- """
- if other is None:
- return self._replace()
- if not isinstance(other, Var):
- other = Var.create(other, _var_is_string=False)
- return self._replace(
- _var_name=f"{{...{self._var_name}, ...{other._var_name}}}" # type: ignore
- )
-
- def to_string(self, json: bool = True) -> Var:
- """Convert a var to a string.
-
- Args:
- json: Whether to convert to a JSON string.
-
- Returns:
- The stringified var.
- """
- fn = "JSON.stringify" if json else "String"
- return self.operation(fn=fn, type_=str)
-
- def to_int(self) -> Var:
- """Convert a var to an int.
-
- Returns:
- The parseInt var.
- """
- return self.operation(fn="parseInt", type_=int)
-
- def __hash__(self) -> int:
- """Define a hash function for a var.
-
- Returns:
- The hash of the var.
- """
- return hash((self._var_name, str(self._var_type)))
-
- def __str__(self) -> str:
- """Wrap the var so it can be used in templates.
-
- Returns:
- The wrapped var, i.e. {state.var}.
- """
- from reflex.utils import format
-
- out = (
- self._var_full_name
- if self._var_is_local
- else format.wrap(self._var_full_name, "{")
- )
- if self._var_is_string:
- out = format.format_string(out)
- return out
-
- def __bool__(self) -> bool:
- """Raise exception if using Var in a boolean context.
-
- Raises:
- VarTypeError: when attempting to bool-ify the Var.
- """
- raise VarTypeError(
- f"Cannot convert Var {self._var_full_name!r} to bool for use with `if`, `and`, `or`, and `not`. "
- "Instead use `rx.cond` and bitwise operators `&` (and), `|` (or), `~` (invert)."
- )
-
- def __iter__(self) -> Any:
- """Raise exception if using Var in an iterable context.
-
- Raises:
- VarTypeError: when attempting to iterate over the Var.
- """
- raise VarTypeError(
- f"Cannot iterate over Var {self._var_full_name!r}. Instead use `rx.foreach`."
- )
-
- def __format__(self, format_spec: str) -> str:
- """Format the var into a Javascript equivalent to an f-string.
-
- Args:
- format_spec: The format specifier (Ignored for now).
-
- Returns:
- The formatted var.
- """
- # Encode the _var_data into the formatted output for tracking purposes.
- str_self = _encode_var(self)
- if self._var_is_local:
- return str_self
- return f"${str_self}"
-
- def __getitem__(self, i: Any) -> Var:
- """Index into a var.
-
- Args:
- i: The index to index into.
-
- Returns:
- The indexed var.
-
- Raises:
- VarTypeError: If the var is not indexable.
- """
- from reflex.utils import format
-
- # Indexing is only supported for strings, lists, tuples, dicts, and dataframes.
- if not (
- types._issubclass(self._var_type, Union[List, Dict, Tuple, str])
- or types.is_dataframe(self._var_type)
- ):
- if self._var_type == Any:
- raise VarTypeError(
- "Could not index into var of type Any. (If you are trying to index into a state var, "
- "add the correct type annotation to the var.)"
- )
- raise VarTypeError(
- f"Var {self._var_name} of type {self._var_type} does not support indexing."
- )
-
- # The type of the indexed var.
- type_ = Any
-
- # Convert any vars to local vars.
- if isinstance(i, Var):
- i = i._replace(_var_is_local=True)
-
- # Handle list/tuple/str indexing.
- if types._issubclass(self._var_type, Union[List, Tuple, str]):
- # List/Tuple/String indices must be ints, slices, or vars.
- if (
- not isinstance(i, types.get_args(Union[int, slice, Var]))
- or isinstance(i, Var)
- and not i._var_type == int
- ):
- raise VarTypeError("Index must be an integer or an integer var.")
-
- # Handle slices first.
- if isinstance(i, slice):
- # Get the start and stop indices.
- start = i.start or 0
- stop = i.stop or "undefined"
-
- # Use the slice function.
- return self._replace(
- _var_name=f"{self._var_name}.slice({start}, {stop})",
- _var_is_string=False,
- )
-
- # Get the type of the indexed var.
- if types.is_generic_alias(self._var_type):
- index = i if not isinstance(i, Var) else 0
- type_ = types.get_args(self._var_type)
- type_ = type_[index % len(type_)] if type_ else Any
- elif types._issubclass(self._var_type, str):
- type_ = str
-
- # Use `at` to support negative indices.
- return self._replace(
- _var_name=f"{self._var_name}.at({i})",
- _var_type=type_,
- _var_is_string=False,
- )
-
- # Dictionary / dataframe indexing.
- # Tuples are currently not supported as indexes.
- if (
- (
- types._issubclass(self._var_type, Dict)
- or types.is_dataframe(self._var_type)
- )
- and not isinstance(i, types.get_args(Union[int, str, float, Var]))
- ) or (
- isinstance(i, Var)
- and not types._issubclass(
- i._var_type, types.get_args(Union[int, str, float])
- )
- ):
- raise VarTypeError(
- "Index must be one of the following types: int, str, int or str Var"
- )
- # Get the type of the indexed var.
- if isinstance(i, str):
- i = format.wrap(i, '"')
- type_ = (
- types.get_args(self._var_type)[1]
- if types.is_generic_alias(self._var_type)
- else Any
- )
-
- # Use normal indexing here.
- return self._replace(
- _var_name=f"{self._var_name}[{i}]",
- _var_type=type_,
- _var_is_string=False,
- )
-
- def __getattribute__(self, name: str) -> Any:
- """Get a var attribute.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The var attribute.
-
- Raises:
- VarAttributeError: If the attribute cannot be found, or if __getattr__ fallback should be used.
- """
- try:
- var_attribute = super().__getattribute__(name)
- if (
- not name.startswith("_")
- and name not in Var.__dict__
- and name not in BaseVar.__dict__
- ):
- # Check if the attribute should be accessed through the Var instead of
- # accessing one of the Var operations
- type_ = types.get_attribute_access_type(
- super().__getattribute__("_var_type"), name
- )
- if type_ is not None:
- raise VarAttributeError(
- f"{name} is being accessed through the Var."
- )
- # Return the attribute as-is.
- return var_attribute
- except VarAttributeError:
- raise # fall back to __getattr__ anyway
-
- def __getattr__(self, name: str) -> Var:
- """Get a var attribute.
-
- Args:
- name: The name of the attribute.
-
- Returns:
- The var attribute.
-
- Raises:
- VarAttributeError: If the var is wrongly annotated or can't find attribute.
- VarTypeError: If an annotation to the var isn't provided.
- """
- # Check if the attribute is one of the class fields.
- if not name.startswith("_"):
- if self._var_type == Any:
- raise VarTypeError(
- f"You must provide an annotation for the state var `{self._var_full_name}`. Annotation cannot be `{self._var_type}`"
- ) from None
- is_optional = types.is_optional(self._var_type)
- type_ = types.get_attribute_access_type(self._var_type, name)
-
- if type_ is not None:
- return self._replace(
- _var_name=f"{self._var_name}{'?' if is_optional else ''}.{name}",
- _var_type=type_,
- _var_is_string=False,
- )
-
- if name in REPLACED_NAMES:
- raise VarAttributeError(
- f"Field {name!r} was renamed to {REPLACED_NAMES[name]!r}"
- )
-
- raise VarAttributeError(
- f"The State var `{self._var_full_name}` has no attribute '{name}' or may have been annotated "
- f"wrongly."
- )
-
- raise VarAttributeError(
- f"The State var has no attribute '{name}' or may have been annotated wrongly.",
- )
-
- def operation(
- self,
- op: str = "",
- other: Var | None = None,
- type_: Type | None = None,
- flip: bool = False,
- fn: str | None = None,
- invoke_fn: bool = False,
- ) -> Var:
- """Perform an operation on a var.
-
- Args:
- op: The operation to perform.
- other: The other var to perform the operation on.
- type_: The type of the operation result.
- flip: Whether to flip the order of the operation.
- fn: A function to apply to the operation.
- invoke_fn: Whether to invoke the function.
-
- Returns:
- The operation result.
-
- Raises:
- VarTypeError: If the operation between two operands is invalid.
- VarValueError: If flip is set to true and value of operand is not provided
- """
- from reflex.utils import format
-
- if isinstance(other, str):
- other = Var.create(json.dumps(other), _var_is_string=False)
- else:
- other = Var.create(other, _var_is_string=False)
-
- type_ = type_ or self._var_type
-
- if other is None and flip:
- raise VarValueError(
- "flip_operands cannot be set to True if the value of 'other' operand is not provided"
- )
-
- left_operand, right_operand = (other, self) if flip else (self, other)
-
- def get_operand_full_name(operand):
- # operand vars that are string literals need to be wrapped in back ticks.
- return (
- operand._var_name_unwrapped
- if operand._var_is_string
- and not operand._var_state
- and operand._var_is_local
- else operand._var_full_name
- )
-
- if other is not None:
- # check if the operation between operands is valid.
- if op and not self.is_valid_operation(
- types.get_base_class(left_operand._var_type), # type: ignore
- types.get_base_class(right_operand._var_type), # type: ignore
- op,
- ):
- raise VarTypeError(
- f"Unsupported Operand type(s) for {op}: `{left_operand._var_full_name}` of type {left_operand._var_type.__name__} and `{right_operand._var_full_name}` of type {right_operand._var_type.__name__}" # type: ignore
- )
-
- left_operand_full_name = get_operand_full_name(left_operand)
- right_operand_full_name = get_operand_full_name(right_operand)
-
- left_operand_full_name = format.wrap(left_operand_full_name, "(")
- right_operand_full_name = format.wrap(right_operand_full_name, "(")
-
- # apply function to operands
- if fn is not None:
- if invoke_fn:
- # invoke the function on left operand.
- operation_name = (
- f"{left_operand_full_name}.{fn}({right_operand_full_name})" # type: ignore
- )
- else:
- # pass the operands as arguments to the function.
- operation_name = (
- f"{left_operand_full_name} {op} {right_operand_full_name}" # type: ignore
- )
- operation_name = f"{fn}({operation_name})"
- else:
- # apply operator to operands (left operand right_operand)
- operation_name = (
- f"{left_operand_full_name} {op} {right_operand_full_name}" # type: ignore
- )
- operation_name = format.wrap(operation_name, "(")
- else:
- # apply operator to left operand ( left_operand)
- operation_name = f"{op}{get_operand_full_name(self)}"
- # apply function to operands
- if fn is not None:
- operation_name = (
- f"{fn}({operation_name})"
- if not invoke_fn
- else f"{get_operand_full_name(self)}.{fn}()"
- )
-
- return self._replace(
- _var_name=operation_name,
- _var_type=type_,
- _var_is_string=False,
- _var_full_name_needs_state_prefix=False,
- merge_var_data=other._var_data if other is not None else None,
- )
-
- @staticmethod
- def is_valid_operation(
- operand1_type: Type, operand2_type: Type, operator: str
- ) -> bool:
- """Check if an operation between two operands is valid.
-
- Args:
- operand1_type: Type of the operand
- operand2_type: Type of the second operand
- operator: The operator.
-
- Returns:
- Whether operation is valid or not
-
- """
- if operator in ALL_OPS or operator in DELIMITERS:
- return True
-
- # bools are subclasses of ints
- pair = tuple(
- sorted(
- [
- int if operand1_type == bool else operand1_type,
- int if operand2_type == bool else operand2_type,
- ],
- key=lambda x: x.__name__,
- )
- )
- return pair in OPERATION_MAPPING and operator in OPERATION_MAPPING[pair]
-
- def compare(self, op: str, other: Var) -> Var:
- """Compare two vars with inequalities.
-
- Args:
- op: The comparison operator.
- other: The other var to compare with.
-
- Returns:
- The comparison result.
- """
- return self.operation(op, other, bool)
-
- def __invert__(self) -> Var:
- """Invert a var.
-
- Returns:
- The inverted var.
- """
- return self.operation("!", type_=bool)
-
- def __neg__(self) -> Var:
- """Negate a var.
-
- Returns:
- The negated var.
- """
- return self.operation(fn="-")
-
- def __abs__(self) -> Var:
- """Get the absolute value of a var.
-
- Returns:
- A var with the absolute value.
- """
- return self.operation(fn="Math.abs")
-
- def length(self) -> Var:
- """Get the length of a list var.
-
- Returns:
- A var with the absolute value.
-
- Raises:
- VarTypeError: If the var is not a list.
- """
- if not types._issubclass(self._var_type, List):
- raise VarTypeError(f"Cannot get length of non-list var {self}.")
- return self._replace(
- _var_name=f"{self._var_name}.length",
- _var_type=int,
- _var_is_string=False,
- )
-
- def _type(self) -> Var:
- """Get the type of the Var in Javascript.
-
- Returns:
- A var representing the type check.
- """
- return self._replace(
- _var_name=f"typeof {self._var_full_name}",
- _var_type=str,
- _var_is_string=False,
- _var_full_name_needs_state_prefix=False,
- )
-
- def __eq__(self, other: Union[Var, Type]) -> Var:
- """Perform an equality comparison.
-
- Args:
- other: The other var to compare with.
-
- Returns:
- A var representing the equality comparison.
- """
- for python_types, js_type in PYTHON_JS_TYPE_MAP.items():
- if not isinstance(other, Var) and other in python_types:
- return self.compare("===", Var.create(js_type, _var_is_string=True)) # type: ignore
- return self.compare("===", other)
-
- def __ne__(self, other: Union[Var, Type]) -> Var:
- """Perform an inequality comparison.
-
- Args:
- other: The other var to compare with.
-
- Returns:
- A var representing the inequality comparison.
- """
- for python_types, js_type in PYTHON_JS_TYPE_MAP.items():
- if not isinstance(other, Var) and other in python_types:
- return self.compare("!==", Var.create(js_type, _var_is_string=True)) # type: ignore
- return self.compare("!==", other)
-
- def __gt__(self, other: Var) -> Var:
- """Perform a greater than comparison.
-
- Args:
- other: The other var to compare with.
-
- Returns:
- A var representing the greater than comparison.
- """
- return self.compare(">", other)
-
- def __ge__(self, other: Var) -> Var:
- """Perform a greater than or equal to comparison.
-
- Args:
- other: The other var to compare with.
-
- Returns:
- A var representing the greater than or equal to comparison.
- """
- return self.compare(">=", other)
-
- def __lt__(self, other: Var) -> Var:
- """Perform a less than comparison.
-
- Args:
- other: The other var to compare with.
-
- Returns:
- A var representing the less than comparison.
- """
- return self.compare("<", other)
-
- def __le__(self, other: Var) -> Var:
- """Perform a less than or equal to comparison.
-
- Args:
- other: The other var to compare with.
-
- Returns:
- A var representing the less than or equal to comparison.
- """
- return self.compare("<=", other)
-
- def __add__(self, other: Var, flip=False) -> Var:
- """Add two vars.
-
- Args:
- other: The other var to add.
- flip: Whether to flip operands.
-
- Returns:
- A var representing the sum.
- """
- other_type = other._var_type if isinstance(other, Var) else type(other)
- # For list-list addition, javascript concatenates the content of the lists instead of
- # merging the list, and for that reason we use the spread operator available through spreadArraysOrObjects
- # utility function
- if (
- types.get_base_class(self._var_type) == list
- and types.get_base_class(other_type) == list
- ):
- return self.operation(
- ",", other, fn="spreadArraysOrObjects", flip=flip
- )._replace(
- merge_var_data=VarData(
- imports={
- f"/{constants.Dirs.STATE_PATH}": [
- ImportVar(tag="spreadArraysOrObjects")
- ]
- },
- ),
- )
- return self.operation("+", other, flip=flip)
-
- def __radd__(self, other: Var) -> Var:
- """Add two vars.
-
- Args:
- other: The other var to add.
-
- Returns:
- A var representing the sum.
- """
- return self.__add__(other=other, flip=True)
-
- def __sub__(self, other: Var) -> Var:
- """Subtract two vars.
-
- Args:
- other: The other var to subtract.
-
- Returns:
- A var representing the difference.
- """
- return self.operation("-", other)
-
- def __rsub__(self, other: Var) -> Var:
- """Subtract two vars.
-
- Args:
- other: The other var to subtract.
-
- Returns:
- A var representing the difference.
- """
- return self.operation("-", other, flip=True)
-
- def __mul__(self, other: Var, flip=True) -> Var:
- """Multiply two vars.
-
- Args:
- other: The other var to multiply.
- flip: Whether to flip operands
-
- Returns:
- A var representing the product.
- """
- other_type = other._var_type if isinstance(other, Var) else type(other)
- # For str-int multiplication, we use the repeat function.
- # i.e "hello" * 2 is equivalent to "hello".repeat(2) in js.
- if (types.get_base_class(self._var_type), types.get_base_class(other_type)) in [
- (int, str),
- (str, int),
- ]:
- return self.operation(other=other, fn="repeat", invoke_fn=True)
-
- # For list-int multiplication, we use the Array function.
- # i.e ["hello"] * 2 is equivalent to Array(2).fill().map(() => ["hello"]).flat() in js.
- if (types.get_base_class(self._var_type), types.get_base_class(other_type)) in [
- (int, list),
- (list, int),
- ]:
- other_name = other._var_full_name if isinstance(other, Var) else other
- name = f"Array({other_name}).fill().map(() => {self._var_full_name}).flat()"
- return self._replace(
- _var_name=name,
- _var_type=str,
- _var_is_string=False,
- _var_full_name_needs_state_prefix=False,
- )
-
- return self.operation("*", other)
-
- def __rmul__(self, other: Var) -> Var:
- """Multiply two vars.
-
- Args:
- other: The other var to multiply.
-
- Returns:
- A var representing the product.
- """
- return self.__mul__(other=other, flip=True)
-
- def __pow__(self, other: Var) -> Var:
- """Raise a var to a power.
-
- Args:
- other: The power to raise to.
-
- Returns:
- A var representing the power.
- """
- return self.operation(",", other, fn="Math.pow")
-
- def __rpow__(self, other: Var) -> Var:
- """Raise a var to a power.
-
- Args:
- other: The power to raise to.
-
- Returns:
- A var representing the power.
- """
- return self.operation(",", other, flip=True, fn="Math.pow")
-
- def __truediv__(self, other: Var) -> Var:
- """Divide two vars.
-
- Args:
- other: The other var to divide.
-
- Returns:
- A var representing the quotient.
- """
- return self.operation("/", other)
-
- def __rtruediv__(self, other: Var) -> Var:
- """Divide two vars.
-
- Args:
- other: The other var to divide.
-
- Returns:
- A var representing the quotient.
- """
- return self.operation("/", other, flip=True)
-
- def __floordiv__(self, other: Var) -> Var:
- """Divide two vars.
-
- Args:
- other: The other var to divide.
-
- Returns:
- A var representing the quotient.
- """
- return self.operation("/", other, fn="Math.floor")
-
- def __mod__(self, other: Var) -> Var:
- """Get the remainder of two vars.
-
- Args:
- other: The other var to divide.
-
- Returns:
- A var representing the remainder.
- """
- return self.operation("%", other)
-
- def __rmod__(self, other: Var) -> Var:
- """Get the remainder of two vars.
-
- Args:
- other: The other var to divide.
-
- Returns:
- A var representing the remainder.
- """
- return self.operation("%", other, flip=True)
-
- def __and__(self, other: Var) -> Var:
- """Perform a logical and.
-
- Args:
- other: The other var to perform the logical AND with.
-
- Returns:
- A var representing the logical AND.
-
- Note:
- This method provides behavior specific to JavaScript, where it returns the JavaScript
- equivalent code (using the '&&' operator) of a logical AND operation.
- In JavaScript, the
- logical OR operator '&&' is used for Boolean logic, and this method emulates that behavior
- by returning the equivalent code as a Var instance.
-
- In Python, logical AND 'and' operates differently, evaluating expressions immediately, making
- it challenging to override the behavior entirely.
- Therefore, this method leverages the
- bitwise AND '__and__' operator for custom JavaScript-like behavior.
-
- Example:
- >>> var1 = Var.create(True)
- >>> var2 = Var.create(False)
- >>> js_code = var1 & var2
- >>> print(js_code._var_full_name)
- '(true && false)'
- """
- return self.operation("&&", other, type_=bool)
-
- def __rand__(self, other: Var) -> Var:
- """Perform a logical and.
-
- Args:
- other: The other var to perform the logical AND with.
-
- Returns:
- A var representing the logical AND.
-
- Note:
- This method provides behavior specific to JavaScript, where it returns the JavaScript
- equivalent code (using the '&&' operator) of a logical AND operation.
- In JavaScript, the
- logical OR operator '&&' is used for Boolean logic, and this method emulates that behavior
- by returning the equivalent code as a Var instance.
-
- In Python, logical AND 'and' operates differently, evaluating expressions immediately, making
- it challenging to override the behavior entirely.
- Therefore, this method leverages the
- bitwise AND '__rand__' operator for custom JavaScript-like behavior.
-
- Example:
- >>> var1 = Var.create(True)
- >>> var2 = Var.create(False)
- >>> js_code = var1 & var2
- >>> print(js_code._var_full_name)
- '(false && true)'
- """
- return self.operation("&&", other, type_=bool, flip=True)
-
- def __or__(self, other: Var) -> Var:
- """Perform a logical or.
-
- Args:
- other: The other var to perform the logical or with.
-
- Returns:
- A var representing the logical or.
-
- Note:
- This method provides behavior specific to JavaScript, where it returns the JavaScript
- equivalent code (using the '||' operator) of a logical OR operation. In JavaScript, the
- logical OR operator '||' is used for Boolean logic, and this method emulates that behavior
- by returning the equivalent code as a Var instance.
-
- In Python, logical OR 'or' operates differently, evaluating expressions immediately, making
- it challenging to override the behavior entirely. Therefore, this method leverages the
- bitwise OR '__or__' operator for custom JavaScript-like behavior.
-
- Example:
- >>> var1 = Var.create(True)
- >>> var2 = Var.create(False)
- >>> js_code = var1 | var2
- >>> print(js_code._var_full_name)
- '(true || false)'
- """
- return self.operation("||", other, type_=bool)
-
- def __ror__(self, other: Var) -> Var:
- """Perform a logical or.
-
- Args:
- other: The other var to perform the logical or with.
-
- Returns:
- A var representing the logical or.
-
- Note:
- This method provides behavior specific to JavaScript, where it returns the JavaScript
- equivalent code (using the '||' operator) of a logical OR operation. In JavaScript, the
- logical OR operator '||' is used for Boolean logic, and this method emulates that behavior
- by returning the equivalent code as a Var instance.
-
- In Python, logical OR 'or' operates differently, evaluating expressions immediately, making
- it challenging to override the behavior entirely. Therefore, this method leverages the
- bitwise OR '__or__' operator for custom JavaScript-like behavior.
-
- Example:
- >>> var1 = Var.create(True)
- >>> var2 = Var.create(False)
- >>> js_code = var1 | var2
- >>> print(js_code)
- 'false || true'
- """
- return self.operation("||", other, type_=bool, flip=True)
-
- def __contains__(self, _: Any) -> Var:
- """Override the 'in' operator to alert the user that it is not supported.
-
- Raises:
- VarTypeError: the operation is not supported
- """
- raise VarTypeError(
- "'in' operator not supported for Var types, use Var.contains() instead."
- )
-
- def contains(self, other: Any, field: Union[Var, None] = None) -> Var:
- """Check if a var contains the object `other`.
-
- Args:
- other: The object to check.
- field: Optionally specify a field to check on both object and the other var.
-
- Raises:
- VarTypeError: If the var is not a valid type: dict, list, tuple or str.
-
- Returns:
- A var representing the contain check.
- """
- if not (types._issubclass(self._var_type, Union[dict, list, tuple, str, set])):
- raise VarTypeError(
- f"Var {self._var_full_name} of type {self._var_type} does not support contains check."
- )
- method = (
- "hasOwnProperty"
- if types.get_base_class(self._var_type) == dict
- else "includes"
- )
- if isinstance(other, str):
- other = Var.create(json.dumps(other), _var_is_string=True)
- elif not isinstance(other, Var):
- other = Var.create(other, _var_is_string=False)
- if types._issubclass(self._var_type, Dict):
- return self._replace(
- _var_name=f"{self._var_name}.{method}({other._var_full_name})",
- _var_type=bool,
- _var_is_string=False,
- merge_var_data=other._var_data,
- )
- else: # str, list, tuple
- # For strings, the left operand must be a string.
- if types._issubclass(self._var_type, str) and not types._issubclass(
- other._var_type, str
- ):
- raise VarTypeError(
- f"'in ' requires string as left operand, not {other._var_type}"
- )
-
- _var_name = None
- if field is None:
- _var_name = f"{self._var_name}.includes({other._var_full_name})"
- else:
- field = Var.create_safe(field, _var_is_string=isinstance(field, str))
- _var_name = f"{self._var_name}.some(e=>e[{field._var_name_unwrapped}]==={other._var_full_name})"
-
- return self._replace(
- _var_name=_var_name,
- _var_type=bool,
- _var_is_string=False,
- merge_var_data=other._var_data,
- )
-
- def reverse(self) -> Var:
- """Reverse a list var.
-
- Raises:
- VarTypeError: If the var is not a list.
-
- Returns:
- A var with the reversed list.
- """
- if not types._issubclass(self._var_type, list):
- raise VarTypeError(f"Cannot reverse non-list var {self._var_full_name}.")
-
- return self._replace(
- _var_name=f"[...{self._var_full_name}].reverse()",
- _var_is_string=False,
- _var_full_name_needs_state_prefix=False,
- )
-
- def lower(self) -> Var:
- """Convert a string var to lowercase.
-
- Returns:
- A var with the lowercase string.
-
- Raises:
- VarTypeError: If the var is not a string.
- """
- if not types._issubclass(self._var_type, str):
- raise VarTypeError(
- f"Cannot convert non-string var {self._var_full_name} to lowercase."
- )
-
- return self._replace(
- _var_name=f"{self._var_name}.toLowerCase()",
- _var_is_string=False,
- _var_type=str,
- )
-
- def upper(self) -> Var:
- """Convert a string var to uppercase.
-
- Returns:
- A var with the uppercase string.
-
- Raises:
- VarTypeError: If the var is not a string.
- """
- if not types._issubclass(self._var_type, str):
- raise VarTypeError(
- f"Cannot convert non-string var {self._var_full_name} to uppercase."
- )
-
- return self._replace(
- _var_name=f"{self._var_name}.toUpperCase()",
- _var_is_string=False,
- _var_type=str,
- )
-
- def strip(self, other: str | Var[str] = " ") -> Var:
- """Strip a string var.
-
- Args:
- other: The string to strip the var with.
-
- Returns:
- A var with the stripped string.
-
- Raises:
- VarTypeError: If the var is not a string.
- """
- if not types._issubclass(self._var_type, str):
- raise VarTypeError(f"Cannot strip non-string var {self._var_full_name}.")
-
- other = (
- Var.create_safe(json.dumps(other), _var_is_string=False)
- if isinstance(other, str)
- else other
- )
-
- return self._replace(
- _var_name=f"{self._var_name}.replace(/^${other._var_full_name}|${other._var_full_name}$/g, '')",
- _var_is_string=False,
- merge_var_data=other._var_data,
- )
-
- def split(self, other: str | Var[str] = " ") -> Var:
- """Split a string var into a list.
-
- Args:
- other: The string to split the var with.
-
- Returns:
- A var with the list.
-
- Raises:
- VarTypeError: If the var is not a string.
- """
- if not types._issubclass(self._var_type, str):
- raise VarTypeError(f"Cannot split non-string var {self._var_full_name}.")
-
- other = (
- Var.create_safe(json.dumps(other), _var_is_string=False)
- if isinstance(other, str)
- else other
- )
-
- return self._replace(
- _var_name=f"{self._var_name}.split({other._var_full_name})",
- _var_is_string=False,
- _var_type=List[str],
- merge_var_data=other._var_data,
- )
-
- def join(self, other: str | Var[str] | None = None) -> Var:
- """Join a list var into a string.
-
- Args:
- other: The string to join the list with.
-
- Returns:
- A var with the string.
-
- Raises:
- VarTypeError: If the var is not a list.
- """
- if not types._issubclass(self._var_type, list):
- raise VarTypeError(f"Cannot join non-list var {self._var_full_name}.")
-
- if other is None:
- other = Var.create_safe('""', _var_is_string=False)
- if isinstance(other, str):
- other = Var.create_safe(json.dumps(other), _var_is_string=False)
- else:
- other = Var.create_safe(other, _var_is_string=False)
-
- return self._replace(
- _var_name=f"{self._var_name}.join({other._var_full_name})",
- _var_is_string=False,
- _var_type=str,
- merge_var_data=other._var_data,
- )
-
- def foreach(self, fn: Callable) -> Var:
- """Return a list of components. after doing a foreach on this var.
-
- Args:
- fn: The function to call on each component.
-
- Returns:
- A var representing foreach operation.
-
- Raises:
- VarTypeError: If the var is not a list.
- """
- inner_types = get_args(self._var_type)
- if not inner_types:
- raise VarTypeError(
- f"Cannot foreach over non-sequence var {self._var_full_name} of type {self._var_type}."
- )
- arg = BaseVar(
- _var_name=get_unique_variable_name(),
- _var_type=inner_types[0],
- )
- index = BaseVar(
- _var_name=get_unique_variable_name(),
- _var_type=int,
- )
- fn_signature = inspect.signature(fn)
- fn_args = (arg, index)
- fn_ret = fn(*fn_args[: len(fn_signature.parameters)])
- return self._replace(
- _var_name=f"{self._var_full_name}.map(({arg._var_name}, {index._var_name}) => {fn_ret})",
- _var_is_string=False,
- )
-
- @classmethod
- def range(
- cls,
- v1: Var | int = 0,
- v2: Var | int | None = None,
- step: Var | int | None = None,
- ) -> Var:
- """Return an iterator over indices from v1 to v2 (or 0 to v1).
-
- Args:
- v1: The start of the range or end of range if v2 is not given.
- v2: The end of the range.
- step: The number of numbers between each item.
-
- Returns:
- A var representing range operation.
-
- Raises:
- VarTypeError: If the var is not an int.
- """
- if not isinstance(v1, Var):
- v1 = Var.create_safe(v1)
- if v1._var_type != int:
- raise VarTypeError(f"Cannot get range on non-int var {v1._var_full_name}.")
- if not isinstance(v2, Var):
- v2 = Var.create(v2)
- if v2 is None:
- v2 = Var.create_safe("undefined", _var_is_string=False)
- elif v2._var_type != int:
- raise VarTypeError(f"Cannot get range on non-int var {v2._var_full_name}.")
-
- if not isinstance(step, Var):
- step = Var.create(step)
- if step is None:
- step = Var.create_safe(1)
- elif step._var_type != int:
- raise VarTypeError(
- f"Cannot get range on non-int var {step._var_full_name}."
- )
-
- return BaseVar(
- _var_name=f"Array.from(range({v1._var_full_name}, {v2._var_full_name}, {step._var_name}))",
- _var_type=List[int],
- _var_is_local=False,
- _var_data=VarData.merge(
- v1._var_data,
- v2._var_data,
- step._var_data,
- VarData(
- imports={
- "/utils/helpers/range.js": [
- ImportVar(tag="range", is_default=True),
- ],
- },
- ),
- ),
- )
-
- def to(self, type_: Type) -> Var:
- """Convert the type of the var.
-
- Args:
- type_: The type to convert to.
-
- Returns:
- The converted var.
- """
- return self._replace(_var_type=type_)
-
- def as_ref(self) -> Var:
- """Convert the var to a ref.
-
- Returns:
- The var as a ref.
- """
- return self._replace(
- _var_name=f"refs['{self._var_full_name}']",
- _var_is_local=True,
- _var_is_string=False,
- _var_full_name_needs_state_prefix=False,
- merge_var_data=VarData(
- imports={
- f"/{constants.Dirs.STATE_PATH}": [imports.ImportVar(tag="refs")],
- },
- ),
- )
-
- @property
- def _var_full_name(self) -> str:
- """Get the full name of the var.
-
- Returns:
- The full name of the var.
- """
- from reflex.utils import format
-
- if not self._var_full_name_needs_state_prefix:
- return self._var_name
- return (
- self._var_name
- if self._var_data is None or self._var_data.state == ""
- else ".".join(
- [format.format_state_name(self._var_data.state), self._var_name]
- )
- )
-
- def _var_set_state(self, state: Type[BaseState] | str) -> Any:
- """Set the state of the var.
-
- Args:
- state: The state to set or the full name of the state.
-
- Returns:
- The var with the set state.
- """
- from reflex.utils import format
-
- state_name = state if isinstance(state, str) else state.get_full_name()
- new_var_data = VarData(
- state=state_name,
- hooks={
- "const {0} = useContext(StateContexts.{0})".format(
- format.format_state_name(state_name)
- ): None
- },
- imports={
- f"/{constants.Dirs.CONTEXTS_PATH}": [ImportVar(tag="StateContexts")],
- "react": [ImportVar(tag="useContext")],
- },
- )
- self._var_data = VarData.merge(self._var_data, new_var_data)
- self._var_full_name_needs_state_prefix = True
- return self
-
- @property
- def _var_state(self) -> str:
- """Compat method for getting the state.
-
- Returns:
- The state name associated with the var.
- """
- return self._var_data.state if self._var_data else ""
-
- def _get_all_var_data(self) -> VarData | None:
- """Get all the var data.
-
- Returns:
- The var data.
- """
- return self._var_data
-
- def json(self) -> str:
- """Serialize the var to a JSON string.
-
- Raises:
- NotImplementedError: If the method is not implemented.
- """
- raise NotImplementedError("Var subclasses must implement the json method.")
-
- @property
- def _var_name_unwrapped(self) -> str:
- """Get the var str without wrapping in curly braces.
-
- Returns:
- The str var without the wrapped curly braces
- """
- from reflex.style import Style
-
- generic_alias = types.is_generic_alias(self._var_type)
-
- type_ = get_origin(self._var_type) if generic_alias else self._var_type
- wrapped_var = str(self)
-
- return (
- wrapped_var
- if not self._var_state
- and not generic_alias
- and (types._issubclass(type_, dict) or types._issubclass(type_, Style))
- else wrapped_var.strip("{}")
- )
-
-
-# Allow automatic serialization of Var within JSON structures
-serializers.serializer(_encode_var)
-
-
-@dataclasses.dataclass(
- eq=False,
- **{"slots": True} if sys.version_info >= (3, 10) else {},
-)
-class BaseVar(Var):
- """A base (non-computed) var of the app state."""
-
- # The name of the var.
- _var_name: str = dataclasses.field()
-
- # The type of the var.
- _var_type: Type = dataclasses.field(default=Any)
-
- # Whether this is a local javascript variable.
- _var_is_local: bool = dataclasses.field(default=False)
-
- # Whether the var is a string literal.
- _var_is_string: bool = dataclasses.field(default=False)
-
- # _var_full_name should be prefixed with _var_state
- _var_full_name_needs_state_prefix: bool = dataclasses.field(default=False)
-
- # Extra metadata associated with the Var
- _var_data: Optional[VarData] = dataclasses.field(default=None)
-
- _var_is_scope: bool = dataclasses.field(default=False)
-
- def __hash__(self) -> int:
- """Define a hash function for a var.
-
- Returns:
- The hash of the var.
- """
- return hash((self._var_name, str(self._var_type)))
-
- def get_default_value(self) -> Any:
- """Get the default value of the var.
-
- Returns:
- The default value of the var.
-
- Raises:
- ImportError: If the var is a dataframe and pandas is not installed.
- """
- if types.is_optional(self._var_type):
- return None
-
- type_ = (
- get_origin(self._var_type)
- if types.is_generic_alias(self._var_type)
- else self._var_type
- )
- if type_ is Literal:
- args = get_args(self._var_type)
- return args[0] if args else None
- if issubclass(type_, str):
- return ""
- if issubclass(type_, types.get_args(Union[int, float])):
- return 0
- if issubclass(type_, bool):
- return False
- if issubclass(type_, list):
- return []
- if issubclass(type_, dict):
- return {}
- if issubclass(type_, tuple):
- return ()
- if types.is_dataframe(type_):
- try:
- import pandas as pd
-
- return pd.DataFrame()
- except ImportError as e:
- raise ImportError(
- "Please install pandas to use dataframes in your app."
- ) from e
- return set() if issubclass(type_, set) else None
-
- def get_setter_name(self, include_state: bool = True) -> str:
- """Get the name of the var's generated setter function.
-
- Args:
- include_state: Whether to include the state name in the setter name.
-
- Returns:
- The name of the setter function.
- """
- setter = constants.SETTER_PREFIX + self._var_name
- if self._var_data is None:
- return setter
- if not include_state or self._var_data.state == "":
- return setter
- return ".".join((self._var_data.state, setter))
-
- def get_setter(self) -> Callable[[BaseState, Any], None]:
- """Get the var's setter function.
-
- Returns:
- A function that that creates a setter for the var.
- """
-
- def setter(state: BaseState, value: Any):
- """Get the setter for the var.
-
- Args:
- state: The state within which we add the setter function.
- value: The value to set.
- """
- if self._var_type in [int, float]:
- try:
- value = self._var_type(value)
- setattr(state, self._var_name, value)
- except ValueError:
- console.debug(
- f"{type(state).__name__}.{self._var_name}: Failed conversion of {value} to '{self._var_type.__name__}'. Value not set.",
- )
- else:
- setattr(state, self._var_name, value)
-
- setter.__qualname__ = self.get_setter_name()
-
- return setter
-
-
-@dataclasses.dataclass(init=False, eq=False)
-class ComputedVar(Var, property):
- """A field with computed getters."""
-
- # Whether to track dependencies and cache computed values
- _cache: bool = dataclasses.field(default=False)
-
- # Whether the computed var is a backend var
- _backend: bool = dataclasses.field(default=False)
-
- # The initial value of the computed var
- _initial_value: Any | types.Unset = dataclasses.field(default=types.Unset())
-
- # Explicit var dependencies to track
- _static_deps: set[str] = dataclasses.field(default_factory=set)
-
- # Whether var dependencies should be auto-determined
- _auto_deps: bool = dataclasses.field(default=True)
-
- # Interval at which the computed var should be updated
- _update_interval: Optional[datetime.timedelta] = dataclasses.field(default=None)
-
- # The name of the var.
- _var_name: str = dataclasses.field()
-
- # The type of the var.
- _var_type: Type = dataclasses.field(default=Any)
-
- # Whether this is a local javascript variable.
- _var_is_local: bool = dataclasses.field(default=False)
-
- # Whether the var is a string literal.
- _var_is_string: bool = dataclasses.field(default=False)
-
- # _var_full_name should be prefixed with _var_state
- _var_full_name_needs_state_prefix: bool = dataclasses.field(default=False)
-
- # Extra metadata associated with the Var
- _var_data: Optional[VarData] = dataclasses.field(default=None)
-
- def __init__(
- self,
- fget: Callable[[BaseState], Any],
- initial_value: Any | types.Unset = types.Unset(),
- cache: bool = False,
- deps: Optional[List[Union[str, Var]]] = None,
- auto_deps: bool = True,
- interval: Optional[Union[int, datetime.timedelta]] = None,
- backend: bool | None = None,
- **kwargs,
- ):
- """Initialize a ComputedVar.
-
- Args:
- fget: The getter function.
- initial_value: The initial value of the computed var.
- cache: Whether to cache the computed value.
- deps: Explicit var dependencies to track.
- auto_deps: Whether var dependencies should be auto-determined.
- interval: Interval at which the computed var should be updated.
- backend: Whether the computed var is a backend var.
- **kwargs: additional attributes to set on the instance
-
- Raises:
- TypeError: If the computed var dependencies are not Var instances or var names.
- """
- if backend is None:
- backend = fget.__name__.startswith("_")
- self._backend = backend
-
- self._initial_value = initial_value
- self._cache = cache
- if isinstance(interval, int):
- interval = datetime.timedelta(seconds=interval)
- self._update_interval = interval
- if deps is None:
- deps = []
- else:
- for dep in deps:
- if isinstance(dep, Var):
- continue
- if isinstance(dep, str) and dep != "":
- continue
- raise TypeError(
- "ComputedVar dependencies must be Var instances or var names (non-empty strings)."
- )
- self._static_deps = {
- dep._var_name if isinstance(dep, Var) else dep for dep in deps
- }
- self._auto_deps = auto_deps
- property.__init__(self, fget)
- kwargs["_var_name"] = kwargs.pop("_var_name", fget.__name__)
- kwargs["_var_type"] = kwargs.pop("_var_type", self._determine_var_type())
- BaseVar.__init__(self, **kwargs) # type: ignore
-
- @override
- def _replace(self, merge_var_data=None, **kwargs: Any) -> ComputedVar:
- """Replace the attributes of the ComputedVar.
-
- Args:
- merge_var_data: VarData to merge into the existing VarData.
- **kwargs: Var fields to update.
-
- Returns:
- The new ComputedVar instance.
-
- Raises:
- TypeError: If kwargs contains keys that are not allowed.
- """
- field_values = dict(
- fget=kwargs.pop("fget", self.fget),
- initial_value=kwargs.pop("initial_value", self._initial_value),
- cache=kwargs.pop("cache", self._cache),
- deps=kwargs.pop("deps", self._static_deps),
- auto_deps=kwargs.pop("auto_deps", self._auto_deps),
- interval=kwargs.pop("interval", self._update_interval),
- backend=kwargs.pop("backend", self._backend),
- _var_name=kwargs.pop("_var_name", self._var_name),
- _var_type=kwargs.pop("_var_type", self._var_type),
- _var_is_local=kwargs.pop("_var_is_local", self._var_is_local),
- _var_is_string=kwargs.pop("_var_is_string", self._var_is_string),
- _var_full_name_needs_state_prefix=kwargs.pop(
- "_var_full_name_needs_state_prefix",
- self._var_full_name_needs_state_prefix,
- ),
- _var_data=VarData.merge(self._var_data, merge_var_data),
- )
-
- if kwargs:
- unexpected_kwargs = ", ".join(kwargs.keys())
- raise TypeError(f"Unexpected keyword arguments: {unexpected_kwargs}")
-
- return ComputedVar(**field_values)
-
- @property
- def _cache_attr(self) -> str:
- """Get the attribute used to cache the value on the instance.
-
- Returns:
- An attribute name.
- """
- return f"__cached_{self._var_name}"
-
- @property
- def _last_updated_attr(self) -> str:
- """Get the attribute used to store the last updated timestamp.
-
- Returns:
- An attribute name.
- """
- return f"__last_updated_{self._var_name}"
-
- def needs_update(self, instance: BaseState) -> bool:
- """Check if the computed var needs to be updated.
-
- Args:
- instance: The state instance that the computed var is attached to.
-
- Returns:
- True if the computed var needs to be updated, False otherwise.
- """
- if self._update_interval is None:
- return False
- last_updated = getattr(instance, self._last_updated_attr, None)
- if last_updated is None:
- return True
- return datetime.datetime.now() - last_updated > self._update_interval
-
- def __get__(self, instance: BaseState | None, owner):
- """Get the ComputedVar value.
-
- If the value is already cached on the instance, return the cached value.
-
- Args:
- instance: the instance of the class accessing this computed var.
- owner: the class that this descriptor is attached to.
-
- Returns:
- The value of the var for the given instance.
- """
- if instance is None or not self._cache:
- return super().__get__(instance, owner)
-
- # handle caching
- if not hasattr(instance, self._cache_attr) or self.needs_update(instance):
- # Set cache attr on state instance.
- setattr(instance, self._cache_attr, super().__get__(instance, owner))
- # Ensure the computed var gets serialized to redis.
- instance._was_touched = True
- # Set the last updated timestamp on the state instance.
- setattr(instance, self._last_updated_attr, datetime.datetime.now())
- return getattr(instance, self._cache_attr)
-
- def _deps(
- self,
- objclass: Type,
- obj: FunctionType | CodeType | None = None,
- self_name: Optional[str] = None,
- ) -> set[str]:
- """Determine var dependencies of this ComputedVar.
-
- Save references to attributes accessed on "self". Recursively called
- when the function makes a method call on "self" or define comprehensions
- or nested functions that may reference "self".
-
- Args:
- objclass: the class obj this ComputedVar is attached to.
- obj: the object to disassemble (defaults to the fget function).
- self_name: if specified, look for this name in LOAD_FAST and LOAD_DEREF instructions.
-
- Returns:
- A set of variable names accessed by the given obj.
-
- Raises:
- VarValueError: if the function references the get_state, parent_state, or substates attributes
- (cannot track deps in a related state, only implicitly via parent state).
- """
- if not self._auto_deps:
- return self._static_deps
- d = self._static_deps.copy()
- if obj is None:
- fget = property.__getattribute__(self, "fget")
- if fget is not None:
- obj = cast(FunctionType, fget)
- else:
- return set()
- with contextlib.suppress(AttributeError):
- # unbox functools.partial
- obj = cast(FunctionType, obj.func) # type: ignore
- with contextlib.suppress(AttributeError):
- # unbox EventHandler
- obj = cast(FunctionType, obj.fn) # type: ignore
-
- if self_name is None and isinstance(obj, FunctionType):
- try:
- # the first argument to the function is the name of "self" arg
- self_name = obj.__code__.co_varnames[0]
- except (AttributeError, IndexError):
- self_name = None
- if self_name is None:
- # cannot reference attributes on self if method takes no args
- return set()
-
- invalid_names = ["get_state", "parent_state", "substates", "get_substate"]
- self_is_top_of_stack = False
- for instruction in dis.get_instructions(obj):
- if (
- instruction.opname in ("LOAD_FAST", "LOAD_DEREF")
- and instruction.argval == self_name
- ):
- # bytecode loaded the class instance to the top of stack, next load instruction
- # is referencing an attribute on self
- self_is_top_of_stack = True
- continue
- if self_is_top_of_stack and instruction.opname in (
- "LOAD_ATTR",
- "LOAD_METHOD",
- ):
- try:
- ref_obj = getattr(objclass, instruction.argval)
- except Exception:
- ref_obj = None
- if instruction.argval in invalid_names:
- raise VarValueError(
- f"Cached var {self._var_full_name} cannot access arbitrary state via `{instruction.argval}`."
- )
- if callable(ref_obj):
- # recurse into callable attributes
- d.update(
- self._deps(
- objclass=objclass,
- obj=ref_obj,
- )
- )
- # recurse into property fget functions
- elif isinstance(ref_obj, property) and not isinstance(
- ref_obj, ComputedVar
- ):
- d.update(
- self._deps(
- objclass=objclass,
- obj=ref_obj.fget, # type: ignore
- )
- )
- elif (
- instruction.argval in objclass.backend_vars
- or instruction.argval in objclass.vars
- ):
- # var access
- d.add(instruction.argval)
- elif instruction.opname == "LOAD_CONST" and isinstance(
- instruction.argval, CodeType
- ):
- # recurse into nested functions / comprehensions, which can reference
- # instance attributes from the outer scope
- d.update(
- self._deps(
- objclass=objclass,
- obj=instruction.argval,
- self_name=self_name,
- )
- )
- self_is_top_of_stack = False
- return d
-
- def mark_dirty(self, instance) -> None:
- """Mark this ComputedVar as dirty.
-
- Args:
- instance: the state instance that needs to recompute the value.
- """
- with contextlib.suppress(AttributeError):
- delattr(instance, self._cache_attr)
-
- def _determine_var_type(self) -> Type:
- """Get the type of the var.
-
- Returns:
- The type of the var.
- """
- hints = get_type_hints(property.__getattribute__(self, "fget"))
- if "return" in hints:
- return hints["return"]
- return Any
-
-
-def computed_var(
- fget: Callable[[BaseState], Any] | None = None,
- initial_value: Any | types.Unset = types.Unset(),
- cache: bool = False,
- deps: Optional[List[Union[str, Var]]] = None,
- auto_deps: bool = True,
- interval: Optional[Union[datetime.timedelta, int]] = None,
- backend: bool | None = None,
- _deprecated_cached_var: bool = False,
- **kwargs,
-) -> ComputedVar | Callable[[Callable[[BaseState], Any]], ComputedVar]:
- """A ComputedVar decorator with or without kwargs.
-
- Args:
- fget: The getter function.
- initial_value: The initial value of the computed var.
- cache: Whether to cache the computed value.
- deps: Explicit var dependencies to track.
- auto_deps: Whether var dependencies should be auto-determined.
- interval: Interval at which the computed var should be updated.
- backend: Whether the computed var is a backend var.
- _deprecated_cached_var: Indicate usage of deprecated cached_var partial function.
- **kwargs: additional attributes to set on the instance
-
- Returns:
- A ComputedVar instance.
-
- Raises:
- ValueError: If caching is disabled and an update interval is set.
- VarDependencyError: If user supplies dependencies without caching.
- """
- if _deprecated_cached_var:
- console.deprecate(
- feature_name="cached_var",
- reason=("Use @rx.var(cache=True) instead of @rx.cached_var."),
- deprecation_version="0.5.6",
- removal_version="0.6.0",
- )
-
- if cache is False and interval is not None:
- raise ValueError("Cannot set update interval without caching.")
-
- if cache is False and (deps is not None or auto_deps is False):
- raise VarDependencyError("Cannot track dependencies without caching.")
-
- if fget is not None:
- return ComputedVar(fget=fget, cache=cache)
-
- def wrapper(fget: Callable[[BaseState], Any]) -> ComputedVar:
- return ComputedVar(
- fget=fget,
- initial_value=initial_value,
- cache=cache,
- deps=deps,
- auto_deps=auto_deps,
- interval=interval,
- backend=backend,
- **kwargs,
- )
-
- return wrapper
-
-
-# Partial function of computed_var with cache=True
-cached_var = functools.partial(computed_var, cache=True, _deprecated_cached_var=True)
-
-
-class CallableVar(BaseVar):
- """Decorate a Var-returning function to act as both a Var and a function.
-
- This is used as a compatibility shim for replacing Var objects in the
- API with functions that return a family of Var.
- """
-
- def __init__(self, fn: Callable[..., BaseVar]):
- """Initialize a CallableVar.
-
- Args:
- fn: The function to decorate (must return Var)
- """
- self.fn = fn
- default_var = fn()
- super().__init__(**dataclasses.asdict(default_var))
-
- def __call__(self, *args, **kwargs) -> BaseVar:
- """Call the decorated function.
-
- Args:
- *args: The args to pass to the function.
- **kwargs: The kwargs to pass to the function.
-
- Returns:
- The Var returned from calling the function.
- """
- return self.fn(*args, **kwargs)
-
-
-def get_uuid_string_var() -> Var:
- """Return a Var that generates a single memoized UUID via .web/utils/state.js.
-
- useMemo with an empty dependency array ensures that the generated UUID is
- consistent across re-renders of the component.
-
- Returns:
- A Var that generates a UUID at runtime.
- """
- from reflex.utils.imports import ImportVar
-
- unique_uuid_var_data = VarData(
- imports={
- f"/{constants.Dirs.STATE_PATH}": {ImportVar(tag="generateUUID")}, # type: ignore
- "react": "useMemo",
- }
- )
-
- return BaseVar(
- _var_name="useMemo(generateUUID, [])",
- _var_type=str,
- _var_data=unique_uuid_var_data,
- )
diff --git a/reflex/vars.pyi b/reflex/vars.pyi
deleted file mode 100644
index 47d433374..000000000
--- a/reflex/vars.pyi
+++ /dev/null
@@ -1,218 +0,0 @@
-"""Generated with stubgen from mypy, then manually edited, do not regen."""
-
-from __future__ import annotations
-
-import datetime
-from dataclasses import dataclass
-from types import FunctionType
-from typing import (
- Any,
- Callable,
- Dict,
- Iterable,
- List,
- Optional,
- Set,
- Tuple,
- Type,
- Union,
- _GenericAlias, # type: ignore
- overload,
-)
-
-from _typeshed import Incomplete
-
-from reflex import constants as constants
-from reflex.base import Base as Base
-from reflex.state import BaseState as BaseState
-from reflex.state import State as State
-from reflex.utils import console as console
-from reflex.utils import format as format
-from reflex.utils import types as types
-from reflex.utils.imports import ImmutableParsedImportDict, ImportDict, ParsedImportDict
-
-USED_VARIABLES: Incomplete
-
-def get_unique_variable_name() -> str: ...
-def _encode_var(value: Var) -> str: ...
-
-_global_vars: Dict[int, Var]
-
-def _decode_var(value: str) -> tuple[VarData, str]: ...
-def _extract_var_data(value: Iterable) -> list[VarData | None]: ...
-
-class VarData(Base):
- state: str = ""
- imports: Union[ImportDict, ParsedImportDict] = {}
- hooks: Dict[str, None] = {}
- interpolations: List[Tuple[int, int]] = []
- @classmethod
- def merge(cls, *others: ImmutableVarData | VarData | None) -> VarData | None: ...
-
-class ImmutableVarData:
- state: str = ""
- imports: ImmutableParsedImportDict = tuple()
- hooks: Tuple[str, ...] = tuple()
- def __init__(
- self,
- state: str = "",
- imports: ImportDict | ParsedImportDict | None = None,
- hooks: dict[str, None] | None = None,
- ) -> None: ...
- @classmethod
- def merge(
- cls, *others: ImmutableVarData | VarData | None
- ) -> ImmutableVarData | None: ...
-
-def _decode_var_immutable(value: str) -> tuple[ImmutableVarData, str]: ...
-
-class Var:
- _var_name: str
- _var_type: Type
- _var_is_local: bool = False
- _var_is_string: bool = False
- _var_full_name_needs_state_prefix: bool = False
- _var_data: VarData | None = None
- @classmethod
- def create(
- cls,
- value: Any,
- _var_is_local: bool = True,
- _var_is_string: bool | None = None,
- _var_data: VarData | None = None,
- ) -> Optional[Var]: ...
- @classmethod
- def create_safe(
- cls,
- value: Any,
- _var_is_local: bool = True,
- _var_is_string: bool | None = None,
- _var_data: VarData | None = None,
- ) -> Var: ...
- @classmethod
- def __class_getitem__(cls, type_: Type) -> _GenericAlias: ...
- def _replace(self, merge_var_data=None, **kwargs: Any) -> BaseVar: ...
- def equals(self, other: Var) -> bool: ...
- def to_string(self) -> Var: ...
- def __hash__(self) -> int: ...
- def __format__(self, format_spec: str) -> str: ...
- def __getitem__(self, i: Any) -> Var: ...
- def __getattribute__(self, name: str) -> Var: ...
- def operation(
- self,
- op: str = ...,
- other: Optional[Var] = ...,
- type_: Optional[Type] = ...,
- flip: bool = ...,
- fn: Optional[str] = ...,
- ) -> Var: ...
- def compare(self, op: str, other: Var) -> Var: ...
- def __invert__(self) -> Var: ...
- def __neg__(self) -> Var: ...
- def __abs__(self) -> Var: ...
- def length(self) -> Var: ...
- def __eq__(self, other: Var) -> Var: ...
- def __ne__(self, other: Var) -> Var: ...
- def __gt__(self, other: Var) -> Var: ...
- def __ge__(self, other: Var) -> Var: ...
- def __lt__(self, other: Var) -> Var: ...
- def __le__(self, other: Var) -> Var: ...
- def __add__(self, other: Var) -> Var: ...
- def __radd__(self, other: Var) -> Var: ...
- def __sub__(self, other: Var) -> Var: ...
- def __rsub__(self, other: Var) -> Var: ...
- def __mul__(self, other: Var) -> Var: ...
- def __rmul__(self, other: Var) -> Var: ...
- def __pow__(self, other: Var) -> Var: ...
- def __rpow__(self, other: Var) -> Var: ...
- def __truediv__(self, other: Var) -> Var: ...
- def __rtruediv__(self, other: Var) -> Var: ...
- def __floordiv__(self, other: Var) -> Var: ...
- def __mod__(self, other: Var) -> Var: ...
- def __rmod__(self, other: Var) -> Var: ...
- def __and__(self, other: Var) -> Var: ...
- def __rand__(self, other: Var) -> Var: ...
- def __or__(self, other: Var) -> Var: ...
- def __ror__(self, other: Var) -> Var: ...
- def __contains__(self, _: Any) -> Var: ...
- def contains(self, other: Any, field: Union[Var, None] = None) -> Var: ...
- def reverse(self) -> Var: ...
- def foreach(self, fn: Callable) -> Var: ...
- @classmethod
- def range(
- cls,
- v1: Var | int = 0,
- v2: Var | int | None = None,
- step: Var | int | None = None,
- ) -> Var: ...
- def to(self, type_: Type) -> Var: ...
- def as_ref(self) -> Var: ...
- @property
- def _var_full_name(self) -> str: ...
- def _var_set_state(self, state: Type[BaseState] | str) -> Any: ...
- def _get_all_var_data(self) -> VarData: ...
- def json(self) -> str: ...
-
-@dataclass(eq=False)
-class BaseVar(Var):
- _var_name: str
- _var_type: Any
- _var_is_local: bool = False
- _var_is_string: bool = False
- _var_full_name_needs_state_prefix: bool = False
- _var_data: VarData | None = None
- def __hash__(self) -> int: ...
- def get_default_value(self) -> Any: ...
- def get_setter_name(self, include_state: bool = ...) -> str: ...
- def get_setter(self) -> Callable[[BaseState, Any], None]: ...
-
-@dataclass(init=False)
-class ComputedVar(Var):
- _var_cache: bool
- fget: FunctionType
- @property
- def _cache_attr(self) -> str: ...
- def __get__(self, instance, owner): ...
- def _deps(self, objclass: Type, obj: Optional[FunctionType] = ...) -> Set[str]: ...
- def _replace(self, merge_var_data=None, **kwargs: Any) -> ComputedVar: ...
- def mark_dirty(self, instance) -> None: ...
- def needs_update(self, instance) -> bool: ...
- def _determine_var_type(self) -> Type: ...
- @overload
- def __init__(
- self,
- fget: Callable[[BaseState], Any],
- **kwargs,
- ) -> None: ...
- @overload
- def __init__(self, func) -> None: ...
-
-@overload
-def computed_var(
- fget: Callable[[BaseState], Any] | None = None,
- initial_value: Any | types.Unset = types.Unset(),
- cache: bool = False,
- deps: Optional[List[Union[str, Var]]] = None,
- auto_deps: bool = True,
- interval: Optional[Union[datetime.timedelta, int]] = None,
- **kwargs,
-) -> Callable[[Callable[[Any], Any]], ComputedVar]: ...
-@overload
-def computed_var(fget: Callable[[Any], Any]) -> ComputedVar: ...
-@overload
-def cached_var(
- fget: Callable[[BaseState], Any] | None = None,
- initial_value: Any | types.Unset = types.Unset(),
- deps: Optional[List[Union[str, Var]]] = None,
- auto_deps: bool = True,
- interval: Optional[Union[datetime.timedelta, int]] = None,
- **kwargs,
-) -> Callable[[Callable[[Any], Any]], ComputedVar]: ...
-@overload
-def cached_var(fget: Callable[[Any], Any]) -> ComputedVar: ...
-
-class CallableVar(BaseVar):
- def __init__(self, fn: Callable[..., BaseVar]): ...
- def __call__(self, *args, **kwargs) -> BaseVar: ...
-
-def get_uuid_string_var() -> Var: ...
diff --git a/reflex/experimental/vars/__init__.py b/reflex/vars/__init__.py
similarity index 67%
rename from reflex/experimental/vars/__init__.py
rename to reflex/vars/__init__.py
index 8fa5196ff..cb02319bc 100644
--- a/reflex/experimental/vars/__init__.py
+++ b/reflex/vars/__init__.py
@@ -1,8 +1,15 @@
-"""Experimental Immutable-Based Var System."""
+"""Immutable-Based Var System."""
-from .base import ImmutableVar as ImmutableVar
+from .base import Field as Field
from .base import LiteralVar as LiteralVar
+from .base import Var as Var
+from .base import VarData as VarData
+from .base import field as field
+from .base import get_unique_variable_name as get_unique_variable_name
+from .base import get_uuid_string_var as get_uuid_string_var
from .base import var_operation as var_operation
+from .base import var_operation_return as var_operation_return
+from .datetime import DateTimeVar as DateTimeVar
from .function import FunctionStringVar as FunctionStringVar
from .function import FunctionVar as FunctionVar
from .function import VarOperationCall as VarOperationCall
@@ -12,7 +19,6 @@ from .number import LiteralNumberVar as LiteralNumberVar
from .number import NumberVar as NumberVar
from .object import LiteralObjectVar as LiteralObjectVar
from .object import ObjectVar as ObjectVar
-from .sequence import ArrayJoinOperation as ArrayJoinOperation
from .sequence import ArrayVar as ArrayVar
from .sequence import ConcatVarOperation as ConcatVarOperation
from .sequence import LiteralArrayVar as LiteralArrayVar
diff --git a/reflex/vars/base.py b/reflex/vars/base.py
new file mode 100644
index 000000000..094a478c8
--- /dev/null
+++ b/reflex/vars/base.py
@@ -0,0 +1,2981 @@
+"""Collection of base classes."""
+
+from __future__ import annotations
+
+import contextlib
+import dataclasses
+import datetime
+import dis
+import functools
+import inspect
+import json
+import random
+import re
+import string
+import sys
+import warnings
+from types import CodeType, FunctionType
+from typing import (
+ TYPE_CHECKING,
+ Any,
+ Callable,
+ ClassVar,
+ Dict,
+ FrozenSet,
+ Generic,
+ Iterable,
+ List,
+ Literal,
+ NoReturn,
+ Optional,
+ Set,
+ Tuple,
+ Type,
+ TypeVar,
+ Union,
+ cast,
+ get_args,
+ overload,
+)
+
+from typing_extensions import ParamSpec, TypeGuard, deprecated, get_type_hints, override
+
+from reflex import constants
+from reflex.base import Base
+from reflex.constants.compiler import Hooks
+from reflex.utils import console, exceptions, imports, serializers, types
+from reflex.utils.exceptions import (
+ VarAttributeError,
+ VarDependencyError,
+ VarTypeError,
+ VarValueError,
+)
+from reflex.utils.format import format_state_name
+from reflex.utils.imports import (
+ ImmutableParsedImportDict,
+ ImportDict,
+ ImportVar,
+ ParsedImportDict,
+ parse_imports,
+)
+from reflex.utils.types import (
+ GenericType,
+ Self,
+ _isinstance,
+ get_origin,
+ has_args,
+ unionize,
+)
+
+if TYPE_CHECKING:
+ from reflex.state import BaseState
+
+ from .number import BooleanVar, NumberVar
+ from .object import ObjectVar
+ from .sequence import ArrayVar, StringVar
+
+
+VAR_TYPE = TypeVar("VAR_TYPE", covariant=True)
+OTHER_VAR_TYPE = TypeVar("OTHER_VAR_TYPE")
+
+warnings.filterwarnings("ignore", message="fields may not start with an underscore")
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+)
+class VarSubclassEntry:
+ """Entry for a Var subclass."""
+
+ var_subclass: Type[Var]
+ to_var_subclass: Type[ToOperation]
+ python_types: Tuple[GenericType, ...]
+
+
+_var_subclasses: List[VarSubclassEntry] = []
+_var_literal_subclasses: List[Tuple[Type[LiteralVar], VarSubclassEntry]] = []
+
+
+@dataclasses.dataclass(
+ eq=True,
+ frozen=True,
+)
+class VarData:
+ """Metadata associated with a x."""
+
+ # The name of the enclosing state.
+ state: str = dataclasses.field(default="")
+
+ # The name of the field in the state.
+ field_name: str = dataclasses.field(default="")
+
+ # Imports needed to render this var
+ imports: ImmutableParsedImportDict = dataclasses.field(default_factory=tuple)
+
+ # Hooks that need to be present in the component to render this var
+ hooks: Tuple[str, ...] = dataclasses.field(default_factory=tuple)
+
+ # Dependencies of the var
+ deps: Tuple[Var, ...] = dataclasses.field(default_factory=tuple)
+
+ # Position of the hook in the component
+ position: Hooks.HookPosition | None = None
+
+ def __init__(
+ self,
+ state: str = "",
+ field_name: str = "",
+ imports: ImportDict | ParsedImportDict | None = None,
+ hooks: dict[str, None] | None = None,
+ deps: list[Var] | None = None,
+ position: Hooks.HookPosition | None = None,
+ ):
+ """Initialize the var data.
+
+ Args:
+ state: The name of the enclosing state.
+ field_name: The name of the field in the state.
+ imports: Imports needed to render this var.
+ hooks: Hooks that need to be present in the component to render this var.
+ deps: Dependencies of the var for useCallback.
+ position: Position of the hook in the component.
+ """
+ immutable_imports: ImmutableParsedImportDict = tuple(
+ sorted(
+ ((k, tuple(sorted(v))) for k, v in parse_imports(imports or {}).items())
+ )
+ )
+ object.__setattr__(self, "state", state)
+ object.__setattr__(self, "field_name", field_name)
+ object.__setattr__(self, "imports", immutable_imports)
+ object.__setattr__(self, "hooks", tuple(hooks or {}))
+ object.__setattr__(self, "deps", tuple(deps or []))
+ object.__setattr__(self, "position", position or None)
+
+ def old_school_imports(self) -> ImportDict:
+ """Return the imports as a mutable dict.
+
+ Returns:
+ The imports as a mutable dict.
+ """
+ return {k: list(v) for k, v in self.imports}
+
+ def merge(*all: VarData | None) -> VarData | None:
+ """Merge multiple var data objects.
+
+ Args:
+ *all: The var data objects to merge.
+
+ Raises:
+ ReflexError: If trying to merge VarData with different positions.
+
+ Returns:
+ The merged var data object.
+
+ # noqa: DAR102 *all
+ """
+ all_var_datas = list(filter(None, all))
+
+ if not all_var_datas:
+ return None
+
+ if len(all_var_datas) == 1:
+ return all_var_datas[0]
+
+ # Get the first non-empty field name or default to empty string.
+ field_name = next(
+ (var_data.field_name for var_data in all_var_datas if var_data.field_name),
+ "",
+ )
+
+ # Get the first non-empty state or default to empty string.
+ state = next(
+ (var_data.state for var_data in all_var_datas if var_data.state), ""
+ )
+
+ hooks = {hook: None for var_data in all_var_datas for hook in var_data.hooks}
+
+ _imports = imports.merge_imports(
+ *(var_data.imports for var_data in all_var_datas)
+ )
+
+ deps = [dep for var_data in all_var_datas for dep in var_data.deps]
+
+ positions = list(
+ {
+ var_data.position
+ for var_data in all_var_datas
+ if var_data.position is not None
+ }
+ )
+ if positions:
+ if len(positions) > 1:
+ raise exceptions.ReflexError(
+ f"Cannot merge var data with different positions: {positions}"
+ )
+ position = positions[0]
+ else:
+ position = None
+
+ if state or _imports or hooks or field_name or deps or position:
+ return VarData(
+ state=state,
+ field_name=field_name,
+ imports=_imports,
+ hooks=hooks,
+ deps=deps,
+ position=position,
+ )
+
+ return None
+
+ def __bool__(self) -> bool:
+ """Check if the var data is non-empty.
+
+ Returns:
+ True if any field is set to a non-default value.
+ """
+ return bool(
+ self.state
+ or self.imports
+ or self.hooks
+ or self.field_name
+ or self.deps
+ or self.position
+ )
+
+ @classmethod
+ def from_state(cls, state: Type[BaseState] | str, field_name: str = "") -> VarData:
+ """Set the state of the var.
+
+ Args:
+ state: The state to set or the full name of the state.
+ field_name: The name of the field in the state. Optional.
+
+ Returns:
+ The var with the set state.
+ """
+ from reflex.utils import format
+
+ state_name = state if isinstance(state, str) else state.get_full_name()
+ return VarData(
+ state=state_name,
+ field_name=field_name,
+ hooks={
+ "const {0} = useContext(StateContexts.{0})".format(
+ format.format_state_name(state_name)
+ ): None
+ },
+ imports={
+ f"$/{constants.Dirs.CONTEXTS_PATH}": [ImportVar(tag="StateContexts")],
+ "react": [ImportVar(tag="useContext")],
+ },
+ )
+
+
+def _decode_var_immutable(value: str) -> tuple[VarData | None, str]:
+ """Decode the state name from a formatted var.
+
+ Args:
+ value: The value to extract the state name from.
+
+ Returns:
+ The extracted state name and the value without the state name.
+ """
+ var_datas = []
+ if isinstance(value, str):
+ # fast path if there is no encoded VarData
+ if constants.REFLEX_VAR_OPENING_TAG not in value:
+ return None, value
+
+ offset = 0
+
+ # Find all tags.
+ while m := _decode_var_pattern.search(value):
+ start, end = m.span()
+ value = value[:start] + value[end:]
+
+ serialized_data = m.group(1)
+
+ if serialized_data.isnumeric() or (
+ serialized_data[0] == "-" and serialized_data[1:].isnumeric()
+ ):
+ # This is a global immutable var.
+ var = _global_vars[int(serialized_data)]
+ var_data = var._get_all_var_data()
+
+ if var_data is not None:
+ var_datas.append(var_data)
+ offset += end - start
+
+ return VarData.merge(*var_datas) if var_datas else None, value
+
+
+def can_use_in_object_var(cls: GenericType) -> bool:
+ """Check if the class can be used in an ObjectVar.
+
+ Args:
+ cls: The class to check.
+
+ Returns:
+ Whether the class can be used in an ObjectVar.
+ """
+ if types.is_union(cls):
+ return all(can_use_in_object_var(t) for t in types.get_args(cls))
+ return (
+ inspect.isclass(cls)
+ and not issubclass(cls, Var)
+ and serializers.can_serialize(cls, dict)
+ )
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+)
+class Var(Generic[VAR_TYPE]):
+ """Base class for immutable vars."""
+
+ # The name of the var.
+ _js_expr: str = dataclasses.field()
+
+ # The type of the var.
+ _var_type: types.GenericType = dataclasses.field(default=Any)
+
+ # Extra metadata associated with the Var
+ _var_data: Optional[VarData] = dataclasses.field(default=None)
+
+ def __str__(self) -> str:
+ """String representation of the var. Guaranteed to be a valid Javascript expression.
+
+ Returns:
+ The name of the var.
+ """
+ return self._js_expr
+
+ @property
+ def _var_is_local(self) -> bool:
+ """Whether this is a local javascript variable.
+
+ Returns:
+ False
+ """
+ return False
+
+ @property
+ @deprecated("Use `_js_expr` instead.")
+ def _var_name(self) -> str:
+ """The name of the var.
+
+ Returns:
+ The name of the var.
+ """
+ return self._js_expr
+
+ @property
+ def _var_field_name(self) -> str:
+ """The name of the field.
+
+ Returns:
+ The name of the field.
+ """
+ var_data = self._get_all_var_data()
+ field_name = var_data.field_name if var_data else None
+ return field_name or self._js_expr
+
+ @property
+ @deprecated("Use `_js_expr` instead.")
+ def _var_name_unwrapped(self) -> str:
+ """The name of the var without extra curly braces.
+
+ Returns:
+ The name of the var.
+ """
+ return self._js_expr
+
+ @property
+ def _var_is_string(self) -> bool:
+ """Whether the var is a string literal.
+
+ Returns:
+ False
+ """
+ return False
+
+ def __init_subclass__(
+ cls,
+ python_types: Tuple[GenericType, ...] | GenericType = types.Unset(),
+ default_type: GenericType = types.Unset(),
+ **kwargs,
+ ):
+ """Initialize the subclass.
+
+ Args:
+ python_types: The python types that the var represents.
+ default_type: The default type of the var. Defaults to the first python type.
+ **kwargs: Additional keyword arguments.
+ """
+ super().__init_subclass__(**kwargs)
+
+ if python_types or default_type:
+ python_types = (
+ (python_types if isinstance(python_types, tuple) else (python_types,))
+ if python_types
+ else ()
+ )
+
+ default_type = default_type or (python_types[0] if python_types else Any)
+
+ @dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+ )
+ class ToVarOperation(ToOperation, cls):
+ """Base class of converting a var to another var type."""
+
+ _original: Var = dataclasses.field(
+ default=Var(_js_expr="null", _var_type=None),
+ )
+
+ _default_var_type: ClassVar[GenericType] = default_type
+
+ ToVarOperation.__name__ = f'To{cls.__name__.removesuffix("Var")}Operation'
+
+ _var_subclasses.append(VarSubclassEntry(cls, ToVarOperation, python_types))
+
+ def __post_init__(self):
+ """Post-initialize the var."""
+ # Decode any inline Var markup and apply it to the instance
+ _var_data, _js_expr = _decode_var_immutable(self._js_expr)
+
+ if _var_data or _js_expr != self._js_expr:
+ self.__init__(
+ _js_expr=_js_expr,
+ _var_type=self._var_type,
+ _var_data=VarData.merge(self._var_data, _var_data),
+ )
+
+ def __hash__(self) -> int:
+ """Define a hash function for the var.
+
+ Returns:
+ The hash of the var.
+ """
+ return hash((self._js_expr, self._var_type, self._var_data))
+
+ def _get_all_var_data(self) -> VarData | None:
+ """Get all VarData associated with the Var.
+
+ Returns:
+ The VarData of the components and all of its children.
+ """
+ return self._var_data
+
+ def equals(self, other: Var) -> bool:
+ """Check if two vars are equal.
+
+ Args:
+ other: The other var to compare.
+
+ Returns:
+ Whether the vars are equal.
+ """
+ return (
+ self._js_expr == other._js_expr
+ and self._var_type == other._var_type
+ and self._get_all_var_data() == other._get_all_var_data()
+ )
+
+ @overload
+ def _replace(
+ self, _var_type: Type[OTHER_VAR_TYPE], merge_var_data=None, **kwargs: Any
+ ) -> Var[OTHER_VAR_TYPE]: ...
+
+ @overload
+ def _replace(
+ self, _var_type: GenericType | None = None, merge_var_data=None, **kwargs: Any
+ ) -> Self: ...
+
+ def _replace(
+ self, _var_type: GenericType | None = None, merge_var_data=None, **kwargs: Any
+ ) -> Self | Var:
+ """Make a copy of this Var with updated fields.
+
+ Args:
+ merge_var_data: VarData to merge into the existing VarData.
+ **kwargs: Var fields to update.
+
+ Returns:
+ A new Var with the updated fields overwriting the corresponding fields in this Var.
+
+ Raises:
+ TypeError: If _var_is_local, _var_is_string, or _var_full_name_needs_state_prefix is not None.
+ """
+ if kwargs.get("_var_is_local", False) is not False:
+ raise TypeError("The _var_is_local argument is not supported for Var.")
+
+ if kwargs.get("_var_is_string", False) is not False:
+ raise TypeError("The _var_is_string argument is not supported for Var.")
+
+ if kwargs.get("_var_full_name_needs_state_prefix", False) is not False:
+ raise TypeError(
+ "The _var_full_name_needs_state_prefix argument is not supported for Var."
+ )
+ value_with_replaced = dataclasses.replace(
+ self,
+ _var_type=_var_type or self._var_type,
+ _var_data=VarData.merge(
+ kwargs.get("_var_data", self._var_data), merge_var_data
+ ),
+ **kwargs,
+ )
+
+ if (js_expr := kwargs.get("_js_expr")) is not None:
+ object.__setattr__(value_with_replaced, "_js_expr", js_expr)
+
+ return value_with_replaced
+
+ @classmethod
+ def create(
+ cls,
+ value: Any,
+ _var_is_local: bool | None = None,
+ _var_is_string: bool | None = None,
+ _var_data: VarData | None = None,
+ ) -> Var:
+ """Create a var from a value.
+
+ Args:
+ value: The value to create the var from.
+ _var_is_local: Whether the var is local. Deprecated.
+ _var_is_string: Whether the var is a string literal. Deprecated.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The var.
+ """
+ if _var_is_local is not None:
+ console.deprecate(
+ feature_name="_var_is_local",
+ reason="The _var_is_local argument is not supported for Var."
+ "If you want to create a Var from a raw Javascript expression, use the constructor directly",
+ deprecation_version="0.6.0",
+ removal_version="0.7.0",
+ )
+ if _var_is_string is not None:
+ console.deprecate(
+ feature_name="_var_is_string",
+ reason="The _var_is_string argument is not supported for Var."
+ "If you want to create a Var from a raw Javascript expression, use the constructor directly",
+ deprecation_version="0.6.0",
+ removal_version="0.7.0",
+ )
+
+ # If the value is already a var, do nothing.
+ if isinstance(value, Var):
+ return value
+
+ # Try to pull the imports and hooks from contained values.
+ if not isinstance(value, str):
+ return LiteralVar.create(value)
+
+ if _var_is_string is False or _var_is_local is True:
+ return cls(
+ _js_expr=value,
+ _var_data=_var_data,
+ )
+
+ return LiteralVar.create(value, _var_data=_var_data)
+
+ @classmethod
+ @deprecated("Use `.create()` instead.")
+ def create_safe(
+ cls,
+ *args: Any,
+ **kwargs: Any,
+ ) -> Var:
+ """Create a var from a value.
+
+ Args:
+ *args: The arguments to create the var from.
+ **kwargs: The keyword arguments to create the var from.
+
+ Returns:
+ The var.
+ """
+ return cls.create(*args, **kwargs)
+
+ def __format__(self, format_spec: str) -> str:
+ """Format the var into a Javascript equivalent to an f-string.
+
+ Args:
+ format_spec: The format specifier (Ignored for now).
+
+ Returns:
+ The formatted var.
+ """
+ hashed_var = hash(self)
+
+ _global_vars[hashed_var] = self
+
+ # Encode the _var_data into the formatted output for tracking purposes.
+ return f"{constants.REFLEX_VAR_OPENING_TAG}{hashed_var}{constants.REFLEX_VAR_CLOSING_TAG}{self._js_expr}"
+
+ @overload
+ def to(self, output: Type[str]) -> StringVar: ...
+
+ @overload
+ def to(self, output: Type[bool]) -> BooleanVar: ...
+
+ @overload
+ def to(self, output: type[int] | type[float]) -> NumberVar: ...
+
+ @overload
+ def to(
+ self,
+ output: type[list] | type[tuple] | type[set],
+ ) -> ArrayVar: ...
+
+ @overload
+ def to(
+ self,
+ output: type[dict],
+ ) -> ObjectVar[dict]: ...
+
+ @overload
+ def to(
+ self, output: Type[ObjectVar], var_type: Type[VAR_INSIDE]
+ ) -> ObjectVar[VAR_INSIDE]: ...
+
+ @overload
+ def to(
+ self, output: Type[ObjectVar], var_type: None = None
+ ) -> ObjectVar[VAR_TYPE]: ...
+
+ @overload
+ def to(self, output: VAR_SUBCLASS, var_type: None = None) -> VAR_SUBCLASS: ...
+
+ @overload
+ def to(
+ self,
+ output: Type[OUTPUT] | types.GenericType,
+ var_type: types.GenericType | None = None,
+ ) -> OUTPUT: ...
+
+ def to(
+ self,
+ output: Type[OUTPUT] | types.GenericType,
+ var_type: types.GenericType | None = None,
+ ) -> Var:
+ """Convert the var to a different type.
+
+ Args:
+ output: The output type.
+ var_type: The type of the var.
+
+ Returns:
+ The converted var.
+ """
+ from .object import ObjectVar
+
+ fixed_output_type = get_origin(output) or output
+
+ # If the first argument is a python type, we map it to the corresponding Var type.
+ for var_subclass in _var_subclasses[::-1]:
+ if fixed_output_type in var_subclass.python_types:
+ return self.to(var_subclass.var_subclass, output)
+
+ if fixed_output_type is None:
+ return get_to_operation(NoneVar).create(self) # type: ignore
+
+ # Handle fixed_output_type being Base or a dataclass.
+ if can_use_in_object_var(fixed_output_type):
+ return self.to(ObjectVar, output)
+
+ if inspect.isclass(output):
+ for var_subclass in _var_subclasses[::-1]:
+ if issubclass(output, var_subclass.var_subclass):
+ current_var_type = self._var_type
+ if current_var_type is Any:
+ new_var_type = var_type
+ else:
+ new_var_type = var_type or current_var_type
+ to_operation_return = var_subclass.to_var_subclass.create(
+ value=self, _var_type=new_var_type
+ )
+ return to_operation_return # type: ignore
+
+ # If we can't determine the first argument, we just replace the _var_type.
+ if not issubclass(output, Var) or var_type is None:
+ return dataclasses.replace(
+ self,
+ _var_type=output,
+ )
+
+ # We couldn't determine the output type to be any other Var type, so we replace the _var_type.
+ if var_type is not None:
+ return dataclasses.replace(
+ self,
+ _var_type=var_type,
+ )
+
+ return self
+
+ @overload
+ def guess_type(self: Var[str]) -> StringVar: ...
+
+ @overload
+ def guess_type(self: Var[bool]) -> BooleanVar: ...
+
+ @overload
+ def guess_type(self: Var[int] | Var[float] | Var[int | float]) -> NumberVar: ...
+
+ @overload
+ def guess_type(self) -> Self: ...
+
+ def guess_type(self) -> Var:
+ """Guesses the type of the variable based on its `_var_type` attribute.
+
+ Returns:
+ Var: The guessed type of the variable.
+
+ Raises:
+ TypeError: If the type is not supported for guessing.
+ """
+ from .number import NumberVar
+ from .object import ObjectVar
+
+ var_type = self._var_type
+ if var_type is None:
+ return self.to(None)
+ if types.is_optional(var_type):
+ var_type = types.get_args(var_type)[0]
+
+ if var_type is Any:
+ return self
+
+ fixed_type = get_origin(var_type) or var_type
+
+ if fixed_type in types.UnionTypes:
+ inner_types = get_args(var_type)
+
+ if all(
+ inspect.isclass(t) and issubclass(t, (int, float)) for t in inner_types
+ ):
+ return self.to(NumberVar, self._var_type)
+
+ if can_use_in_object_var(var_type):
+ return self.to(ObjectVar, self._var_type)
+
+ return self
+
+ if fixed_type is Literal:
+ args = get_args(var_type)
+ fixed_type = unionize(*(type(arg) for arg in args))
+
+ if not inspect.isclass(fixed_type):
+ raise TypeError(f"Unsupported type {var_type} for guess_type.")
+
+ if fixed_type is None:
+ return self.to(None)
+
+ for var_subclass in _var_subclasses[::-1]:
+ if issubclass(fixed_type, var_subclass.python_types):
+ return self.to(var_subclass.var_subclass, self._var_type)
+
+ if can_use_in_object_var(fixed_type):
+ return self.to(ObjectVar, self._var_type)
+
+ return self
+
+ def _get_default_value(self) -> Any:
+ """Get the default value of the var.
+
+ Returns:
+ The default value of the var.
+
+ Raises:
+ ImportError: If the var is a dataframe and pandas is not installed.
+ """
+ if types.is_optional(self._var_type):
+ return None
+
+ type_ = (
+ get_origin(self._var_type)
+ if types.is_generic_alias(self._var_type)
+ else self._var_type
+ )
+ if type_ is Literal:
+ args = get_args(self._var_type)
+ return args[0] if args else None
+ if issubclass(type_, str):
+ return ""
+ if issubclass(type_, types.get_args(Union[int, float])):
+ return 0
+ if issubclass(type_, bool):
+ return False
+ if issubclass(type_, list):
+ return []
+ if issubclass(type_, dict):
+ return {}
+ if issubclass(type_, tuple):
+ return ()
+ if types.is_dataframe(type_):
+ try:
+ import pandas as pd
+
+ return pd.DataFrame()
+ except ImportError as e:
+ raise ImportError(
+ "Please install pandas to use dataframes in your app."
+ ) from e
+ return set() if issubclass(type_, set) else None
+
+ def _get_setter_name(self, include_state: bool = True) -> str:
+ """Get the name of the var's generated setter function.
+
+ Args:
+ include_state: Whether to include the state name in the setter name.
+
+ Returns:
+ The name of the setter function.
+ """
+ setter = constants.SETTER_PREFIX + self._var_field_name
+ var_data = self._get_all_var_data()
+ if var_data is None:
+ return setter
+ if not include_state or var_data.state == "":
+ return setter
+ return ".".join((var_data.state, setter))
+
+ def _get_setter(self) -> Callable[[BaseState, Any], None]:
+ """Get the var's setter function.
+
+ Returns:
+ A function that that creates a setter for the var.
+ """
+ actual_name = self._var_field_name
+
+ def setter(state: BaseState, value: Any):
+ """Get the setter for the var.
+
+ Args:
+ state: The state within which we add the setter function.
+ value: The value to set.
+ """
+ if self._var_type in [int, float]:
+ try:
+ value = self._var_type(value)
+ setattr(state, actual_name, value)
+ except ValueError:
+ console.debug(
+ f"{type(state).__name__}.{self._js_expr}: Failed conversion of {value} to '{self._var_type.__name__}'. Value not set.",
+ )
+ else:
+ setattr(state, actual_name, value)
+
+ setter.__qualname__ = self._get_setter_name()
+
+ return setter
+
+ def _var_set_state(self, state: type[BaseState] | str):
+ """Set the state of the var.
+
+ Args:
+ state: The state to set.
+
+ Returns:
+ The var with the state set.
+ """
+ formatted_state_name = (
+ state
+ if isinstance(state, str)
+ else format_state_name(state.get_full_name())
+ )
+
+ return StateOperation.create(
+ formatted_state_name,
+ self,
+ _var_data=VarData.merge(
+ VarData.from_state(state, self._js_expr), self._var_data
+ ),
+ ).guess_type()
+
+ def __eq__(self, other: Var | Any) -> BooleanVar:
+ """Check if the current variable is equal to the given variable.
+
+ Args:
+ other (Var | Any): The variable to compare with.
+
+ Returns:
+ BooleanVar: A BooleanVar object representing the result of the equality check.
+ """
+ from .number import equal_operation
+
+ return equal_operation(self, other)
+
+ def __ne__(self, other: Var | Any) -> BooleanVar:
+ """Check if the current object is not equal to the given object.
+
+ Parameters:
+ other (Var | Any): The object to compare with.
+
+ Returns:
+ BooleanVar: A BooleanVar object representing the result of the comparison.
+ """
+ from .number import equal_operation
+
+ return ~equal_operation(self, other)
+
+ def bool(self) -> BooleanVar:
+ """Convert the var to a boolean.
+
+ Returns:
+ The boolean var.
+ """
+ from .number import boolify
+
+ return boolify(self)
+
+ def __and__(self, other: Var | Any) -> Var:
+ """Perform a logical AND operation on the current instance and another variable.
+
+ Args:
+ other: The variable to perform the logical AND operation with.
+
+ Returns:
+ A `BooleanVar` object representing the result of the logical AND operation.
+ """
+ return and_operation(self, other)
+
+ def __rand__(self, other: Var | Any) -> Var:
+ """Perform a logical AND operation on the current instance and another variable.
+
+ Args:
+ other: The variable to perform the logical AND operation with.
+
+ Returns:
+ A `BooleanVar` object representing the result of the logical AND operation.
+ """
+ return and_operation(other, self)
+
+ def __or__(self, other: Var | Any) -> Var:
+ """Perform a logical OR operation on the current instance and another variable.
+
+ Args:
+ other: The variable to perform the logical OR operation with.
+
+ Returns:
+ A `BooleanVar` object representing the result of the logical OR operation.
+ """
+ return or_operation(self, other)
+
+ def __ror__(self, other: Var | Any) -> Var:
+ """Perform a logical OR operation on the current instance and another variable.
+
+ Args:
+ other: The variable to perform the logical OR operation with.
+
+ Returns:
+ A `BooleanVar` object representing the result of the logical OR operation.
+ """
+ return or_operation(other, self)
+
+ def __invert__(self) -> BooleanVar:
+ """Perform a logical NOT operation on the current instance.
+
+ Returns:
+ A `BooleanVar` object representing the result of the logical NOT operation.
+ """
+ return ~self.bool()
+
+ def to_string(self, use_json: bool = True) -> StringVar:
+ """Convert the var to a string.
+
+ Args:
+ use_json: Whether to use JSON stringify. If False, uses Object.prototype.toString.
+
+ Returns:
+ The string var.
+ """
+ from .function import JSON_STRINGIFY, PROTOTYPE_TO_STRING
+ from .sequence import StringVar
+
+ return (
+ JSON_STRINGIFY.call(self).to(StringVar)
+ if use_json
+ else PROTOTYPE_TO_STRING.call(self).to(StringVar)
+ )
+
+ def _as_ref(self) -> Var:
+ """Get a reference to the var.
+
+ Returns:
+ The reference to the var.
+ """
+ from .object import ObjectVar
+
+ refs = Var(
+ _js_expr="refs",
+ _var_data=VarData(
+ imports={
+ f"$/{constants.Dirs.STATE_PATH}": [imports.ImportVar(tag="refs")]
+ }
+ ),
+ ).to(ObjectVar, Dict[str, str])
+ return refs[LiteralVar.create(str(self))]
+
+ @deprecated("Use `.js_type()` instead.")
+ def _type(self) -> StringVar:
+ """Returns the type of the object.
+
+ This method uses the `typeof` function from the `FunctionStringVar` class
+ to determine the type of the object.
+
+ Returns:
+ StringVar: A string variable representing the type of the object.
+ """
+ return self.js_type()
+
+ def js_type(self) -> StringVar:
+ """Returns the javascript type of the object.
+
+ This method uses the `typeof` function from the `FunctionStringVar` class
+ to determine the type of the object.
+
+ Returns:
+ StringVar: A string variable representing the type of the object.
+ """
+ from .function import FunctionStringVar
+ from .sequence import StringVar
+
+ type_of = FunctionStringVar("typeof")
+ return type_of.call(self).to(StringVar)
+
+ def _without_data(self):
+ """Create a copy of the var without the data.
+
+ Returns:
+ The var without the data.
+ """
+ return dataclasses.replace(self, _var_data=None)
+
+ def __get__(self, instance: Any, owner: Any):
+ """Get the var.
+
+ Args:
+ instance: The instance to get the var from.
+ owner: The owner of the var.
+
+ Returns:
+ The var.
+ """
+ return self
+
+ def __getattr__(self, name: str):
+ """Get an attribute of the var.
+
+ Args:
+ name: The name of the attribute.
+
+ Returns:
+ The attribute.
+
+ Raises:
+ VarAttributeError: If the attribute does not exist.
+ TypeError: If the var type is Any.
+ """
+ if name.startswith("_"):
+ return self.__getattribute__(name)
+
+ if name == "contains":
+ raise TypeError(
+ f"Var of type {self._var_type} does not support contains check."
+ )
+ if name == "reverse":
+ raise TypeError("Cannot reverse non-list var.")
+
+ if self._var_type is Any:
+ raise TypeError(
+ f"You must provide an annotation for the state var `{self!s}`. Annotation cannot be `{self._var_type}`."
+ )
+
+ if name in REPLACED_NAMES:
+ raise VarAttributeError(
+ f"Field {name!r} was renamed to {REPLACED_NAMES[name]!r}"
+ )
+
+ raise VarAttributeError(
+ f"The State var has no attribute '{name}' or may have been annotated wrongly.",
+ )
+
+ def _decode(self) -> Any:
+ """Decode Var as a python value.
+
+ Note that Var with state set cannot be decoded python-side and will be
+ returned as full_name.
+
+ Returns:
+ The decoded value or the Var name.
+ """
+ if isinstance(self, LiteralVar):
+ return self._var_value # type: ignore
+ try:
+ return json.loads(str(self))
+ except ValueError:
+ return str(self)
+
+ @property
+ def _var_state(self) -> str:
+ """Compat method for getting the state.
+
+ Returns:
+ The state name associated with the var.
+ """
+ var_data = self._get_all_var_data()
+ return var_data.state if var_data else ""
+
+ @overload
+ @classmethod
+ def range(cls, stop: int | NumberVar, /) -> ArrayVar[List[int]]: ...
+
+ @overload
+ @classmethod
+ def range(
+ cls,
+ start: int | NumberVar,
+ end: int | NumberVar,
+ step: int | NumberVar = 1,
+ /,
+ ) -> ArrayVar[List[int]]: ...
+
+ @classmethod
+ def range(
+ cls,
+ first_endpoint: int | NumberVar,
+ second_endpoint: int | NumberVar | None = None,
+ step: int | NumberVar | None = None,
+ ) -> ArrayVar[List[int]]:
+ """Create a range of numbers.
+
+ Args:
+ first_endpoint: The end of the range if second_endpoint is not provided, otherwise the start of the range.
+ second_endpoint: The end of the range.
+ step: The step of the range.
+
+ Returns:
+ The range of numbers.
+ """
+ from .sequence import ArrayVar
+
+ return ArrayVar.range(first_endpoint, second_endpoint, step)
+
+ def __bool__(self) -> bool:
+ """Raise exception if using Var in a boolean context.
+
+ Raises:
+ VarTypeError: when attempting to bool-ify the Var.
+ """
+ raise VarTypeError(
+ f"Cannot convert Var {str(self)!r} to bool for use with `if`, `and`, `or`, and `not`. "
+ "Instead use `rx.cond` and bitwise operators `&` (and), `|` (or), `~` (invert)."
+ )
+
+ def __iter__(self) -> Any:
+ """Raise exception if using Var in an iterable context.
+
+ Raises:
+ VarTypeError: when attempting to iterate over the Var.
+ """
+ raise VarTypeError(
+ f"Cannot iterate over Var {str(self)!r}. Instead use `rx.foreach`."
+ )
+
+ def __contains__(self, _: Any) -> Var:
+ """Override the 'in' operator to alert the user that it is not supported.
+
+ Raises:
+ VarTypeError: the operation is not supported
+ """
+ raise VarTypeError(
+ "'in' operator not supported for Var types, use Var.contains() instead."
+ )
+
+
+OUTPUT = TypeVar("OUTPUT", bound=Var)
+
+VAR_SUBCLASS = TypeVar("VAR_SUBCLASS", bound=Var)
+VAR_INSIDE = TypeVar("VAR_INSIDE")
+
+
+class ToOperation:
+ """A var operation that converts a var to another type."""
+
+ def __getattr__(self, name: str) -> Any:
+ """Get an attribute of the var.
+
+ Args:
+ name: The name of the attribute.
+
+ Returns:
+ The attribute of the var.
+ """
+ from .object import ObjectVar
+
+ if isinstance(self, ObjectVar) and name != "_js_expr":
+ return ObjectVar.__getattr__(self, name)
+ return getattr(self._original, name)
+
+ def __post_init__(self):
+ """Post initialization."""
+ object.__delattr__(self, "_js_expr")
+
+ def __hash__(self) -> int:
+ """Calculate the hash value of the object.
+
+ Returns:
+ int: The hash value of the object.
+ """
+ return hash(self._original)
+
+ def _get_all_var_data(self) -> VarData | None:
+ """Get all the var data.
+
+ Returns:
+ The var data.
+ """
+ return VarData.merge(
+ self._original._get_all_var_data(),
+ self._var_data, # type: ignore
+ )
+
+ @classmethod
+ def create(
+ cls,
+ value: Var,
+ _var_type: GenericType | None = None,
+ _var_data: VarData | None = None,
+ ):
+ """Create a ToOperation.
+
+ Args:
+ value: The value of the var.
+ _var_type: The type of the Var.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The ToOperation.
+ """
+ return cls(
+ _js_expr="", # type: ignore
+ _var_data=_var_data, # type: ignore
+ _var_type=_var_type or cls._default_var_type, # type: ignore
+ _original=value, # type: ignore
+ )
+
+
+class LiteralVar(Var):
+ """Base class for immutable literal vars."""
+
+ def __init_subclass__(cls, **kwargs):
+ """Initialize the subclass.
+
+ Args:
+ **kwargs: Additional keyword arguments.
+
+ Raises:
+ TypeError: If the LiteralVar subclass does not have a corresponding Var subclass.
+ """
+ super().__init_subclass__(**kwargs)
+
+ bases = cls.__bases__
+
+ bases_normalized = [
+ base if inspect.isclass(base) else get_origin(base) for base in bases
+ ]
+
+ possible_bases = [
+ base
+ for base in bases_normalized
+ if issubclass(base, Var) and base != LiteralVar
+ ]
+
+ if not possible_bases:
+ raise TypeError(
+ f"LiteralVar subclass {cls} must have a base class that is a subclass of Var and not LiteralVar."
+ )
+
+ var_subclasses = [
+ var_subclass
+ for var_subclass in _var_subclasses
+ if var_subclass.var_subclass in possible_bases
+ ]
+
+ if not var_subclasses:
+ raise TypeError(
+ f"LiteralVar {cls} must have a base class annotated with `python_types`."
+ )
+
+ if len(var_subclasses) != 1:
+ raise TypeError(
+ f"LiteralVar {cls} must have exactly one base class annotated with `python_types`."
+ )
+
+ var_subclass = var_subclasses[0]
+
+ # Remove the old subclass, happens because __init_subclass__ is called twice
+ # for each subclass. This is because of __slots__ in dataclasses.
+ for var_literal_subclass in list(_var_literal_subclasses):
+ if var_literal_subclass[1] is var_subclass:
+ _var_literal_subclasses.remove(var_literal_subclass)
+
+ _var_literal_subclasses.append((cls, var_subclass))
+
+ @classmethod
+ def create(
+ cls,
+ value: Any,
+ _var_data: VarData | None = None,
+ ) -> Var:
+ """Create a var from a value.
+
+ Args:
+ value: The value to create the var from.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The var.
+
+ Raises:
+ TypeError: If the value is not a supported type for LiteralVar.
+ """
+ from .object import LiteralObjectVar
+ from .sequence import LiteralStringVar
+
+ if isinstance(value, Var):
+ if _var_data is None:
+ return value
+ return value._replace(merge_var_data=_var_data)
+
+ for literal_subclass, var_subclass in _var_literal_subclasses[::-1]:
+ if isinstance(value, var_subclass.python_types):
+ return literal_subclass.create(value, _var_data=_var_data)
+
+ from reflex.event import EventHandler
+ from reflex.utils.format import get_event_handler_parts
+
+ if isinstance(value, EventHandler):
+ return Var(_js_expr=".".join(filter(None, get_event_handler_parts(value))))
+
+ serialized_value = serializers.serialize(value)
+ if serialized_value is not None:
+ if isinstance(serialized_value, dict):
+ return LiteralObjectVar.create(
+ serialized_value,
+ _var_type=type(value),
+ _var_data=_var_data,
+ )
+ if isinstance(serialized_value, str):
+ return LiteralStringVar.create(
+ serialized_value, _var_type=type(value), _var_data=_var_data
+ )
+ return LiteralVar.create(serialized_value, _var_data=_var_data)
+
+ if isinstance(value, Base):
+ # get the fields of the pydantic class
+ fields = value.__fields__.keys()
+ one_level_dict = {field: getattr(value, field) for field in fields}
+
+ return LiteralObjectVar.create(
+ {
+ field: value
+ for field, value in one_level_dict.items()
+ if not callable(value)
+ },
+ _var_type=type(value),
+ _var_data=_var_data,
+ )
+
+ if dataclasses.is_dataclass(value) and not isinstance(value, type):
+ return LiteralObjectVar.create(
+ {
+ k: (None if callable(v) else v)
+ for k, v in dataclasses.asdict(value).items()
+ },
+ _var_type=type(value),
+ _var_data=_var_data,
+ )
+
+ raise TypeError(
+ f"Unsupported type {type(value)} for LiteralVar. Tried to create a LiteralVar from {value}."
+ )
+
+ def __post_init__(self):
+ """Post-initialize the var."""
+
+ def json(self) -> str:
+ """Serialize the var to a JSON string.
+
+ Raises:
+ NotImplementedError: If the method is not implemented.
+ """
+ raise NotImplementedError(
+ "LiteralVar subclasses must implement the json method."
+ )
+
+
+@serializers.serializer
+def serialize_literal(value: LiteralVar):
+ """Serialize a Literal type.
+
+ Args:
+ value: The Literal to serialize.
+
+ Returns:
+ The serialized Literal.
+ """
+ return value._var_value
+
+
+def get_python_literal(value: Union[LiteralVar, Any]) -> Any | None:
+ """Get the Python literal value.
+
+ Args:
+ value: The value to get the Python literal value of.
+
+ Returns:
+ The Python literal value.
+ """
+ if isinstance(value, LiteralVar):
+ return value._var_value
+ if isinstance(value, Var):
+ return None
+ return value
+
+
+P = ParamSpec("P")
+T = TypeVar("T")
+
+
+# NoReturn is used to match CustomVarOperationReturn with no type hint.
+@overload
+def var_operation(
+ func: Callable[P, CustomVarOperationReturn[NoReturn]],
+) -> Callable[P, Var]: ...
+
+
+@overload
+def var_operation(
+ func: Callable[P, CustomVarOperationReturn[bool]],
+) -> Callable[P, BooleanVar]: ...
+
+
+NUMBER_T = TypeVar("NUMBER_T", int, float, Union[int, float])
+
+
+@overload
+def var_operation(
+ func: Callable[P, CustomVarOperationReturn[NUMBER_T]],
+) -> Callable[P, NumberVar[NUMBER_T]]: ...
+
+
+@overload
+def var_operation(
+ func: Callable[P, CustomVarOperationReturn[str]],
+) -> Callable[P, StringVar]: ...
+
+
+LIST_T = TypeVar("LIST_T", bound=Union[List[Any], Tuple, Set])
+
+
+@overload
+def var_operation(
+ func: Callable[P, CustomVarOperationReturn[LIST_T]],
+) -> Callable[P, ArrayVar[LIST_T]]: ...
+
+
+OBJECT_TYPE = TypeVar("OBJECT_TYPE", bound=Dict)
+
+
+@overload
+def var_operation(
+ func: Callable[P, CustomVarOperationReturn[OBJECT_TYPE]],
+) -> Callable[P, ObjectVar[OBJECT_TYPE]]: ...
+
+
+@overload
+def var_operation(
+ func: Callable[P, CustomVarOperationReturn[T]],
+) -> Callable[P, Var[T]]: ...
+
+
+def var_operation(
+ func: Callable[P, CustomVarOperationReturn[T]],
+) -> Callable[P, Var[T]]:
+ """Decorator for creating a var operation.
+
+ Example:
+ ```python
+ @var_operation
+ def add(a: NumberVar, b: NumberVar):
+ return custom_var_operation(f"{a} + {b}")
+ ```
+
+ Args:
+ func: The function to decorate.
+
+ Returns:
+ The decorated function.
+ """
+
+ @functools.wraps(func)
+ def wrapper(*args: P.args, **kwargs: P.kwargs) -> Var[T]:
+ func_args = list(inspect.signature(func).parameters)
+ args_vars = {
+ func_args[i]: (LiteralVar.create(arg) if not isinstance(arg, Var) else arg)
+ for i, arg in enumerate(args)
+ }
+ kwargs_vars = {
+ key: LiteralVar.create(value) if not isinstance(value, Var) else value
+ for key, value in kwargs.items()
+ }
+
+ return CustomVarOperation.create(
+ name=func.__name__,
+ args=tuple(list(args_vars.items()) + list(kwargs_vars.items())),
+ return_var=func(*args_vars.values(), **kwargs_vars), # type: ignore
+ ).guess_type()
+
+ return wrapper
+
+
+def figure_out_type(value: Any) -> types.GenericType:
+ """Figure out the type of the value.
+
+ Args:
+ value: The value to figure out the type of.
+
+ Returns:
+ The type of the value.
+ """
+ if isinstance(value, Var):
+ return value._var_type
+ type_ = type(value)
+ if has_args(type_):
+ return type_
+ if isinstance(value, list):
+ return List[unionize(*(figure_out_type(v) for v in value))]
+ if isinstance(value, set):
+ return Set[unionize(*(figure_out_type(v) for v in value))]
+ if isinstance(value, tuple):
+ return Tuple[unionize(*(figure_out_type(v) for v in value)), ...]
+ if isinstance(value, dict):
+ return Dict[
+ unionize(*(figure_out_type(k) for k in value)),
+ unionize(*(figure_out_type(v) for v in value.values())),
+ ]
+ return type(value)
+
+
+class cached_property_no_lock(functools.cached_property):
+ """A special version of functools.cached_property that does not use a lock."""
+
+ def __init__(self, func):
+ """Initialize the cached_property_no_lock.
+
+ Args:
+ func: The function to cache.
+ """
+ super().__init__(func)
+ self.lock = contextlib.nullcontext()
+
+
+class CachedVarOperation:
+ """Base class for cached var operations to lower boilerplate code."""
+
+ def __post_init__(self):
+ """Post-initialize the CachedVarOperation."""
+ object.__delattr__(self, "_js_expr")
+
+ def __getattr__(self, name: str) -> Any:
+ """Get an attribute of the var.
+
+ Args:
+ name: The name of the attribute.
+
+ Returns:
+ The attribute.
+ """
+ if name == "_js_expr":
+ return self._cached_var_name
+
+ parent_classes = inspect.getmro(type(self))
+
+ next_class = parent_classes[parent_classes.index(CachedVarOperation) + 1]
+
+ return next_class.__getattr__(self, name) # type: ignore
+
+ def _get_all_var_data(self) -> VarData | None:
+ """Get all VarData associated with the Var.
+
+ Returns:
+ The VarData of the components and all of its children.
+ """
+ return self._cached_get_all_var_data
+
+ @cached_property_no_lock
+ def _cached_get_all_var_data(self) -> VarData | None:
+ """Get the cached VarData.
+
+ Returns:
+ The cached VarData.
+ """
+ return VarData.merge(
+ *(
+ value._get_all_var_data() if isinstance(value, Var) else None
+ for value in (
+ getattr(self, field.name)
+ for field in dataclasses.fields(self) # type: ignore
+ )
+ ),
+ self._var_data,
+ )
+
+ def __hash__(self) -> int:
+ """Calculate the hash of the object.
+
+ Returns:
+ The hash of the object.
+ """
+ return hash(
+ (
+ type(self).__name__,
+ *[
+ getattr(self, field.name)
+ for field in dataclasses.fields(self) # type: ignore
+ if field.name not in ["_js_expr", "_var_data", "_var_type"]
+ ],
+ )
+ )
+
+
+def and_operation(a: Var | Any, b: Var | Any) -> Var:
+ """Perform a logical AND operation on two variables.
+
+ Args:
+ a: The first variable.
+ b: The second variable.
+
+ Returns:
+ The result of the logical AND operation.
+ """
+ return _and_operation(a, b) # type: ignore
+
+
+@var_operation
+def _and_operation(a: Var, b: Var):
+ """Perform a logical AND operation on two variables.
+
+ Args:
+ a: The first variable.
+ b: The second variable.
+
+ Returns:
+ The result of the logical AND operation.
+ """
+ return var_operation_return(
+ js_expression=f"({a} && {b})",
+ var_type=unionize(a._var_type, b._var_type),
+ )
+
+
+def or_operation(a: Var | Any, b: Var | Any) -> Var:
+ """Perform a logical OR operation on two variables.
+
+ Args:
+ a: The first variable.
+ b: The second variable.
+
+ Returns:
+ The result of the logical OR operation.
+ """
+ return _or_operation(a, b) # type: ignore
+
+
+@var_operation
+def _or_operation(a: Var, b: Var):
+ """Perform a logical OR operation on two variables.
+
+ Args:
+ a: The first variable.
+ b: The second variable.
+
+ Returns:
+ The result of the logical OR operation.
+ """
+ return var_operation_return(
+ js_expression=f"({a} || {b})",
+ var_type=unionize(a._var_type, b._var_type),
+ )
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class CallableVar(Var):
+ """Decorate a Var-returning function to act as both a Var and a function.
+
+ This is used as a compatibility shim for replacing Var objects in the
+ API with functions that return a family of Var.
+ """
+
+ fn: Callable[..., Var] = dataclasses.field(
+ default_factory=lambda: lambda: Var(_js_expr="undefined")
+ )
+ original_var: Var = dataclasses.field(
+ default_factory=lambda: Var(_js_expr="undefined")
+ )
+
+ def __init__(self, fn: Callable[..., Var]):
+ """Initialize a CallableVar.
+
+ Args:
+ fn: The function to decorate (must return Var)
+ """
+ original_var = fn()
+ super(CallableVar, self).__init__(
+ _js_expr=original_var._js_expr,
+ _var_type=original_var._var_type,
+ _var_data=VarData.merge(original_var._get_all_var_data()),
+ )
+ object.__setattr__(self, "fn", fn)
+ object.__setattr__(self, "original_var", original_var)
+
+ def __call__(self, *args, **kwargs) -> Var:
+ """Call the decorated function.
+
+ Args:
+ *args: The args to pass to the function.
+ **kwargs: The kwargs to pass to the function.
+
+ Returns:
+ The Var returned from calling the function.
+ """
+ return self.fn(*args, **kwargs)
+
+ def __hash__(self) -> int:
+ """Calculate the hash of the object.
+
+ Returns:
+ The hash of the object.
+ """
+ return hash((type(self).__name__, self.original_var))
+
+
+RETURN_TYPE = TypeVar("RETURN_TYPE")
+
+DICT_KEY = TypeVar("DICT_KEY")
+DICT_VAL = TypeVar("DICT_VAL")
+
+LIST_INSIDE = TypeVar("LIST_INSIDE")
+
+
+class FakeComputedVarBaseClass(property):
+ """A fake base class for ComputedVar to avoid inheriting from property."""
+
+ __pydantic_run_validation__ = False
+
+
+def is_computed_var(obj: Any) -> TypeGuard[ComputedVar]:
+ """Check if the object is a ComputedVar.
+
+ Args:
+ obj: The object to check.
+
+ Returns:
+ Whether the object is a ComputedVar.
+ """
+ return isinstance(obj, FakeComputedVarBaseClass)
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class ComputedVar(Var[RETURN_TYPE]):
+ """A field with computed getters."""
+
+ # Whether to track dependencies and cache computed values
+ _cache: bool = dataclasses.field(default=False)
+
+ # Whether the computed var is a backend var
+ _backend: bool = dataclasses.field(default=False)
+
+ # The initial value of the computed var
+ _initial_value: RETURN_TYPE | types.Unset = dataclasses.field(default=types.Unset())
+
+ # Explicit var dependencies to track
+ _static_deps: set[str] = dataclasses.field(default_factory=set)
+
+ # Whether var dependencies should be auto-determined
+ _auto_deps: bool = dataclasses.field(default=True)
+
+ # Interval at which the computed var should be updated
+ _update_interval: Optional[datetime.timedelta] = dataclasses.field(default=None)
+
+ _fget: Callable[[BaseState], RETURN_TYPE] = dataclasses.field(
+ default_factory=lambda: lambda _: None
+ ) # type: ignore
+
+ def __init__(
+ self,
+ fget: Callable[[BASE_STATE], RETURN_TYPE],
+ initial_value: RETURN_TYPE | types.Unset = types.Unset(),
+ cache: bool = False,
+ deps: Optional[List[Union[str, Var]]] = None,
+ auto_deps: bool = True,
+ interval: Optional[Union[int, datetime.timedelta]] = None,
+ backend: bool | None = None,
+ **kwargs,
+ ):
+ """Initialize a ComputedVar.
+
+ Args:
+ fget: The getter function.
+ initial_value: The initial value of the computed var.
+ cache: Whether to cache the computed value.
+ deps: Explicit var dependencies to track.
+ auto_deps: Whether var dependencies should be auto-determined.
+ interval: Interval at which the computed var should be updated.
+ backend: Whether the computed var is a backend var.
+ **kwargs: additional attributes to set on the instance
+
+ Raises:
+ TypeError: If the computed var dependencies are not Var instances or var names.
+ """
+ hint = kwargs.pop("return_type", None) or get_type_hints(fget).get(
+ "return", Any
+ )
+
+ if hint is Any:
+ console.deprecate(
+ "untyped-computed-var",
+ "ComputedVar should have a return type annotation.",
+ "0.6.5",
+ "0.7.0",
+ )
+
+ kwargs.setdefault("_js_expr", fget.__name__)
+ kwargs.setdefault("_var_type", hint)
+
+ Var.__init__(
+ self,
+ _js_expr=kwargs.pop("_js_expr"),
+ _var_type=kwargs.pop("_var_type"),
+ _var_data=kwargs.pop("_var_data", None),
+ )
+
+ if kwargs:
+ raise TypeError(f"Unexpected keyword arguments: {tuple(kwargs)}")
+
+ if backend is None:
+ backend = fget.__name__.startswith("_")
+
+ object.__setattr__(self, "_backend", backend)
+ object.__setattr__(self, "_initial_value", initial_value)
+ object.__setattr__(self, "_cache", cache)
+
+ if isinstance(interval, int):
+ interval = datetime.timedelta(seconds=interval)
+
+ object.__setattr__(self, "_update_interval", interval)
+
+ if deps is None:
+ deps = []
+ else:
+ for dep in deps:
+ if isinstance(dep, Var):
+ continue
+ if isinstance(dep, str) and dep != "":
+ continue
+ raise TypeError(
+ "ComputedVar dependencies must be Var instances or var names (non-empty strings)."
+ )
+ object.__setattr__(
+ self,
+ "_static_deps",
+ {dep._js_expr if isinstance(dep, Var) else dep for dep in deps},
+ )
+ object.__setattr__(self, "_auto_deps", auto_deps)
+
+ object.__setattr__(self, "_fget", fget)
+
+ @override
+ def _replace(self, merge_var_data=None, **kwargs: Any) -> Self:
+ """Replace the attributes of the ComputedVar.
+
+ Args:
+ merge_var_data: VarData to merge into the existing VarData.
+ **kwargs: Var fields to update.
+
+ Returns:
+ The new ComputedVar instance.
+
+ Raises:
+ TypeError: If kwargs contains keys that are not allowed.
+ """
+ field_values = {
+ "fget": kwargs.pop("fget", self._fget),
+ "initial_value": kwargs.pop("initial_value", self._initial_value),
+ "cache": kwargs.pop("cache", self._cache),
+ "deps": kwargs.pop("deps", self._static_deps),
+ "auto_deps": kwargs.pop("auto_deps", self._auto_deps),
+ "interval": kwargs.pop("interval", self._update_interval),
+ "backend": kwargs.pop("backend", self._backend),
+ "_js_expr": kwargs.pop("_js_expr", self._js_expr),
+ "_var_type": kwargs.pop("_var_type", self._var_type),
+ "_var_data": kwargs.pop(
+ "_var_data", VarData.merge(self._var_data, merge_var_data)
+ ),
+ }
+
+ if kwargs:
+ unexpected_kwargs = ", ".join(kwargs.keys())
+ raise TypeError(f"Unexpected keyword arguments: {unexpected_kwargs}")
+
+ return type(self)(**field_values)
+
+ @property
+ def _cache_attr(self) -> str:
+ """Get the attribute used to cache the value on the instance.
+
+ Returns:
+ An attribute name.
+ """
+ return f"__cached_{self._js_expr}"
+
+ @property
+ def _last_updated_attr(self) -> str:
+ """Get the attribute used to store the last updated timestamp.
+
+ Returns:
+ An attribute name.
+ """
+ return f"__last_updated_{self._js_expr}"
+
+ def needs_update(self, instance: BaseState) -> bool:
+ """Check if the computed var needs to be updated.
+
+ Args:
+ instance: The state instance that the computed var is attached to.
+
+ Returns:
+ True if the computed var needs to be updated, False otherwise.
+ """
+ if self._update_interval is None:
+ return False
+ last_updated = getattr(instance, self._last_updated_attr, None)
+ if last_updated is None:
+ return True
+ return datetime.datetime.now() - last_updated > self._update_interval
+
+ @overload
+ def __get__(
+ self: ComputedVar[int] | ComputedVar[float],
+ instance: None,
+ owner: Type,
+ ) -> NumberVar: ...
+
+ @overload
+ def __get__(
+ self: ComputedVar[str],
+ instance: None,
+ owner: Type,
+ ) -> StringVar: ...
+
+ @overload
+ def __get__(
+ self: ComputedVar[dict[DICT_KEY, DICT_VAL]],
+ instance: None,
+ owner: Type,
+ ) -> ObjectVar[dict[DICT_KEY, DICT_VAL]]: ...
+
+ @overload
+ def __get__(
+ self: ComputedVar[list[LIST_INSIDE]],
+ instance: None,
+ owner: Type,
+ ) -> ArrayVar[list[LIST_INSIDE]]: ...
+
+ @overload
+ def __get__(
+ self: ComputedVar[set[LIST_INSIDE]],
+ instance: None,
+ owner: Type,
+ ) -> ArrayVar[set[LIST_INSIDE]]: ...
+
+ @overload
+ def __get__(
+ self: ComputedVar[tuple[LIST_INSIDE, ...]],
+ instance: None,
+ owner: Type,
+ ) -> ArrayVar[tuple[LIST_INSIDE, ...]]: ...
+
+ @overload
+ def __get__(self, instance: None, owner: Type) -> ComputedVar[RETURN_TYPE]: ...
+
+ @overload
+ def __get__(self, instance: BaseState, owner: Type) -> RETURN_TYPE: ...
+
+ def __get__(self, instance: BaseState | None, owner):
+ """Get the ComputedVar value.
+
+ If the value is already cached on the instance, return the cached value.
+
+ Args:
+ instance: the instance of the class accessing this computed var.
+ owner: the class that this descriptor is attached to.
+
+ Returns:
+ The value of the var for the given instance.
+ """
+ if instance is None:
+ state_where_defined = owner
+ while self._js_expr in state_where_defined.inherited_vars:
+ state_where_defined = state_where_defined.get_parent_state()
+
+ field_name = (
+ format_state_name(state_where_defined.get_full_name())
+ + "."
+ + self._js_expr
+ )
+
+ return dispatch(
+ field_name,
+ var_data=VarData.from_state(state_where_defined, self._js_expr),
+ result_var_type=self._var_type,
+ existing_var=self,
+ )
+
+ if not self._cache:
+ value = self.fget(instance)
+ else:
+ # handle caching
+ if not hasattr(instance, self._cache_attr) or self.needs_update(instance):
+ # Set cache attr on state instance.
+ setattr(instance, self._cache_attr, self.fget(instance))
+ # Ensure the computed var gets serialized to redis.
+ instance._was_touched = True
+ # Set the last updated timestamp on the state instance.
+ setattr(instance, self._last_updated_attr, datetime.datetime.now())
+ value = getattr(instance, self._cache_attr)
+
+ if not _isinstance(value, self._var_type):
+ console.deprecate(
+ "mismatched-computed-var-return",
+ f"Computed var {type(instance).__name__}.{self._js_expr} returned value of type {type(value)}, "
+ f"expected {self._var_type}. This might cause unexpected behavior.",
+ "0.6.5",
+ "0.7.0",
+ )
+
+ return value
+
+ def _deps(
+ self,
+ objclass: Type,
+ obj: FunctionType | CodeType | None = None,
+ self_name: Optional[str] = None,
+ ) -> set[str]:
+ """Determine var dependencies of this ComputedVar.
+
+ Save references to attributes accessed on "self". Recursively called
+ when the function makes a method call on "self" or define comprehensions
+ or nested functions that may reference "self".
+
+ Args:
+ objclass: the class obj this ComputedVar is attached to.
+ obj: the object to disassemble (defaults to the fget function).
+ self_name: if specified, look for this name in LOAD_FAST and LOAD_DEREF instructions.
+
+ Returns:
+ A set of variable names accessed by the given obj.
+
+ Raises:
+ VarValueError: if the function references the get_state, parent_state, or substates attributes
+ (cannot track deps in a related state, only implicitly via parent state).
+ """
+ if not self._auto_deps:
+ return self._static_deps
+ d = self._static_deps.copy()
+ if obj is None:
+ fget = self._fget
+ if fget is not None:
+ obj = cast(FunctionType, fget)
+ else:
+ return set()
+ with contextlib.suppress(AttributeError):
+ # unbox functools.partial
+ obj = cast(FunctionType, obj.func) # type: ignore
+ with contextlib.suppress(AttributeError):
+ # unbox EventHandler
+ obj = cast(FunctionType, obj.fn) # type: ignore
+
+ if self_name is None and isinstance(obj, FunctionType):
+ try:
+ # the first argument to the function is the name of "self" arg
+ self_name = obj.__code__.co_varnames[0]
+ except (AttributeError, IndexError):
+ self_name = None
+ if self_name is None:
+ # cannot reference attributes on self if method takes no args
+ return set()
+
+ invalid_names = ["get_state", "parent_state", "substates", "get_substate"]
+ self_is_top_of_stack = False
+ for instruction in dis.get_instructions(obj):
+ if (
+ instruction.opname in ("LOAD_FAST", "LOAD_DEREF")
+ and instruction.argval == self_name
+ ):
+ # bytecode loaded the class instance to the top of stack, next load instruction
+ # is referencing an attribute on self
+ self_is_top_of_stack = True
+ continue
+ if self_is_top_of_stack and instruction.opname in (
+ "LOAD_ATTR",
+ "LOAD_METHOD",
+ ):
+ try:
+ ref_obj = getattr(objclass, instruction.argval)
+ except Exception:
+ ref_obj = None
+ if instruction.argval in invalid_names:
+ raise VarValueError(
+ f"Cached var {self!s} cannot access arbitrary state via `{instruction.argval}`."
+ )
+ if callable(ref_obj):
+ # recurse into callable attributes
+ d.update(
+ self._deps(
+ objclass=objclass,
+ obj=ref_obj,
+ )
+ )
+ # recurse into property fget functions
+ elif isinstance(ref_obj, property) and not isinstance(
+ ref_obj, ComputedVar
+ ):
+ d.update(
+ self._deps(
+ objclass=objclass,
+ obj=ref_obj.fget, # type: ignore
+ )
+ )
+ elif (
+ instruction.argval in objclass.backend_vars
+ or instruction.argval in objclass.vars
+ ):
+ # var access
+ d.add(instruction.argval)
+ elif instruction.opname == "LOAD_CONST" and isinstance(
+ instruction.argval, CodeType
+ ):
+ # recurse into nested functions / comprehensions, which can reference
+ # instance attributes from the outer scope
+ d.update(
+ self._deps(
+ objclass=objclass,
+ obj=instruction.argval,
+ self_name=self_name,
+ )
+ )
+ self_is_top_of_stack = False
+ return d
+
+ def mark_dirty(self, instance) -> None:
+ """Mark this ComputedVar as dirty.
+
+ Args:
+ instance: the state instance that needs to recompute the value.
+ """
+ with contextlib.suppress(AttributeError):
+ delattr(instance, self._cache_attr)
+
+ def _determine_var_type(self) -> Type:
+ """Get the type of the var.
+
+ Returns:
+ The type of the var.
+ """
+ hints = get_type_hints(self._fget)
+ if "return" in hints:
+ return hints["return"]
+ return Any
+
+ @property
+ def __class__(self) -> Type:
+ """Get the class of the var.
+
+ Returns:
+ The class of the var.
+ """
+ return FakeComputedVarBaseClass
+
+ @property
+ def fget(self) -> Callable[[BaseState], RETURN_TYPE]:
+ """Get the getter function.
+
+ Returns:
+ The getter function.
+ """
+ return self._fget
+
+
+class DynamicRouteVar(ComputedVar[Union[str, List[str]]]):
+ """A ComputedVar that represents a dynamic route."""
+
+ pass
+
+
+if TYPE_CHECKING:
+ BASE_STATE = TypeVar("BASE_STATE", bound=BaseState)
+
+
+@overload
+def computed_var(
+ fget: None = None,
+ initial_value: Any | types.Unset = types.Unset(),
+ cache: bool = False,
+ deps: Optional[List[Union[str, Var]]] = None,
+ auto_deps: bool = True,
+ interval: Optional[Union[datetime.timedelta, int]] = None,
+ backend: bool | None = None,
+ **kwargs,
+) -> Callable[[Callable[[BASE_STATE], RETURN_TYPE]], ComputedVar[RETURN_TYPE]]: ...
+
+
+@overload
+def computed_var(
+ fget: Callable[[BASE_STATE], RETURN_TYPE],
+ initial_value: RETURN_TYPE | types.Unset = types.Unset(),
+ cache: bool = False,
+ deps: Optional[List[Union[str, Var]]] = None,
+ auto_deps: bool = True,
+ interval: Optional[Union[datetime.timedelta, int]] = None,
+ backend: bool | None = None,
+ **kwargs,
+) -> ComputedVar[RETURN_TYPE]: ...
+
+
+def computed_var(
+ fget: Callable[[BASE_STATE], Any] | None = None,
+ initial_value: Any | types.Unset = types.Unset(),
+ cache: bool = False,
+ deps: Optional[List[Union[str, Var]]] = None,
+ auto_deps: bool = True,
+ interval: Optional[Union[datetime.timedelta, int]] = None,
+ backend: bool | None = None,
+ **kwargs,
+) -> ComputedVar | Callable[[Callable[[BASE_STATE], Any]], ComputedVar]:
+ """A ComputedVar decorator with or without kwargs.
+
+ Args:
+ fget: The getter function.
+ initial_value: The initial value of the computed var.
+ cache: Whether to cache the computed value.
+ deps: Explicit var dependencies to track.
+ auto_deps: Whether var dependencies should be auto-determined.
+ interval: Interval at which the computed var should be updated.
+ backend: Whether the computed var is a backend var.
+ **kwargs: additional attributes to set on the instance
+
+ Returns:
+ A ComputedVar instance.
+
+ Raises:
+ ValueError: If caching is disabled and an update interval is set.
+ VarDependencyError: If user supplies dependencies without caching.
+ """
+ if cache is False and interval is not None:
+ raise ValueError("Cannot set update interval without caching.")
+
+ if cache is False and (deps is not None or auto_deps is False):
+ raise VarDependencyError("Cannot track dependencies without caching.")
+
+ if fget is not None:
+ return ComputedVar(fget, cache=cache)
+
+ def wrapper(fget: Callable[[BASE_STATE], Any]) -> ComputedVar:
+ return ComputedVar(
+ fget,
+ initial_value=initial_value,
+ cache=cache,
+ deps=deps,
+ auto_deps=auto_deps,
+ interval=interval,
+ backend=backend,
+ **kwargs,
+ )
+
+ return wrapper
+
+
+RETURN = TypeVar("RETURN")
+
+
+class CustomVarOperationReturn(Var[RETURN]):
+ """Base class for custom var operations."""
+
+ @classmethod
+ def create(
+ cls,
+ js_expression: str,
+ _var_type: Type[RETURN] | None = None,
+ _var_data: VarData | None = None,
+ ) -> CustomVarOperationReturn[RETURN]:
+ """Create a CustomVarOperation.
+
+ Args:
+ js_expression: The JavaScript expression to evaluate.
+ _var_type: The type of the var.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The CustomVarOperation.
+ """
+ return CustomVarOperationReturn(
+ _js_expr=js_expression,
+ _var_type=_var_type or Any,
+ _var_data=_var_data,
+ )
+
+
+def var_operation_return(
+ js_expression: str,
+ var_type: Type[RETURN] | None = None,
+ var_data: VarData | None = None,
+) -> CustomVarOperationReturn[RETURN]:
+ """Shortcut for creating a CustomVarOperationReturn.
+
+ Args:
+ js_expression: The JavaScript expression to evaluate.
+ var_type: The type of the var.
+ var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The CustomVarOperationReturn.
+ """
+ return CustomVarOperationReturn.create(
+ js_expression,
+ var_type,
+ var_data,
+ )
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class CustomVarOperation(CachedVarOperation, Var[T]):
+ """Base class for custom var operations."""
+
+ _name: str = dataclasses.field(default="")
+
+ _args: Tuple[Tuple[str, Var], ...] = dataclasses.field(default_factory=tuple)
+
+ _return: CustomVarOperationReturn[T] = dataclasses.field(
+ default_factory=lambda: CustomVarOperationReturn.create("")
+ )
+
+ @cached_property_no_lock
+ def _cached_var_name(self) -> str:
+ """Get the cached var name.
+
+ Returns:
+ The cached var name.
+ """
+ return str(self._return)
+
+ @cached_property_no_lock
+ def _cached_get_all_var_data(self) -> VarData | None:
+ """Get the cached VarData.
+
+ Returns:
+ The cached VarData.
+ """
+ return VarData.merge(
+ *(arg[1]._get_all_var_data() for arg in self._args),
+ self._return._get_all_var_data(),
+ self._var_data,
+ )
+
+ @classmethod
+ def create(
+ cls,
+ name: str,
+ args: Tuple[Tuple[str, Var], ...],
+ return_var: CustomVarOperationReturn[T],
+ _var_data: VarData | None = None,
+ ) -> CustomVarOperation[T]:
+ """Create a CustomVarOperation.
+
+ Args:
+ name: The name of the operation.
+ args: The arguments to the operation.
+ return_var: The return var.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The CustomVarOperation.
+ """
+ return CustomVarOperation(
+ _js_expr="",
+ _var_type=return_var._var_type,
+ _var_data=_var_data,
+ _name=name,
+ _args=args,
+ _return=return_var,
+ )
+
+
+class NoneVar(Var[None], python_types=type(None)):
+ """A var representing None."""
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class LiteralNoneVar(LiteralVar, NoneVar):
+ """A var representing None."""
+
+ _var_value: None = None
+
+ def json(self) -> str:
+ """Serialize the var to a JSON string.
+
+ Returns:
+ The JSON string.
+ """
+ return "null"
+
+ @classmethod
+ def create(
+ cls,
+ value: None = None,
+ _var_data: VarData | None = None,
+ ) -> LiteralNoneVar:
+ """Create a var from a value.
+
+ Args:
+ value: The value of the var. Must be None. Existed for compatibility with LiteralVar.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The var.
+ """
+ return LiteralNoneVar(
+ _js_expr="null",
+ _var_type=None,
+ _var_data=_var_data,
+ )
+
+
+def get_to_operation(var_subclass: Type[Var]) -> Type[ToOperation]:
+ """Get the ToOperation class for a given Var subclass.
+
+ Args:
+ var_subclass: The Var subclass.
+
+ Returns:
+ The ToOperation class.
+
+ Raises:
+ ValueError: If the ToOperation class cannot be found.
+ """
+ possible_classes = [
+ saved_var_subclass.to_var_subclass
+ for saved_var_subclass in _var_subclasses
+ if saved_var_subclass.var_subclass is var_subclass
+ ]
+ if not possible_classes:
+ raise ValueError(f"Could not find ToOperation for {var_subclass}.")
+ return possible_classes[0]
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class StateOperation(CachedVarOperation, Var):
+ """A var operation that accesses a field on an object."""
+
+ _state_name: str = dataclasses.field(default="")
+ _field: Var = dataclasses.field(default_factory=lambda: LiteralNoneVar.create())
+
+ @cached_property_no_lock
+ def _cached_var_name(self) -> str:
+ """Get the cached var name.
+
+ Returns:
+ The cached var name.
+ """
+ return f"{self._state_name!s}.{self._field!s}"
+
+ def __getattr__(self, name: str) -> Any:
+ """Get an attribute of the var.
+
+ Args:
+ name: The name of the attribute.
+
+ Returns:
+ The attribute.
+ """
+ if name == "_js_expr":
+ return self._cached_var_name
+
+ return getattr(self._field, name)
+
+ @classmethod
+ def create(
+ cls,
+ state_name: str,
+ field: Var,
+ _var_data: VarData | None = None,
+ ) -> StateOperation:
+ """Create a DotOperation.
+
+ Args:
+ state_name: The name of the state.
+ field: The field of the state.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The DotOperation.
+ """
+ return StateOperation(
+ _js_expr="",
+ _var_type=field._var_type,
+ _var_data=_var_data,
+ _state_name=state_name,
+ _field=field,
+ )
+
+
+def get_uuid_string_var() -> Var:
+ """Return a Var that generates a single memoized UUID via .web/utils/state.js.
+
+ useMemo with an empty dependency array ensures that the generated UUID is
+ consistent across re-renders of the component.
+
+ Returns:
+ A Var that generates a UUID at runtime.
+ """
+ from reflex.utils.imports import ImportVar
+ from reflex.vars import Var
+
+ unique_uuid_var = get_unique_variable_name()
+ unique_uuid_var_data = VarData(
+ imports={
+ f"$/{constants.Dirs.STATE_PATH}": {ImportVar(tag="generateUUID")}, # type: ignore
+ "react": "useMemo",
+ },
+ hooks={f"const {unique_uuid_var} = useMemo(generateUUID, [])": None},
+ )
+
+ return Var(
+ _js_expr=unique_uuid_var,
+ _var_type=str,
+ _var_data=unique_uuid_var_data,
+ )
+
+
+# Set of unique variable names.
+USED_VARIABLES = set()
+
+
+def get_unique_variable_name() -> str:
+ """Get a unique variable name.
+
+ Returns:
+ The unique variable name.
+ """
+ name = "".join([random.choice(string.ascii_lowercase) for _ in range(8)])
+ if name not in USED_VARIABLES:
+ USED_VARIABLES.add(name)
+ return name
+ return get_unique_variable_name()
+
+
+# Compile regex for finding reflex var tags.
+_decode_var_pattern_re = (
+ rf"{constants.REFLEX_VAR_OPENING_TAG}(.*?){constants.REFLEX_VAR_CLOSING_TAG}"
+)
+_decode_var_pattern = re.compile(_decode_var_pattern_re, flags=re.DOTALL)
+
+# Defined global immutable vars.
+_global_vars: Dict[int, Var] = {}
+
+
+def _extract_var_data(value: Iterable) -> list[VarData | None]:
+ """Extract the var imports and hooks from an iterable containing a Var.
+
+ Args:
+ value: The iterable to extract the VarData from
+
+ Returns:
+ The extracted VarDatas.
+ """
+ from reflex.style import Style
+ from reflex.vars import Var
+
+ var_datas = []
+ with contextlib.suppress(TypeError):
+ for sub in value:
+ if isinstance(sub, Var):
+ var_datas.append(sub._var_data)
+ elif not isinstance(sub, str):
+ # Recurse into dict values.
+ if hasattr(sub, "values") and callable(sub.values):
+ var_datas.extend(_extract_var_data(sub.values()))
+ # Recurse into iterable values (or dict keys).
+ var_datas.extend(_extract_var_data(sub))
+
+ # Style objects should already have _var_data.
+ if isinstance(value, Style):
+ var_datas.append(value._var_data)
+ else:
+ # Recurse when value is a dict itself.
+ values = getattr(value, "values", None)
+ if callable(values):
+ var_datas.extend(_extract_var_data(values()))
+ return var_datas
+
+
+# These names were changed in reflex 0.3.0
+REPLACED_NAMES = {
+ "full_name": "_var_full_name",
+ "name": "_js_expr",
+ "state": "_var_data.state",
+ "type_": "_var_type",
+ "is_local": "_var_is_local",
+ "is_string": "_var_is_string",
+ "set_state": "_var_set_state",
+ "deps": "_deps",
+}
+
+
+dispatchers: Dict[GenericType, Callable[[Var], Var]] = {}
+
+
+def transform(fn: Callable[[Var], Var]) -> Callable[[Var], Var]:
+ """Register a function to transform a Var.
+
+ Args:
+ fn: The function to register.
+
+ Returns:
+ The decorator.
+
+ Raises:
+ TypeError: If the return type of the function is not a Var.
+ TypeError: If the Var return type does not have a generic type.
+ ValueError: If a function for the generic type is already registered.
+ """
+ return_type = fn.__annotations__["return"]
+
+ origin = get_origin(return_type)
+
+ if origin is not Var:
+ raise TypeError(
+ f"Expected return type of {fn.__name__} to be a Var, got {origin}."
+ )
+
+ generic_args = get_args(return_type)
+
+ if not generic_args:
+ raise TypeError(
+ f"Expected Var return type of {fn.__name__} to have a generic type."
+ )
+
+ generic_type = get_origin(generic_args[0]) or generic_args[0]
+
+ if generic_type in dispatchers:
+ raise ValueError(f"Function for {generic_type} already registered.")
+
+ dispatchers[generic_type] = fn
+
+ return fn
+
+
+def generic_type_to_actual_type_map(
+ generic_type: GenericType, actual_type: GenericType
+) -> Dict[TypeVar, GenericType]:
+ """Map the generic type to the actual type.
+
+ Args:
+ generic_type: The generic type.
+ actual_type: The actual type.
+
+ Returns:
+ The mapping of type variables to actual types.
+
+ Raises:
+ TypeError: If the generic type and actual type do not match.
+ TypeError: If the number of generic arguments and actual arguments do not match.
+ """
+ generic_origin = get_origin(generic_type) or generic_type
+ actual_origin = get_origin(actual_type) or actual_type
+
+ if generic_origin is not actual_origin:
+ if isinstance(generic_origin, TypeVar):
+ return {generic_origin: actual_origin}
+ raise TypeError(
+ f"Type mismatch: expected {generic_origin}, got {actual_origin}."
+ )
+
+ generic_args = get_args(generic_type)
+ actual_args = get_args(actual_type)
+
+ if len(generic_args) != len(actual_args):
+ raise TypeError(
+ f"Number of generic arguments mismatch: expected {len(generic_args)}, got {len(actual_args)}."
+ )
+
+ # call recursively for nested generic types and merge the results
+ return {
+ k: v
+ for generic_arg, actual_arg in zip(generic_args, actual_args)
+ for k, v in generic_type_to_actual_type_map(generic_arg, actual_arg).items()
+ }
+
+
+def resolve_generic_type_with_mapping(
+ generic_type: GenericType, type_mapping: Dict[TypeVar, GenericType]
+):
+ """Resolve a generic type with a type mapping.
+
+ Args:
+ generic_type: The generic type.
+ type_mapping: The type mapping.
+
+ Returns:
+ The resolved generic type.
+ """
+ if isinstance(generic_type, TypeVar):
+ return type_mapping.get(generic_type, generic_type)
+
+ generic_origin = get_origin(generic_type) or generic_type
+
+ generic_args = get_args(generic_type)
+
+ if not generic_args:
+ return generic_type
+
+ mapping_for_older_python = {
+ list: List,
+ set: Set,
+ dict: Dict,
+ tuple: Tuple,
+ frozenset: FrozenSet,
+ }
+
+ return mapping_for_older_python.get(generic_origin, generic_origin)[
+ tuple(
+ resolve_generic_type_with_mapping(arg, type_mapping) for arg in generic_args
+ )
+ ]
+
+
+def resolve_arg_type_from_return_type(
+ arg_type: GenericType, return_type: GenericType, actual_return_type: GenericType
+) -> GenericType:
+ """Resolve the argument type from the return type.
+
+ Args:
+ arg_type: The argument type.
+ return_type: The return type.
+ actual_return_type: The requested return type.
+
+ Returns:
+ The argument type without the generics that are resolved.
+ """
+ return resolve_generic_type_with_mapping(
+ arg_type, generic_type_to_actual_type_map(return_type, actual_return_type)
+ )
+
+
+def dispatch(
+ field_name: str,
+ var_data: VarData,
+ result_var_type: GenericType,
+ existing_var: Var | None = None,
+) -> Var:
+ """Dispatch a Var to the appropriate transformation function.
+
+ Args:
+ field_name: The name of the field.
+ var_data: The VarData associated with the Var.
+ result_var_type: The type of the Var.
+ existing_var: The existing Var to transform. Optional.
+
+ Returns:
+ The transformed Var.
+
+ Raises:
+ TypeError: If the return type of the function is not a Var.
+ TypeError: If the Var return type does not have a generic type.
+ TypeError: If the first argument of the function is not a Var.
+ TypeError: If the first argument of the function does not have a generic type
+ """
+ result_origin_var_type = get_origin(result_var_type) or result_var_type
+
+ if result_origin_var_type in dispatchers:
+ fn = dispatchers[result_origin_var_type]
+ fn_first_arg_type = next(
+ iter(inspect.signature(fn).parameters.values())
+ ).annotation
+
+ fn_return = inspect.signature(fn).return_annotation
+
+ fn_return_origin = get_origin(fn_return) or fn_return
+
+ if fn_return_origin is not Var:
+ raise TypeError(
+ f"Expected return type of {fn.__name__} to be a Var, got {fn_return}."
+ )
+
+ fn_return_generic_args = get_args(fn_return)
+
+ if not fn_return_generic_args:
+ raise TypeError(f"Expected generic type of {fn_return} to be a type.")
+
+ arg_origin = get_origin(fn_first_arg_type) or fn_first_arg_type
+
+ if arg_origin is not Var:
+ raise TypeError(
+ f"Expected first argument of {fn.__name__} to be a Var, got {fn_first_arg_type}."
+ )
+
+ arg_generic_args = get_args(fn_first_arg_type)
+
+ if not arg_generic_args:
+ raise TypeError(
+ f"Expected generic type of {fn_first_arg_type} to be a type."
+ )
+
+ arg_type = arg_generic_args[0]
+ fn_return_type = fn_return_generic_args[0]
+
+ var = (
+ Var(
+ field_name,
+ _var_data=var_data,
+ _var_type=resolve_arg_type_from_return_type(
+ arg_type, fn_return_type, result_var_type
+ ),
+ ).guess_type()
+ if existing_var is None
+ else existing_var._replace(
+ _var_type=resolve_arg_type_from_return_type(
+ arg_type, fn_return_type, result_var_type
+ ),
+ _var_data=var_data,
+ _js_expr=field_name,
+ ).guess_type()
+ )
+
+ return fn(var)
+
+ if existing_var is not None:
+ return existing_var._replace(
+ _js_expr=field_name,
+ _var_data=var_data,
+ _var_type=result_var_type,
+ ).guess_type()
+ return Var(
+ field_name,
+ _var_data=var_data,
+ _var_type=result_var_type,
+ ).guess_type()
+
+
+V = TypeVar("V")
+
+BASE_TYPE = TypeVar("BASE_TYPE", bound=Base)
+
+
+class Field(Generic[T]):
+ """Shadow class for Var to allow for type hinting in the IDE."""
+
+ def __set__(self, instance, value: T):
+ """Set the Var.
+
+ Args:
+ instance: The instance of the class setting the Var.
+ value: The value to set the Var to.
+ """
+
+ @overload
+ def __get__(self: Field[bool], instance: None, owner) -> BooleanVar: ...
+
+ @overload
+ def __get__(self: Field[int], instance: None, owner) -> NumberVar: ...
+
+ @overload
+ def __get__(self: Field[str], instance: None, owner) -> StringVar: ...
+
+ @overload
+ def __get__(self: Field[None], instance: None, owner) -> NoneVar: ...
+
+ @overload
+ def __get__(
+ self: Field[List[V]] | Field[Set[V]] | Field[Tuple[V, ...]],
+ instance: None,
+ owner,
+ ) -> ArrayVar[List[V]]: ...
+
+ @overload
+ def __get__(
+ self: Field[Dict[str, V]], instance: None, owner
+ ) -> ObjectVar[Dict[str, V]]: ...
+
+ @overload
+ def __get__(
+ self: Field[BASE_TYPE], instance: None, owner
+ ) -> ObjectVar[BASE_TYPE]: ...
+
+ @overload
+ def __get__(self, instance: None, owner) -> Var[T]: ...
+
+ @overload
+ def __get__(self, instance, owner) -> T: ...
+
+ def __get__(self, instance, owner): # type: ignore
+ """Get the Var.
+
+ Args:
+ instance: The instance of the class accessing the Var.
+ owner: The class that the Var is attached to.
+ """
+
+
+def field(value: T) -> Field[T]:
+ """Create a Field with a value.
+
+ Args:
+ value: The value of the Field.
+
+ Returns:
+ The Field.
+ """
+ return value # type: ignore
diff --git a/reflex/vars/datetime.py b/reflex/vars/datetime.py
new file mode 100644
index 000000000..b6f4c24c6
--- /dev/null
+++ b/reflex/vars/datetime.py
@@ -0,0 +1,222 @@
+"""Immutable datetime and date vars."""
+
+from __future__ import annotations
+
+import dataclasses
+import sys
+from datetime import date, datetime
+from typing import Any, NoReturn, TypeVar, Union, overload
+
+from reflex.utils.exceptions import VarTypeError
+from reflex.vars.number import BooleanVar
+
+from .base import (
+ CustomVarOperationReturn,
+ LiteralVar,
+ Var,
+ VarData,
+ var_operation,
+ var_operation_return,
+)
+
+DATETIME_T = TypeVar("DATETIME_T", datetime, date)
+
+datetime_types = Union[datetime, date]
+
+
+def raise_var_type_error():
+ """Raise a VarTypeError.
+
+ Raises:
+ VarTypeError: Cannot compare a datetime object with a non-datetime object.
+ """
+ raise VarTypeError("Cannot compare a datetime object with a non-datetime object.")
+
+
+class DateTimeVar(Var[DATETIME_T], python_types=(datetime, date)):
+ """A variable that holds a datetime or date object."""
+
+ @overload
+ def __lt__(self, other: datetime_types) -> BooleanVar: ...
+
+ @overload
+ def __lt__(self, other: NoReturn) -> NoReturn: ...
+
+ def __lt__(self, other: Any):
+ """Less than comparison.
+
+ Args:
+ other: The other datetime to compare.
+
+ Returns:
+ The result of the comparison.
+ """
+ if not isinstance(other, DATETIME_TYPES):
+ raise_var_type_error()
+ return date_lt_operation(self, other)
+
+ @overload
+ def __le__(self, other: datetime_types) -> BooleanVar: ...
+
+ @overload
+ def __le__(self, other: NoReturn) -> NoReturn: ...
+
+ def __le__(self, other: Any):
+ """Less than or equal comparison.
+
+ Args:
+ other: The other datetime to compare.
+
+ Returns:
+ The result of the comparison.
+ """
+ if not isinstance(other, DATETIME_TYPES):
+ raise_var_type_error()
+ return date_le_operation(self, other)
+
+ @overload
+ def __gt__(self, other: datetime_types) -> BooleanVar: ...
+
+ @overload
+ def __gt__(self, other: NoReturn) -> NoReturn: ...
+
+ def __gt__(self, other: Any):
+ """Greater than comparison.
+
+ Args:
+ other: The other datetime to compare.
+
+ Returns:
+ The result of the comparison.
+ """
+ if not isinstance(other, DATETIME_TYPES):
+ raise_var_type_error()
+ return date_gt_operation(self, other)
+
+ @overload
+ def __ge__(self, other: datetime_types) -> BooleanVar: ...
+
+ @overload
+ def __ge__(self, other: NoReturn) -> NoReturn: ...
+
+ def __ge__(self, other: Any):
+ """Greater than or equal comparison.
+
+ Args:
+ other: The other datetime to compare.
+
+ Returns:
+ The result of the comparison.
+ """
+ if not isinstance(other, DATETIME_TYPES):
+ raise_var_type_error()
+ return date_ge_operation(self, other)
+
+
+@var_operation
+def date_gt_operation(lhs: Var | Any, rhs: Var | Any) -> CustomVarOperationReturn:
+ """Greater than comparison.
+
+ Args:
+ lhs: The left-hand side of the operation.
+ rhs: The right-hand side of the operation.
+
+ Returns:
+ The result of the operation.
+ """
+ return date_compare_operation(rhs, lhs, strict=True)
+
+
+@var_operation
+def date_lt_operation(lhs: Var | Any, rhs: Var | Any) -> CustomVarOperationReturn:
+ """Less than comparison.
+
+ Args:
+ lhs: The left-hand side of the operation.
+ rhs: The right-hand side of the operation.
+
+ Returns:
+ The result of the operation.
+ """
+ return date_compare_operation(lhs, rhs, strict=True)
+
+
+@var_operation
+def date_le_operation(lhs: Var | Any, rhs: Var | Any) -> CustomVarOperationReturn:
+ """Less than or equal comparison.
+
+ Args:
+ lhs: The left-hand side of the operation.
+ rhs: The right-hand side of the operation.
+
+ Returns:
+ The result of the operation.
+ """
+ return date_compare_operation(lhs, rhs)
+
+
+@var_operation
+def date_ge_operation(lhs: Var | Any, rhs: Var | Any) -> CustomVarOperationReturn:
+ """Greater than or equal comparison.
+
+ Args:
+ lhs: The left-hand side of the operation.
+ rhs: The right-hand side of the operation.
+
+ Returns:
+ The result of the operation.
+ """
+ return date_compare_operation(rhs, lhs)
+
+
+def date_compare_operation(
+ lhs: DateTimeVar[DATETIME_T] | Any,
+ rhs: DateTimeVar[DATETIME_T] | Any,
+ strict: bool = False,
+) -> CustomVarOperationReturn:
+ """Check if the value is less than the other value.
+
+ Args:
+ lhs: The left-hand side of the operation.
+ rhs: The right-hand side of the operation.
+ strict: Whether to use strict comparison.
+
+ Returns:
+ The result of the operation.
+ """
+ return var_operation_return(
+ f"({lhs} { '<' if strict else '<='} {rhs})",
+ bool,
+ )
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class LiteralDatetimeVar(LiteralVar, DateTimeVar):
+ """Base class for immutable datetime and date vars."""
+
+ _var_value: datetime | date = dataclasses.field(default=datetime.now())
+
+ @classmethod
+ def create(cls, value: datetime | date, _var_data: VarData | None = None):
+ """Create a new instance of the class.
+
+ Args:
+ value: The value to set.
+
+ Returns:
+ LiteralDatetimeVar: The new instance of the class.
+ """
+ js_expr = f'"{value!s}"'
+ return cls(
+ _js_expr=js_expr,
+ _var_type=type(value),
+ _var_value=value,
+ _var_data=_var_data,
+ )
+
+
+DATETIME_TYPES = (datetime, date, DateTimeVar)
diff --git a/reflex/vars/function.py b/reflex/vars/function.py
new file mode 100644
index 000000000..2a7d50e1b
--- /dev/null
+++ b/reflex/vars/function.py
@@ -0,0 +1,479 @@
+"""Immutable function vars."""
+
+from __future__ import annotations
+
+import dataclasses
+import sys
+from typing import Any, Callable, Optional, Sequence, Tuple, Type, Union, overload
+
+from typing_extensions import Concatenate, Generic, ParamSpec, Protocol, TypeVar
+
+from reflex.utils import format
+from reflex.utils.types import GenericType
+
+from .base import CachedVarOperation, LiteralVar, Var, VarData, cached_property_no_lock
+
+P = ParamSpec("P")
+V1 = TypeVar("V1")
+V2 = TypeVar("V2")
+V3 = TypeVar("V3")
+V4 = TypeVar("V4")
+V5 = TypeVar("V5")
+V6 = TypeVar("V6")
+R = TypeVar("R")
+
+
+class ReflexCallable(Protocol[P, R]):
+ """Protocol for a callable."""
+
+ __call__: Callable[P, R]
+
+
+CALLABLE_TYPE = TypeVar("CALLABLE_TYPE", bound=ReflexCallable, infer_variance=True)
+OTHER_CALLABLE_TYPE = TypeVar(
+ "OTHER_CALLABLE_TYPE", bound=ReflexCallable, infer_variance=True
+)
+
+
+class FunctionVar(Var[CALLABLE_TYPE], default_type=ReflexCallable[Any, Any]):
+ """Base class for immutable function vars."""
+
+ @overload
+ def partial(self) -> FunctionVar[CALLABLE_TYPE]: ...
+
+ @overload
+ def partial(
+ self: FunctionVar[ReflexCallable[Concatenate[V1, P], R]],
+ arg1: Union[V1, Var[V1]],
+ ) -> FunctionVar[ReflexCallable[P, R]]: ...
+
+ @overload
+ def partial(
+ self: FunctionVar[ReflexCallable[Concatenate[V1, V2, P], R]],
+ arg1: Union[V1, Var[V1]],
+ arg2: Union[V2, Var[V2]],
+ ) -> FunctionVar[ReflexCallable[P, R]]: ...
+
+ @overload
+ def partial(
+ self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, P], R]],
+ arg1: Union[V1, Var[V1]],
+ arg2: Union[V2, Var[V2]],
+ arg3: Union[V3, Var[V3]],
+ ) -> FunctionVar[ReflexCallable[P, R]]: ...
+
+ @overload
+ def partial(
+ self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, V4, P], R]],
+ arg1: Union[V1, Var[V1]],
+ arg2: Union[V2, Var[V2]],
+ arg3: Union[V3, Var[V3]],
+ arg4: Union[V4, Var[V4]],
+ ) -> FunctionVar[ReflexCallable[P, R]]: ...
+
+ @overload
+ def partial(
+ self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, V4, V5, P], R]],
+ arg1: Union[V1, Var[V1]],
+ arg2: Union[V2, Var[V2]],
+ arg3: Union[V3, Var[V3]],
+ arg4: Union[V4, Var[V4]],
+ arg5: Union[V5, Var[V5]],
+ ) -> FunctionVar[ReflexCallable[P, R]]: ...
+
+ @overload
+ def partial(
+ self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, V4, V5, V6, P], R]],
+ arg1: Union[V1, Var[V1]],
+ arg2: Union[V2, Var[V2]],
+ arg3: Union[V3, Var[V3]],
+ arg4: Union[V4, Var[V4]],
+ arg5: Union[V5, Var[V5]],
+ arg6: Union[V6, Var[V6]],
+ ) -> FunctionVar[ReflexCallable[P, R]]: ...
+
+ @overload
+ def partial(
+ self: FunctionVar[ReflexCallable[P, R]], *args: Var | Any
+ ) -> FunctionVar[ReflexCallable[P, R]]: ...
+
+ @overload
+ def partial(self, *args: Var | Any) -> FunctionVar: ...
+
+ def partial(self, *args: Var | Any) -> FunctionVar: # type: ignore
+ """Partially apply the function with the given arguments.
+
+ Args:
+ *args: The arguments to partially apply the function with.
+
+ Returns:
+ The partially applied function.
+ """
+ if not args:
+ return ArgsFunctionOperation.create((), self)
+ return ArgsFunctionOperation.create(
+ ("...args",),
+ VarOperationCall.create(self, *args, Var(_js_expr="...args")),
+ )
+
+ @overload
+ def call(
+ self: FunctionVar[ReflexCallable[[V1], R]], arg1: Union[V1, Var[V1]]
+ ) -> VarOperationCall[[V1], R]: ...
+
+ @overload
+ def call(
+ self: FunctionVar[ReflexCallable[[V1, V2], R]],
+ arg1: Union[V1, Var[V1]],
+ arg2: Union[V2, Var[V2]],
+ ) -> VarOperationCall[[V1, V2], R]: ...
+
+ @overload
+ def call(
+ self: FunctionVar[ReflexCallable[[V1, V2, V3], R]],
+ arg1: Union[V1, Var[V1]],
+ arg2: Union[V2, Var[V2]],
+ arg3: Union[V3, Var[V3]],
+ ) -> VarOperationCall[[V1, V2, V3], R]: ...
+
+ @overload
+ def call(
+ self: FunctionVar[ReflexCallable[[V1, V2, V3, V4], R]],
+ arg1: Union[V1, Var[V1]],
+ arg2: Union[V2, Var[V2]],
+ arg3: Union[V3, Var[V3]],
+ arg4: Union[V4, Var[V4]],
+ ) -> VarOperationCall[[V1, V2, V3, V4], R]: ...
+
+ @overload
+ def call(
+ self: FunctionVar[ReflexCallable[[V1, V2, V3, V4, V5], R]],
+ arg1: Union[V1, Var[V1]],
+ arg2: Union[V2, Var[V2]],
+ arg3: Union[V3, Var[V3]],
+ arg4: Union[V4, Var[V4]],
+ arg5: Union[V5, Var[V5]],
+ ) -> VarOperationCall[[V1, V2, V3, V4, V5], R]: ...
+
+ @overload
+ def call(
+ self: FunctionVar[ReflexCallable[[V1, V2, V3, V4, V5, V6], R]],
+ arg1: Union[V1, Var[V1]],
+ arg2: Union[V2, Var[V2]],
+ arg3: Union[V3, Var[V3]],
+ arg4: Union[V4, Var[V4]],
+ arg5: Union[V5, Var[V5]],
+ arg6: Union[V6, Var[V6]],
+ ) -> VarOperationCall[[V1, V2, V3, V4, V5, V6], R]: ...
+
+ @overload
+ def call(
+ self: FunctionVar[ReflexCallable[P, R]], *args: Var | Any
+ ) -> VarOperationCall[P, R]: ...
+
+ @overload
+ def call(self, *args: Var | Any) -> Var: ...
+
+ def call(self, *args: Var | Any) -> Var: # type: ignore
+ """Call the function with the given arguments.
+
+ Args:
+ *args: The arguments to call the function with.
+
+ Returns:
+ The function call operation.
+ """
+ return VarOperationCall.create(self, *args).guess_type()
+
+ __call__ = call
+
+
+class BuilderFunctionVar(
+ FunctionVar[CALLABLE_TYPE], default_type=ReflexCallable[Any, Any]
+):
+ """Base class for immutable function vars with the builder pattern."""
+
+ __call__ = FunctionVar.partial
+
+
+class FunctionStringVar(FunctionVar[CALLABLE_TYPE]):
+ """Base class for immutable function vars from a string."""
+
+ @classmethod
+ def create(
+ cls,
+ func: str,
+ _var_type: Type[OTHER_CALLABLE_TYPE] = ReflexCallable[Any, Any],
+ _var_data: VarData | None = None,
+ ) -> FunctionStringVar[OTHER_CALLABLE_TYPE]:
+ """Create a new function var from a string.
+
+ Args:
+ func: The function to call.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The function var.
+ """
+ return FunctionStringVar(
+ _js_expr=func,
+ _var_type=_var_type,
+ _var_data=_var_data,
+ )
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class VarOperationCall(Generic[P, R], CachedVarOperation, Var[R]):
+ """Base class for immutable vars that are the result of a function call."""
+
+ _func: Optional[FunctionVar[ReflexCallable[P, R]]] = dataclasses.field(default=None)
+ _args: Tuple[Union[Var, Any], ...] = dataclasses.field(default_factory=tuple)
+
+ @cached_property_no_lock
+ def _cached_var_name(self) -> str:
+ """The name of the var.
+
+ Returns:
+ The name of the var.
+ """
+ return f"({self._func!s}({', '.join([str(LiteralVar.create(arg)) for arg in self._args])}))"
+
+ @cached_property_no_lock
+ def _cached_get_all_var_data(self) -> VarData | None:
+ """Get all the var data associated with the var.
+
+ Returns:
+ All the var data associated with the var.
+ """
+ return VarData.merge(
+ self._func._get_all_var_data() if self._func is not None else None,
+ *[LiteralVar.create(arg)._get_all_var_data() for arg in self._args],
+ self._var_data,
+ )
+
+ @classmethod
+ def create(
+ cls,
+ func: FunctionVar[ReflexCallable[P, R]],
+ *args: Var | Any,
+ _var_type: GenericType = Any,
+ _var_data: VarData | None = None,
+ ) -> VarOperationCall:
+ """Create a new function call var.
+
+ Args:
+ func: The function to call.
+ *args: The arguments to call the function with.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The function call var.
+ """
+ function_return_type = (
+ func._var_type.__args__[1]
+ if getattr(func._var_type, "__args__", None)
+ else Any
+ )
+ var_type = _var_type if _var_type is not Any else function_return_type
+ return cls(
+ _js_expr="",
+ _var_type=var_type,
+ _var_data=_var_data,
+ _func=func,
+ _args=args,
+ )
+
+
+@dataclasses.dataclass(frozen=True)
+class DestructuredArg:
+ """Class for destructured arguments."""
+
+ fields: Tuple[str, ...] = ()
+ rest: Optional[str] = None
+
+ def to_javascript(self) -> str:
+ """Convert the destructured argument to JavaScript.
+
+ Returns:
+ The destructured argument in JavaScript.
+ """
+ return format.wrap(
+ ", ".join(self.fields) + (f", ...{self.rest}" if self.rest else ""),
+ "{",
+ "}",
+ )
+
+
+@dataclasses.dataclass(
+ frozen=True,
+)
+class FunctionArgs:
+ """Class for function arguments."""
+
+ args: Tuple[Union[str, DestructuredArg], ...] = ()
+ rest: Optional[str] = None
+
+
+def format_args_function_operation(
+ args: FunctionArgs, return_expr: Var | Any, explicit_return: bool
+) -> str:
+ """Format an args function operation.
+
+ Args:
+ args: The function arguments.
+ return_expr: The return expression.
+ explicit_return: Whether to use explicit return syntax.
+
+ Returns:
+ The formatted args function operation.
+ """
+ arg_names_str = ", ".join(
+ [arg if isinstance(arg, str) else arg.to_javascript() for arg in args.args]
+ ) + (f", ...{args.rest}" if args.rest else "")
+
+ return_expr_str = str(LiteralVar.create(return_expr))
+
+ # Wrap return expression in curly braces if explicit return syntax is used.
+ return_expr_str_wrapped = (
+ format.wrap(return_expr_str, "{", "}") if explicit_return else return_expr_str
+ )
+
+ return f"(({arg_names_str}) => {return_expr_str_wrapped})"
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class ArgsFunctionOperation(CachedVarOperation, FunctionVar):
+ """Base class for immutable function defined via arguments and return expression."""
+
+ _args: FunctionArgs = dataclasses.field(default_factory=FunctionArgs)
+ _return_expr: Union[Var, Any] = dataclasses.field(default=None)
+ _explicit_return: bool = dataclasses.field(default=False)
+
+ @cached_property_no_lock
+ def _cached_var_name(self) -> str:
+ """The name of the var.
+
+ Returns:
+ The name of the var.
+ """
+ return format_args_function_operation(
+ self._args, self._return_expr, self._explicit_return
+ )
+
+ @classmethod
+ def create(
+ cls,
+ args_names: Sequence[Union[str, DestructuredArg]],
+ return_expr: Var | Any,
+ rest: str | None = None,
+ explicit_return: bool = False,
+ _var_type: GenericType = Callable,
+ _var_data: VarData | None = None,
+ ):
+ """Create a new function var.
+
+ Args:
+ args_names: The names of the arguments.
+ return_expr: The return expression of the function.
+ rest: The name of the rest argument.
+ explicit_return: Whether to use explicit return syntax.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The function var.
+ """
+ return cls(
+ _js_expr="",
+ _var_type=_var_type,
+ _var_data=_var_data,
+ _args=FunctionArgs(args=tuple(args_names), rest=rest),
+ _return_expr=return_expr,
+ _explicit_return=explicit_return,
+ )
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class ArgsFunctionOperationBuilder(CachedVarOperation, BuilderFunctionVar):
+ """Base class for immutable function defined via arguments and return expression with the builder pattern."""
+
+ _args: FunctionArgs = dataclasses.field(default_factory=FunctionArgs)
+ _return_expr: Union[Var, Any] = dataclasses.field(default=None)
+ _explicit_return: bool = dataclasses.field(default=False)
+
+ @cached_property_no_lock
+ def _cached_var_name(self) -> str:
+ """The name of the var.
+
+ Returns:
+ The name of the var.
+ """
+ return format_args_function_operation(
+ self._args, self._return_expr, self._explicit_return
+ )
+
+ @classmethod
+ def create(
+ cls,
+ args_names: Sequence[Union[str, DestructuredArg]],
+ return_expr: Var | Any,
+ rest: str | None = None,
+ explicit_return: bool = False,
+ _var_type: GenericType = Callable,
+ _var_data: VarData | None = None,
+ ):
+ """Create a new function var.
+
+ Args:
+ args_names: The names of the arguments.
+ return_expr: The return expression of the function.
+ rest: The name of the rest argument.
+ explicit_return: Whether to use explicit return syntax.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The function var.
+ """
+ return cls(
+ _js_expr="",
+ _var_type=_var_type,
+ _var_data=_var_data,
+ _args=FunctionArgs(args=tuple(args_names), rest=rest),
+ _return_expr=return_expr,
+ _explicit_return=explicit_return,
+ )
+
+
+if python_version := sys.version_info[:2] >= (3, 10):
+ JSON_STRINGIFY = FunctionStringVar.create(
+ "JSON.stringify", _var_type=ReflexCallable[[Any], str]
+ )
+ ARRAY_ISARRAY = FunctionStringVar.create(
+ "Array.isArray", _var_type=ReflexCallable[[Any], bool]
+ )
+ PROTOTYPE_TO_STRING = FunctionStringVar.create(
+ "((__to_string) => __to_string.toString())",
+ _var_type=ReflexCallable[[Any], str],
+ )
+else:
+ JSON_STRINGIFY = FunctionStringVar.create(
+ "JSON.stringify", _var_type=ReflexCallable[Any, str]
+ )
+ ARRAY_ISARRAY = FunctionStringVar.create(
+ "Array.isArray", _var_type=ReflexCallable[Any, bool]
+ )
+ PROTOTYPE_TO_STRING = FunctionStringVar.create(
+ "((__to_string) => __to_string.toString())",
+ _var_type=ReflexCallable[Any, str],
+ )
diff --git a/reflex/vars/number.py b/reflex/vars/number.py
new file mode 100644
index 000000000..d04aded35
--- /dev/null
+++ b/reflex/vars/number.py
@@ -0,0 +1,1142 @@
+"""Immutable number vars."""
+
+from __future__ import annotations
+
+import dataclasses
+import json
+import math
+import sys
+from typing import (
+ TYPE_CHECKING,
+ Any,
+ Callable,
+ NoReturn,
+ Type,
+ TypeVar,
+ Union,
+ overload,
+)
+
+from reflex.constants.base import Dirs
+from reflex.utils.exceptions import PrimitiveUnserializableToJSON, VarTypeError
+from reflex.utils.imports import ImportDict, ImportVar
+from reflex.utils.types import is_optional
+
+from .base import (
+ CustomVarOperationReturn,
+ LiteralVar,
+ Var,
+ VarData,
+ unionize,
+ var_operation,
+ var_operation_return,
+)
+
+NUMBER_T = TypeVar("NUMBER_T", int, float, Union[int, float], bool)
+
+if TYPE_CHECKING:
+ from .sequence import ArrayVar
+
+
+def raise_unsupported_operand_types(
+ operator: str, operands_types: tuple[type, ...]
+) -> NoReturn:
+ """Raise an unsupported operand types error.
+
+ Args:
+ operator: The operator.
+ operands_types: The types of the operands.
+
+ Raises:
+ VarTypeError: The operand types are unsupported.
+ """
+ raise VarTypeError(
+ f"Unsupported Operand type(s) for {operator}: {', '.join(t.__name__ for t in operands_types)}"
+ )
+
+
+class NumberVar(Var[NUMBER_T], python_types=(int, float)):
+ """Base class for immutable number vars."""
+
+ @overload
+ def __add__(self, other: number_types) -> NumberVar: ...
+
+ @overload
+ def __add__(self, other: NoReturn) -> NoReturn: ...
+
+ def __add__(self, other: Any):
+ """Add two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number addition operation.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("+", (type(self), type(other)))
+ return number_add_operation(self, +other)
+
+ @overload
+ def __radd__(self, other: number_types) -> NumberVar: ...
+
+ @overload
+ def __radd__(self, other: NoReturn) -> NoReturn: ...
+
+ def __radd__(self, other: Any):
+ """Add two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number addition operation.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("+", (type(other), type(self)))
+ return number_add_operation(+other, self)
+
+ @overload
+ def __sub__(self, other: number_types) -> NumberVar: ...
+
+ @overload
+ def __sub__(self, other: NoReturn) -> NoReturn: ...
+
+ def __sub__(self, other: Any):
+ """Subtract two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number subtraction operation.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("-", (type(self), type(other)))
+
+ return number_subtract_operation(self, +other)
+
+ @overload
+ def __rsub__(self, other: number_types) -> NumberVar: ...
+
+ @overload
+ def __rsub__(self, other: NoReturn) -> NoReturn: ...
+
+ def __rsub__(self, other: Any):
+ """Subtract two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number subtraction operation.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("-", (type(other), type(self)))
+
+ return number_subtract_operation(+other, self)
+
+ def __abs__(self):
+ """Get the absolute value of the number.
+
+ Returns:
+ The number absolute operation.
+ """
+ return number_abs_operation(self)
+
+ @overload
+ def __mul__(self, other: number_types | boolean_types) -> NumberVar: ...
+
+ @overload
+ def __mul__(self, other: list | tuple | set | ArrayVar) -> ArrayVar: ...
+
+ def __mul__(self, other: Any):
+ """Multiply two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number multiplication operation.
+ """
+ from .sequence import ArrayVar, LiteralArrayVar
+
+ if isinstance(other, (list, tuple, set, ArrayVar)):
+ if isinstance(other, ArrayVar):
+ return other * self
+ return LiteralArrayVar.create(other) * self
+
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("*", (type(self), type(other)))
+
+ return number_multiply_operation(self, +other)
+
+ @overload
+ def __rmul__(self, other: number_types | boolean_types) -> NumberVar: ...
+
+ @overload
+ def __rmul__(self, other: list | tuple | set | ArrayVar) -> ArrayVar: ...
+
+ def __rmul__(self, other: Any):
+ """Multiply two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number multiplication operation.
+ """
+ from .sequence import ArrayVar, LiteralArrayVar
+
+ if isinstance(other, (list, tuple, set, ArrayVar)):
+ if isinstance(other, ArrayVar):
+ return other * self
+ return LiteralArrayVar.create(other) * self
+
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("*", (type(other), type(self)))
+
+ return number_multiply_operation(+other, self)
+
+ @overload
+ def __truediv__(self, other: number_types) -> NumberVar: ...
+
+ @overload
+ def __truediv__(self, other: NoReturn) -> NoReturn: ...
+
+ def __truediv__(self, other: Any):
+ """Divide two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number true division operation.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("/", (type(self), type(other)))
+
+ return number_true_division_operation(self, +other)
+
+ @overload
+ def __rtruediv__(self, other: number_types) -> NumberVar: ...
+
+ @overload
+ def __rtruediv__(self, other: NoReturn) -> NoReturn: ...
+
+ def __rtruediv__(self, other: Any):
+ """Divide two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number true division operation.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("/", (type(other), type(self)))
+
+ return number_true_division_operation(+other, self)
+
+ @overload
+ def __floordiv__(self, other: number_types) -> NumberVar: ...
+
+ @overload
+ def __floordiv__(self, other: NoReturn) -> NoReturn: ...
+
+ def __floordiv__(self, other: Any):
+ """Floor divide two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number floor division operation.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("//", (type(self), type(other)))
+
+ return number_floor_division_operation(self, +other)
+
+ @overload
+ def __rfloordiv__(self, other: number_types) -> NumberVar: ...
+
+ @overload
+ def __rfloordiv__(self, other: NoReturn) -> NoReturn: ...
+
+ def __rfloordiv__(self, other: Any):
+ """Floor divide two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number floor division operation.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("//", (type(other), type(self)))
+
+ return number_floor_division_operation(+other, self)
+
+ @overload
+ def __mod__(self, other: number_types) -> NumberVar: ...
+
+ @overload
+ def __mod__(self, other: NoReturn) -> NoReturn: ...
+
+ def __mod__(self, other: Any):
+ """Modulo two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number modulo operation.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("%", (type(self), type(other)))
+
+ return number_modulo_operation(self, +other)
+
+ @overload
+ def __rmod__(self, other: number_types) -> NumberVar: ...
+
+ @overload
+ def __rmod__(self, other: NoReturn) -> NoReturn: ...
+
+ def __rmod__(self, other: Any):
+ """Modulo two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number modulo operation.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("%", (type(other), type(self)))
+
+ return number_modulo_operation(+other, self)
+
+ @overload
+ def __pow__(self, other: number_types) -> NumberVar: ...
+
+ @overload
+ def __pow__(self, other: NoReturn) -> NoReturn: ...
+
+ def __pow__(self, other: Any):
+ """Exponentiate two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number exponent operation.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("**", (type(self), type(other)))
+
+ return number_exponent_operation(self, +other)
+
+ @overload
+ def __rpow__(self, other: number_types) -> NumberVar: ...
+
+ @overload
+ def __rpow__(self, other: NoReturn) -> NoReturn: ...
+
+ def __rpow__(self, other: Any):
+ """Exponentiate two numbers.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The number exponent operation.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("**", (type(other), type(self)))
+
+ return number_exponent_operation(+other, self)
+
+ def __neg__(self):
+ """Negate the number.
+
+ Returns:
+ The number negation operation.
+ """
+ return number_negate_operation(self)
+
+ def __invert__(self):
+ """Boolean NOT the number.
+
+ Returns:
+ The boolean NOT operation.
+ """
+ return boolean_not_operation(self.bool())
+
+ def __pos__(self) -> NumberVar:
+ """Positive the number.
+
+ Returns:
+ The number.
+ """
+ return self
+
+ def __round__(self):
+ """Round the number.
+
+ Returns:
+ The number round operation.
+ """
+ return number_round_operation(self)
+
+ def __ceil__(self):
+ """Ceil the number.
+
+ Returns:
+ The number ceil operation.
+ """
+ return number_ceil_operation(self)
+
+ def __floor__(self):
+ """Floor the number.
+
+ Returns:
+ The number floor operation.
+ """
+ return number_floor_operation(self)
+
+ def __trunc__(self):
+ """Trunc the number.
+
+ Returns:
+ The number trunc operation.
+ """
+ return number_trunc_operation(self)
+
+ @overload
+ def __lt__(self, other: number_types) -> BooleanVar: ...
+
+ @overload
+ def __lt__(self, other: NoReturn) -> NoReturn: ...
+
+ def __lt__(self, other: Any):
+ """Less than comparison.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The result of the comparison.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("<", (type(self), type(other)))
+ return less_than_operation(self, +other)
+
+ @overload
+ def __le__(self, other: number_types) -> BooleanVar: ...
+
+ @overload
+ def __le__(self, other: NoReturn) -> NoReturn: ...
+
+ def __le__(self, other: Any):
+ """Less than or equal comparison.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The result of the comparison.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types("<=", (type(self), type(other)))
+ return less_than_or_equal_operation(self, +other)
+
+ def __eq__(self, other: Any):
+ """Equal comparison.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The result of the comparison.
+ """
+ if isinstance(other, NUMBER_TYPES):
+ return equal_operation(self, +other)
+ return equal_operation(self, other)
+
+ def __ne__(self, other: Any):
+ """Not equal comparison.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The result of the comparison.
+ """
+ if isinstance(other, NUMBER_TYPES):
+ return not_equal_operation(self, +other)
+ return not_equal_operation(self, other)
+
+ @overload
+ def __gt__(self, other: number_types) -> BooleanVar: ...
+
+ @overload
+ def __gt__(self, other: NoReturn) -> NoReturn: ...
+
+ def __gt__(self, other: Any):
+ """Greater than comparison.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The result of the comparison.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types(">", (type(self), type(other)))
+ return greater_than_operation(self, +other)
+
+ @overload
+ def __ge__(self, other: number_types) -> BooleanVar: ...
+
+ @overload
+ def __ge__(self, other: NoReturn) -> NoReturn: ...
+
+ def __ge__(self, other: Any):
+ """Greater than or equal comparison.
+
+ Args:
+ other: The other number.
+
+ Returns:
+ The result of the comparison.
+ """
+ if not isinstance(other, NUMBER_TYPES):
+ raise_unsupported_operand_types(">=", (type(self), type(other)))
+ return greater_than_or_equal_operation(self, +other)
+
+ def bool(self):
+ """Boolean conversion.
+
+ Returns:
+ The boolean value of the number.
+ """
+ if is_optional(self._var_type):
+ return boolify((self != None) & (self != 0)) # noqa: E711
+ return self != 0
+
+ def _is_strict_float(self) -> bool:
+ """Check if the number is a float.
+
+ Returns:
+ bool: True if the number is a float.
+ """
+ return issubclass(self._var_type, float)
+
+ def _is_strict_int(self) -> bool:
+ """Check if the number is an int.
+
+ Returns:
+ bool: True if the number is an int.
+ """
+ return issubclass(self._var_type, int)
+
+
+def binary_number_operation(
+ func: Callable[[NumberVar, NumberVar], str],
+) -> Callable[[number_types, number_types], NumberVar]:
+ """Decorator to create a binary number operation.
+
+ Args:
+ func: The binary number operation function.
+
+ Returns:
+ The binary number operation.
+ """
+
+ @var_operation
+ def operation(lhs: NumberVar, rhs: NumberVar):
+ return var_operation_return(
+ js_expression=func(lhs, rhs),
+ var_type=unionize(lhs._var_type, rhs._var_type),
+ )
+
+ def wrapper(lhs: number_types, rhs: number_types) -> NumberVar:
+ """Create the binary number operation.
+
+ Args:
+ lhs: The first number.
+ rhs: The second number.
+
+ Returns:
+ The binary number operation.
+ """
+ return operation(lhs, rhs) # type: ignore
+
+ return wrapper
+
+
+@binary_number_operation
+def number_add_operation(lhs: NumberVar, rhs: NumberVar):
+ """Add two numbers.
+
+ Args:
+ lhs: The first number.
+ rhs: The second number.
+
+ Returns:
+ The number addition operation.
+ """
+ return f"({lhs} + {rhs})"
+
+
+@binary_number_operation
+def number_subtract_operation(lhs: NumberVar, rhs: NumberVar):
+ """Subtract two numbers.
+
+ Args:
+ lhs: The first number.
+ rhs: The second number.
+
+ Returns:
+ The number subtraction operation.
+ """
+ return f"({lhs} - {rhs})"
+
+
+@var_operation
+def number_abs_operation(value: NumberVar):
+ """Get the absolute value of the number.
+
+ Args:
+ value: The number.
+
+ Returns:
+ The number absolute operation.
+ """
+ return var_operation_return(
+ js_expression=f"Math.abs({value})", var_type=value._var_type
+ )
+
+
+@binary_number_operation
+def number_multiply_operation(lhs: NumberVar, rhs: NumberVar):
+ """Multiply two numbers.
+
+ Args:
+ lhs: The first number.
+ rhs: The second number.
+
+ Returns:
+ The number multiplication operation.
+ """
+ return f"({lhs} * {rhs})"
+
+
+@var_operation
+def number_negate_operation(
+ value: NumberVar[NUMBER_T],
+) -> CustomVarOperationReturn[NUMBER_T]:
+ """Negate the number.
+
+ Args:
+ value: The number.
+
+ Returns:
+ The number negation operation.
+ """
+ return var_operation_return(js_expression=f"-({value})", var_type=value._var_type)
+
+
+@binary_number_operation
+def number_true_division_operation(lhs: NumberVar, rhs: NumberVar):
+ """Divide two numbers.
+
+ Args:
+ lhs: The first number.
+ rhs: The second number.
+
+ Returns:
+ The number true division operation.
+ """
+ return f"({lhs} / {rhs})"
+
+
+@binary_number_operation
+def number_floor_division_operation(lhs: NumberVar, rhs: NumberVar):
+ """Floor divide two numbers.
+
+ Args:
+ lhs: The first number.
+ rhs: The second number.
+
+ Returns:
+ The number floor division operation.
+ """
+ return f"Math.floor({lhs} / {rhs})"
+
+
+@binary_number_operation
+def number_modulo_operation(lhs: NumberVar, rhs: NumberVar):
+ """Modulo two numbers.
+
+ Args:
+ lhs: The first number.
+ rhs: The second number.
+
+ Returns:
+ The number modulo operation.
+ """
+ return f"({lhs} % {rhs})"
+
+
+@binary_number_operation
+def number_exponent_operation(lhs: NumberVar, rhs: NumberVar):
+ """Exponentiate two numbers.
+
+ Args:
+ lhs: The first number.
+ rhs: The second number.
+
+ Returns:
+ The number exponent operation.
+ """
+ return f"({lhs} ** {rhs})"
+
+
+@var_operation
+def number_round_operation(value: NumberVar):
+ """Round the number.
+
+ Args:
+ value: The number.
+
+ Returns:
+ The number round operation.
+ """
+ return var_operation_return(js_expression=f"Math.round({value})", var_type=int)
+
+
+@var_operation
+def number_ceil_operation(value: NumberVar):
+ """Ceil the number.
+
+ Args:
+ value: The number.
+
+ Returns:
+ The number ceil operation.
+ """
+ return var_operation_return(js_expression=f"Math.ceil({value})", var_type=int)
+
+
+@var_operation
+def number_floor_operation(value: NumberVar):
+ """Floor the number.
+
+ Args:
+ value: The number.
+
+ Returns:
+ The number floor operation.
+ """
+ return var_operation_return(js_expression=f"Math.floor({value})", var_type=int)
+
+
+@var_operation
+def number_trunc_operation(value: NumberVar):
+ """Trunc the number.
+
+ Args:
+ value: The number.
+
+ Returns:
+ The number trunc operation.
+ """
+ return var_operation_return(js_expression=f"Math.trunc({value})", var_type=int)
+
+
+class BooleanVar(NumberVar[bool], python_types=bool):
+ """Base class for immutable boolean vars."""
+
+ def __invert__(self):
+ """NOT the boolean.
+
+ Returns:
+ The boolean NOT operation.
+ """
+ return boolean_not_operation(self)
+
+ def __int__(self):
+ """Convert the boolean to an int.
+
+ Returns:
+ The boolean to int operation.
+ """
+ return boolean_to_number_operation(self)
+
+ def __pos__(self):
+ """Convert the boolean to an int.
+
+ Returns:
+ The boolean to int operation.
+ """
+ return boolean_to_number_operation(self)
+
+ def bool(self) -> BooleanVar:
+ """Boolean conversion.
+
+ Returns:
+ The boolean value of the boolean.
+ """
+ return self
+
+ def __lt__(self, other: Any):
+ """Less than comparison.
+
+ Args:
+ other: The other boolean.
+
+ Returns:
+ The result of the comparison.
+ """
+ return +self < other
+
+ def __le__(self, other: Any):
+ """Less than or equal comparison.
+
+ Args:
+ other: The other boolean.
+
+ Returns:
+ The result of the comparison.
+ """
+ return +self <= other
+
+ def __gt__(self, other: Any):
+ """Greater than comparison.
+
+ Args:
+ other: The other boolean.
+
+ Returns:
+ The result of the comparison.
+ """
+ return +self > other
+
+ def __ge__(self, other: Any):
+ """Greater than or equal comparison.
+
+ Args:
+ other: The other boolean.
+
+ Returns:
+ The result of the comparison.
+ """
+ return +self >= other
+
+
+@var_operation
+def boolean_to_number_operation(value: BooleanVar):
+ """Convert the boolean to a number.
+
+ Args:
+ value: The boolean.
+
+ Returns:
+ The boolean to number operation.
+ """
+ return var_operation_return(js_expression=f"Number({value})", var_type=int)
+
+
+def comparison_operator(
+ func: Callable[[Var, Var], str],
+) -> Callable[[Var | Any, Var | Any], BooleanVar]:
+ """Decorator to create a comparison operation.
+
+ Args:
+ func: The comparison operation function.
+
+ Returns:
+ The comparison operation.
+ """
+
+ @var_operation
+ def operation(lhs: Var, rhs: Var):
+ return var_operation_return(
+ js_expression=func(lhs, rhs),
+ var_type=bool,
+ )
+
+ def wrapper(lhs: Var | Any, rhs: Var | Any) -> BooleanVar:
+ """Create the comparison operation.
+
+ Args:
+ lhs: The first value.
+ rhs: The second value.
+
+ Returns:
+ The comparison operation.
+ """
+ return operation(lhs, rhs)
+
+ return wrapper
+
+
+@comparison_operator
+def greater_than_operation(lhs: Var, rhs: Var):
+ """Greater than comparison.
+
+ Args:
+ lhs: The first value.
+ rhs: The second value.
+
+ Returns:
+ The result of the comparison.
+ """
+ return f"({lhs} > {rhs})"
+
+
+@comparison_operator
+def greater_than_or_equal_operation(lhs: Var, rhs: Var):
+ """Greater than or equal comparison.
+
+ Args:
+ lhs: The first value.
+ rhs: The second value.
+
+ Returns:
+ The result of the comparison.
+ """
+ return f"({lhs} >= {rhs})"
+
+
+@comparison_operator
+def less_than_operation(lhs: Var, rhs: Var):
+ """Less than comparison.
+
+ Args:
+ lhs: The first value.
+ rhs: The second value.
+
+ Returns:
+ The result of the comparison.
+ """
+ return f"({lhs} < {rhs})"
+
+
+@comparison_operator
+def less_than_or_equal_operation(lhs: Var, rhs: Var):
+ """Less than or equal comparison.
+
+ Args:
+ lhs: The first value.
+ rhs: The second value.
+
+ Returns:
+ The result of the comparison.
+ """
+ return f"({lhs} <= {rhs})"
+
+
+@comparison_operator
+def equal_operation(lhs: Var, rhs: Var):
+ """Equal comparison.
+
+ Args:
+ lhs: The first value.
+ rhs: The second value.
+
+ Returns:
+ The result of the comparison.
+ """
+ return f"({lhs} === {rhs})"
+
+
+@comparison_operator
+def not_equal_operation(lhs: Var, rhs: Var):
+ """Not equal comparison.
+
+ Args:
+ lhs: The first value.
+ rhs: The second value.
+
+ Returns:
+ The result of the comparison.
+ """
+ return f"({lhs} !== {rhs})"
+
+
+@var_operation
+def boolean_not_operation(value: BooleanVar):
+ """Boolean NOT the boolean.
+
+ Args:
+ value: The boolean.
+
+ Returns:
+ The boolean NOT operation.
+ """
+ return var_operation_return(js_expression=f"!({value})", var_type=bool)
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class LiteralNumberVar(LiteralVar, NumberVar):
+ """Base class for immutable literal number vars."""
+
+ _var_value: float | int = dataclasses.field(default=0)
+
+ def json(self) -> str:
+ """Get the JSON representation of the var.
+
+ Returns:
+ The JSON representation of the var.
+
+ Raises:
+ PrimitiveUnserializableToJSON: If the var is unserializable to JSON.
+ """
+ if math.isinf(self._var_value) or math.isnan(self._var_value):
+ raise PrimitiveUnserializableToJSON(
+ f"No valid JSON representation for {self}"
+ )
+ return json.dumps(self._var_value)
+
+ def __hash__(self) -> int:
+ """Calculate the hash value of the object.
+
+ Returns:
+ int: The hash value of the object.
+ """
+ return hash((type(self).__name__, self._var_value))
+
+ @classmethod
+ def create(cls, value: float | int, _var_data: VarData | None = None):
+ """Create the number var.
+
+ Args:
+ value: The value of the var.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The number var.
+ """
+ if math.isinf(value):
+ js_expr = "Infinity" if value > 0 else "-Infinity"
+ elif math.isnan(value):
+ js_expr = "NaN"
+ else:
+ js_expr = str(value)
+
+ return cls(
+ _js_expr=js_expr,
+ _var_type=type(value),
+ _var_data=_var_data,
+ _var_value=value,
+ )
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class LiteralBooleanVar(LiteralVar, BooleanVar):
+ """Base class for immutable literal boolean vars."""
+
+ _var_value: bool = dataclasses.field(default=False)
+
+ def json(self) -> str:
+ """Get the JSON representation of the var.
+
+ Returns:
+ The JSON representation of the var.
+ """
+ return "true" if self._var_value else "false"
+
+ def __hash__(self) -> int:
+ """Calculate the hash value of the object.
+
+ Returns:
+ int: The hash value of the object.
+ """
+ return hash((type(self).__name__, self._var_value))
+
+ @classmethod
+ def create(cls, value: bool, _var_data: VarData | None = None):
+ """Create the boolean var.
+
+ Args:
+ value: The value of the var.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The boolean var.
+ """
+ return cls(
+ _js_expr="true" if value else "false",
+ _var_type=bool,
+ _var_data=_var_data,
+ _var_value=value,
+ )
+
+
+number_types = Union[NumberVar, int, float]
+boolean_types = Union[BooleanVar, bool]
+
+
+_IS_TRUE_IMPORT: ImportDict = {
+ f"$/{Dirs.STATE_PATH}": [ImportVar(tag="isTrue")],
+}
+
+
+@var_operation
+def boolify(value: Var):
+ """Convert the value to a boolean.
+
+ Args:
+ value: The value.
+
+ Returns:
+ The boolean value.
+ """
+ return var_operation_return(
+ js_expression=f"isTrue({value})",
+ var_type=bool,
+ var_data=VarData(imports=_IS_TRUE_IMPORT),
+ )
+
+
+T = TypeVar("T")
+U = TypeVar("U")
+
+
+@var_operation
+def ternary_operation(
+ condition: BooleanVar, if_true: Var[T], if_false: Var[U]
+) -> CustomVarOperationReturn[Union[T, U]]:
+ """Create a ternary operation.
+
+ Args:
+ condition: The condition.
+ if_true: The value if the condition is true.
+ if_false: The value if the condition is false.
+
+ Returns:
+ The ternary operation.
+ """
+ type_value: Union[Type[T], Type[U]] = unionize(
+ if_true._var_type, if_false._var_type
+ )
+ value: CustomVarOperationReturn[Union[T, U]] = var_operation_return(
+ js_expression=f"({condition} ? {if_true} : {if_false})",
+ var_type=type_value,
+ )
+ return value
+
+
+NUMBER_TYPES = (int, float, NumberVar)
diff --git a/reflex/vars/object.py b/reflex/vars/object.py
new file mode 100644
index 000000000..5de431f5a
--- /dev/null
+++ b/reflex/vars/object.py
@@ -0,0 +1,542 @@
+"""Classes for immutable object vars."""
+
+from __future__ import annotations
+
+import dataclasses
+import sys
+import typing
+from inspect import isclass
+from typing import (
+ Any,
+ Dict,
+ List,
+ NoReturn,
+ Tuple,
+ Type,
+ TypeVar,
+ Union,
+ get_args,
+ overload,
+)
+
+from reflex.utils import types
+from reflex.utils.exceptions import VarAttributeError
+from reflex.utils.types import GenericType, get_attribute_access_type, get_origin
+
+from .base import (
+ CachedVarOperation,
+ LiteralVar,
+ Var,
+ VarData,
+ cached_property_no_lock,
+ figure_out_type,
+ var_operation,
+ var_operation_return,
+)
+from .number import BooleanVar, NumberVar, raise_unsupported_operand_types
+from .sequence import ArrayVar, StringVar
+
+OBJECT_TYPE = TypeVar("OBJECT_TYPE")
+
+KEY_TYPE = TypeVar("KEY_TYPE")
+VALUE_TYPE = TypeVar("VALUE_TYPE")
+
+ARRAY_INNER_TYPE = TypeVar("ARRAY_INNER_TYPE")
+
+OTHER_KEY_TYPE = TypeVar("OTHER_KEY_TYPE")
+
+
+class ObjectVar(Var[OBJECT_TYPE], python_types=dict):
+ """Base class for immutable object vars."""
+
+ def _key_type(self) -> Type:
+ """Get the type of the keys of the object.
+
+ Returns:
+ The type of the keys of the object.
+ """
+ return str
+
+ @overload
+ def _value_type(
+ self: ObjectVar[Dict[Any, VALUE_TYPE]],
+ ) -> Type[VALUE_TYPE]: ...
+
+ @overload
+ def _value_type(self) -> Type: ...
+
+ def _value_type(self) -> Type:
+ """Get the type of the values of the object.
+
+ Returns:
+ The type of the values of the object.
+ """
+ fixed_type = get_origin(self._var_type) or self._var_type
+ if not isclass(fixed_type):
+ return Any
+ args = get_args(self._var_type) if issubclass(fixed_type, dict) else ()
+ return args[1] if args else Any
+
+ def keys(self) -> ArrayVar[List[str]]:
+ """Get the keys of the object.
+
+ Returns:
+ The keys of the object.
+ """
+ return object_keys_operation(self)
+
+ @overload
+ def values(
+ self: ObjectVar[Dict[Any, VALUE_TYPE]],
+ ) -> ArrayVar[List[VALUE_TYPE]]: ...
+
+ @overload
+ def values(self) -> ArrayVar: ...
+
+ def values(self) -> ArrayVar:
+ """Get the values of the object.
+
+ Returns:
+ The values of the object.
+ """
+ return object_values_operation(self)
+
+ @overload
+ def entries(
+ self: ObjectVar[Dict[Any, VALUE_TYPE]],
+ ) -> ArrayVar[List[Tuple[str, VALUE_TYPE]]]: ...
+
+ @overload
+ def entries(self) -> ArrayVar: ...
+
+ def entries(self) -> ArrayVar:
+ """Get the entries of the object.
+
+ Returns:
+ The entries of the object.
+ """
+ return object_entries_operation(self)
+
+ items = entries
+
+ def merge(self, other: ObjectVar):
+ """Merge two objects.
+
+ Args:
+ other: The other object to merge.
+
+ Returns:
+ The merged object.
+ """
+ return object_merge_operation(self, other)
+
+ # NoReturn is used here to catch when key value is Any
+ @overload
+ def __getitem__(
+ self: ObjectVar[Dict[Any, NoReturn]],
+ key: Var | Any,
+ ) -> Var: ...
+
+ @overload
+ def __getitem__(
+ self: (
+ ObjectVar[Dict[Any, int]]
+ | ObjectVar[Dict[Any, float]]
+ | ObjectVar[Dict[Any, int | float]]
+ ),
+ key: Var | Any,
+ ) -> NumberVar: ...
+
+ @overload
+ def __getitem__(
+ self: ObjectVar[Dict[Any, str]],
+ key: Var | Any,
+ ) -> StringVar: ...
+
+ @overload
+ def __getitem__(
+ self: ObjectVar[Dict[Any, list[ARRAY_INNER_TYPE]]],
+ key: Var | Any,
+ ) -> ArrayVar[list[ARRAY_INNER_TYPE]]: ...
+
+ @overload
+ def __getitem__(
+ self: ObjectVar[Dict[Any, set[ARRAY_INNER_TYPE]]],
+ key: Var | Any,
+ ) -> ArrayVar[set[ARRAY_INNER_TYPE]]: ...
+
+ @overload
+ def __getitem__(
+ self: ObjectVar[Dict[Any, tuple[ARRAY_INNER_TYPE, ...]]],
+ key: Var | Any,
+ ) -> ArrayVar[tuple[ARRAY_INNER_TYPE, ...]]: ...
+
+ @overload
+ def __getitem__(
+ self: ObjectVar[Dict[Any, dict[OTHER_KEY_TYPE, VALUE_TYPE]]],
+ key: Var | Any,
+ ) -> ObjectVar[dict[OTHER_KEY_TYPE, VALUE_TYPE]]: ...
+
+ def __getitem__(self, key: Var | Any) -> Var:
+ """Get an item from the object.
+
+ Args:
+ key: The key to get from the object.
+
+ Returns:
+ The item from the object.
+ """
+ if not isinstance(key, (StringVar, str, int, NumberVar)) or (
+ isinstance(key, NumberVar) and key._is_strict_float()
+ ):
+ raise_unsupported_operand_types("[]", (type(self), type(key)))
+ return ObjectItemOperation.create(self, key).guess_type()
+
+ # NoReturn is used here to catch when key value is Any
+ @overload
+ def __getattr__(
+ self: ObjectVar[Dict[Any, NoReturn]],
+ name: str,
+ ) -> Var: ...
+
+ @overload
+ def __getattr__(
+ self: (
+ ObjectVar[Dict[Any, int]]
+ | ObjectVar[Dict[Any, float]]
+ | ObjectVar[Dict[Any, int | float]]
+ ),
+ name: str,
+ ) -> NumberVar: ...
+
+ @overload
+ def __getattr__(
+ self: ObjectVar[Dict[Any, str]],
+ name: str,
+ ) -> StringVar: ...
+
+ @overload
+ def __getattr__(
+ self: ObjectVar[Dict[Any, list[ARRAY_INNER_TYPE]]],
+ name: str,
+ ) -> ArrayVar[list[ARRAY_INNER_TYPE]]: ...
+
+ @overload
+ def __getattr__(
+ self: ObjectVar[Dict[Any, set[ARRAY_INNER_TYPE]]],
+ name: str,
+ ) -> ArrayVar[set[ARRAY_INNER_TYPE]]: ...
+
+ @overload
+ def __getattr__(
+ self: ObjectVar[Dict[Any, tuple[ARRAY_INNER_TYPE, ...]]],
+ name: str,
+ ) -> ArrayVar[tuple[ARRAY_INNER_TYPE, ...]]: ...
+
+ @overload
+ def __getattr__(
+ self: ObjectVar[Dict[Any, dict[OTHER_KEY_TYPE, VALUE_TYPE]]],
+ name: str,
+ ) -> ObjectVar[dict[OTHER_KEY_TYPE, VALUE_TYPE]]: ...
+
+ @overload
+ def __getattr__(
+ self: ObjectVar,
+ name: str,
+ ) -> ObjectItemOperation: ...
+
+ def __getattr__(self, name) -> Var:
+ """Get an attribute of the var.
+
+ Args:
+ name: The name of the attribute.
+
+ Raises:
+ VarAttributeError: The State var has no such attribute or may have been annotated wrongly.
+
+ Returns:
+ The attribute of the var.
+ """
+ if name.startswith("__") and name.endswith("__"):
+ return getattr(super(type(self), self), name)
+
+ var_type = self._var_type
+
+ if types.is_optional(var_type):
+ var_type = get_args(var_type)[0]
+
+ fixed_type = var_type if isclass(var_type) else get_origin(var_type)
+ if (isclass(fixed_type) and not issubclass(fixed_type, dict)) or (
+ fixed_type in types.UnionTypes
+ ):
+ attribute_type = get_attribute_access_type(var_type, name)
+ if attribute_type is None:
+ raise VarAttributeError(
+ f"The State var `{self!s}` has no attribute '{name}' or may have been annotated "
+ f"wrongly."
+ )
+ return ObjectItemOperation.create(self, name, attribute_type).guess_type()
+ else:
+ return ObjectItemOperation.create(self, name).guess_type()
+
+ def contains(self, key: Var | Any) -> BooleanVar:
+ """Check if the object contains a key.
+
+ Args:
+ key: The key to check.
+
+ Returns:
+ The result of the check.
+ """
+ return object_has_own_property_operation(self, key)
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class LiteralObjectVar(CachedVarOperation, ObjectVar[OBJECT_TYPE], LiteralVar):
+ """Base class for immutable literal object vars."""
+
+ _var_value: Dict[Union[Var, Any], Union[Var, Any]] = dataclasses.field(
+ default_factory=dict
+ )
+
+ def _key_type(self) -> Type:
+ """Get the type of the keys of the object.
+
+ Returns:
+ The type of the keys of the object.
+ """
+ args_list = typing.get_args(self._var_type)
+ return args_list[0] if args_list else Any
+
+ def _value_type(self) -> Type:
+ """Get the type of the values of the object.
+
+ Returns:
+ The type of the values of the object.
+ """
+ args_list = typing.get_args(self._var_type)
+ return args_list[1] if args_list else Any
+
+ @cached_property_no_lock
+ def _cached_var_name(self) -> str:
+ """The name of the var.
+
+ Returns:
+ The name of the var.
+ """
+ return (
+ "({ "
+ + ", ".join(
+ [
+ f"[{LiteralVar.create(key)!s}] : {LiteralVar.create(value)!s}"
+ for key, value in self._var_value.items()
+ ]
+ )
+ + " })"
+ )
+
+ def json(self) -> str:
+ """Get the JSON representation of the object.
+
+ Returns:
+ The JSON representation of the object.
+ """
+ return (
+ "{"
+ + ", ".join(
+ [
+ f"{LiteralVar.create(key).json()}:{LiteralVar.create(value).json()}"
+ for key, value in self._var_value.items()
+ ]
+ )
+ + "}"
+ )
+
+ def __hash__(self) -> int:
+ """Get the hash of the var.
+
+ Returns:
+ The hash of the var.
+ """
+ return hash((type(self).__name__, self._js_expr))
+
+ @cached_property_no_lock
+ def _cached_get_all_var_data(self) -> VarData | None:
+ """Get all the var data.
+
+ Returns:
+ The var data.
+ """
+ return VarData.merge(
+ *[LiteralVar.create(var)._get_all_var_data() for var in self._var_value],
+ *[
+ LiteralVar.create(var)._get_all_var_data()
+ for var in self._var_value.values()
+ ],
+ self._var_data,
+ )
+
+ @classmethod
+ def create(
+ cls,
+ _var_value: dict,
+ _var_type: Type[OBJECT_TYPE] | None = None,
+ _var_data: VarData | None = None,
+ ) -> LiteralObjectVar[OBJECT_TYPE]:
+ """Create the literal object var.
+
+ Args:
+ _var_value: The value of the var.
+ _var_type: The type of the var.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The literal object var.
+ """
+ return LiteralObjectVar(
+ _js_expr="",
+ _var_type=(figure_out_type(_var_value) if _var_type is None else _var_type),
+ _var_data=_var_data,
+ _var_value=_var_value,
+ )
+
+
+@var_operation
+def object_keys_operation(value: ObjectVar):
+ """Get the keys of an object.
+
+ Args:
+ value: The object to get the keys from.
+
+ Returns:
+ The keys of the object.
+ """
+ return var_operation_return(
+ js_expression=f"Object.keys({value})",
+ var_type=List[str],
+ )
+
+
+@var_operation
+def object_values_operation(value: ObjectVar):
+ """Get the values of an object.
+
+ Args:
+ value: The object to get the values from.
+
+ Returns:
+ The values of the object.
+ """
+ return var_operation_return(
+ js_expression=f"Object.values({value})",
+ var_type=List[value._value_type()],
+ )
+
+
+@var_operation
+def object_entries_operation(value: ObjectVar):
+ """Get the entries of an object.
+
+ Args:
+ value: The object to get the entries from.
+
+ Returns:
+ The entries of the object.
+ """
+ return var_operation_return(
+ js_expression=f"Object.entries({value})",
+ var_type=List[Tuple[str, value._value_type()]],
+ )
+
+
+@var_operation
+def object_merge_operation(lhs: ObjectVar, rhs: ObjectVar):
+ """Merge two objects.
+
+ Args:
+ lhs: The first object to merge.
+ rhs: The second object to merge.
+
+ Returns:
+ The merged object.
+ """
+ return var_operation_return(
+ js_expression=f"({{...{lhs}, ...{rhs}}})",
+ var_type=Dict[
+ Union[lhs._key_type(), rhs._key_type()],
+ Union[lhs._value_type(), rhs._value_type()],
+ ],
+ )
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class ObjectItemOperation(CachedVarOperation, Var):
+ """Operation to get an item from an object."""
+
+ _object: ObjectVar = dataclasses.field(
+ default_factory=lambda: LiteralObjectVar.create({})
+ )
+ _key: Var | Any = dataclasses.field(default_factory=lambda: LiteralVar.create(None))
+
+ @cached_property_no_lock
+ def _cached_var_name(self) -> str:
+ """The name of the operation.
+
+ Returns:
+ The name of the operation.
+ """
+ if types.is_optional(self._object._var_type):
+ return f"{self._object!s}?.[{self._key!s}]"
+ return f"{self._object!s}[{self._key!s}]"
+
+ @classmethod
+ def create(
+ cls,
+ object: ObjectVar,
+ key: Var | Any,
+ _var_type: GenericType | None = None,
+ _var_data: VarData | None = None,
+ ) -> ObjectItemOperation:
+ """Create the object item operation.
+
+ Args:
+ object: The object to get the item from.
+ key: The key to get from the object.
+ _var_type: The type of the item.
+ _var_data: Additional hooks and imports associated with the operation.
+
+ Returns:
+ The object item operation.
+ """
+ return cls(
+ _js_expr="",
+ _var_type=object._value_type() if _var_type is None else _var_type,
+ _var_data=_var_data,
+ _object=object,
+ _key=key if isinstance(key, Var) else LiteralVar.create(key),
+ )
+
+
+@var_operation
+def object_has_own_property_operation(object: ObjectVar, key: Var):
+ """Check if an object has a key.
+
+ Args:
+ object: The object to check.
+ key: The key to check.
+
+ Returns:
+ The result of the check.
+ """
+ return var_operation_return(
+ js_expression=f"{object}.hasOwnProperty({key})",
+ var_type=bool,
+ )
diff --git a/reflex/vars/sequence.py b/reflex/vars/sequence.py
new file mode 100644
index 000000000..476c1e32c
--- /dev/null
+++ b/reflex/vars/sequence.py
@@ -0,0 +1,1789 @@
+"""Collection of string classes and utilities."""
+
+from __future__ import annotations
+
+import dataclasses
+import inspect
+import json
+import re
+import sys
+import typing
+from typing import (
+ TYPE_CHECKING,
+ Any,
+ Dict,
+ List,
+ Literal,
+ NoReturn,
+ Set,
+ Tuple,
+ Type,
+ Union,
+ overload,
+)
+
+from typing_extensions import TypeVar
+
+from reflex import constants
+from reflex.constants.base import REFLEX_VAR_OPENING_TAG
+from reflex.constants.colors import Color
+from reflex.utils.exceptions import VarTypeError
+from reflex.utils.types import GenericType, get_origin
+
+from .base import (
+ CachedVarOperation,
+ CustomVarOperationReturn,
+ LiteralVar,
+ Var,
+ VarData,
+ _global_vars,
+ cached_property_no_lock,
+ figure_out_type,
+ get_python_literal,
+ get_unique_variable_name,
+ unionize,
+ var_operation,
+ var_operation_return,
+)
+from .number import (
+ BooleanVar,
+ LiteralNumberVar,
+ NumberVar,
+ raise_unsupported_operand_types,
+ ternary_operation,
+)
+
+if TYPE_CHECKING:
+ from .object import ObjectVar
+
+STRING_TYPE = TypeVar("STRING_TYPE", default=str)
+
+
+class StringVar(Var[STRING_TYPE], python_types=str):
+ """Base class for immutable string vars."""
+
+ @overload
+ def __add__(self, other: StringVar | str) -> ConcatVarOperation: ...
+
+ @overload
+ def __add__(self, other: NoReturn) -> NoReturn: ...
+
+ def __add__(self, other: Any) -> ConcatVarOperation:
+ """Concatenate two strings.
+
+ Args:
+ other: The other string.
+
+ Returns:
+ The string concatenation operation.
+ """
+ if not isinstance(other, (StringVar, str)):
+ raise_unsupported_operand_types("+", (type(self), type(other)))
+
+ return ConcatVarOperation.create(self, other)
+
+ @overload
+ def __radd__(self, other: StringVar | str) -> ConcatVarOperation: ...
+
+ @overload
+ def __radd__(self, other: NoReturn) -> NoReturn: ...
+
+ def __radd__(self, other: Any) -> ConcatVarOperation:
+ """Concatenate two strings.
+
+ Args:
+ other: The other string.
+
+ Returns:
+ The string concatenation operation.
+ """
+ if not isinstance(other, (StringVar, str)):
+ raise_unsupported_operand_types("+", (type(other), type(self)))
+
+ return ConcatVarOperation.create(other, self)
+
+ @overload
+ def __mul__(self, other: NumberVar | int) -> StringVar: ...
+
+ @overload
+ def __mul__(self, other: NoReturn) -> NoReturn: ...
+
+ def __mul__(self, other: Any) -> StringVar:
+ """Multiply the sequence by a number or an integer.
+
+ Args:
+ other: The number or integer to multiply the sequence by.
+
+ Returns:
+ StringVar: The resulting sequence after multiplication.
+ """
+ if not isinstance(other, (NumberVar, int)):
+ raise_unsupported_operand_types("*", (type(self), type(other)))
+
+ return (self.split() * other).join()
+
+ @overload
+ def __rmul__(self, other: NumberVar | int) -> StringVar: ...
+
+ @overload
+ def __rmul__(self, other: NoReturn) -> NoReturn: ...
+
+ def __rmul__(self, other: Any) -> StringVar:
+ """Multiply the sequence by a number or an integer.
+
+ Args:
+ other: The number or integer to multiply the sequence by.
+
+ Returns:
+ StringVar: The resulting sequence after multiplication.
+ """
+ if not isinstance(other, (NumberVar, int)):
+ raise_unsupported_operand_types("*", (type(other), type(self)))
+
+ return (self.split() * other).join()
+
+ @overload
+ def __getitem__(self, i: slice) -> StringVar: ...
+
+ @overload
+ def __getitem__(self, i: int | NumberVar) -> StringVar: ...
+
+ def __getitem__(self, i: Any) -> StringVar:
+ """Get a slice of the string.
+
+ Args:
+ i: The slice.
+
+ Returns:
+ The string slice operation.
+ """
+ if isinstance(i, slice):
+ return self.split()[i].join()
+ if not isinstance(i, (int, NumberVar)) or (
+ isinstance(i, NumberVar) and i._is_strict_float()
+ ):
+ raise_unsupported_operand_types("[]", (type(self), type(i)))
+ return string_item_operation(self, i)
+
+ def length(self) -> NumberVar:
+ """Get the length of the string.
+
+ Returns:
+ The string length operation.
+ """
+ return self.split().length()
+
+ def lower(self) -> StringVar:
+ """Convert the string to lowercase.
+
+ Returns:
+ The string lower operation.
+ """
+ return string_lower_operation(self)
+
+ def upper(self) -> StringVar:
+ """Convert the string to uppercase.
+
+ Returns:
+ The string upper operation.
+ """
+ return string_upper_operation(self)
+
+ def strip(self) -> StringVar:
+ """Strip the string.
+
+ Returns:
+ The string strip operation.
+ """
+ return string_strip_operation(self)
+
+ def reversed(self) -> StringVar:
+ """Reverse the string.
+
+ Returns:
+ The string reverse operation.
+ """
+ return self.split().reverse().join()
+
+ @overload
+ def contains(
+ self, other: StringVar | str, field: StringVar | str | None = None
+ ) -> BooleanVar: ...
+
+ @overload
+ def contains(
+ self, other: NoReturn, field: StringVar | str | None = None
+ ) -> NoReturn: ...
+
+ def contains(self, other: Any, field: Any = None) -> BooleanVar:
+ """Check if the string contains another string.
+
+ Args:
+ other: The other string.
+ field: The field to check.
+
+ Returns:
+ The string contains operation.
+ """
+ if not isinstance(other, (StringVar, str)):
+ raise_unsupported_operand_types("contains", (type(self), type(other)))
+ if field is not None:
+ if not isinstance(field, (StringVar, str)):
+ raise_unsupported_operand_types("contains", (type(self), type(field)))
+ return string_contains_field_operation(self, other, field)
+ return string_contains_operation(self, other)
+
+ @overload
+ def split(self, separator: StringVar | str = "") -> ArrayVar[List[str]]: ...
+
+ @overload
+ def split(self, separator: NoReturn) -> NoReturn: ...
+
+ def split(self, separator: Any = "") -> ArrayVar[List[str]]:
+ """Split the string.
+
+ Args:
+ separator: The separator.
+
+ Returns:
+ The string split operation.
+ """
+ if not isinstance(separator, (StringVar, str)):
+ raise_unsupported_operand_types("split", (type(self), type(separator)))
+ return string_split_operation(self, separator)
+
+ @overload
+ def startswith(self, prefix: StringVar | str) -> BooleanVar: ...
+
+ @overload
+ def startswith(self, prefix: NoReturn) -> NoReturn: ...
+
+ def startswith(self, prefix: Any) -> BooleanVar:
+ """Check if the string starts with a prefix.
+
+ Args:
+ prefix: The prefix.
+
+ Returns:
+ The string starts with operation.
+ """
+ if not isinstance(prefix, (StringVar, str)):
+ raise_unsupported_operand_types("startswith", (type(self), type(prefix)))
+ return string_starts_with_operation(self, prefix)
+
+ @overload
+ def __lt__(self, other: StringVar | str) -> BooleanVar: ...
+
+ @overload
+ def __lt__(self, other: NoReturn) -> NoReturn: ...
+
+ def __lt__(self, other: Any):
+ """Check if the string is less than another string.
+
+ Args:
+ other: The other string.
+
+ Returns:
+ The string less than operation.
+ """
+ if not isinstance(other, (StringVar, str)):
+ raise_unsupported_operand_types("<", (type(self), type(other)))
+
+ return string_lt_operation(self, other)
+
+ @overload
+ def __gt__(self, other: StringVar | str) -> BooleanVar: ...
+
+ @overload
+ def __gt__(self, other: NoReturn) -> NoReturn: ...
+
+ def __gt__(self, other: Any):
+ """Check if the string is greater than another string.
+
+ Args:
+ other: The other string.
+
+ Returns:
+ The string greater than operation.
+ """
+ if not isinstance(other, (StringVar, str)):
+ raise_unsupported_operand_types(">", (type(self), type(other)))
+
+ return string_gt_operation(self, other)
+
+ @overload
+ def __le__(self, other: StringVar | str) -> BooleanVar: ...
+
+ @overload
+ def __le__(self, other: NoReturn) -> NoReturn: ...
+
+ def __le__(self, other: Any):
+ """Check if the string is less than or equal to another string.
+
+ Args:
+ other: The other string.
+
+ Returns:
+ The string less than or equal operation.
+ """
+ if not isinstance(other, (StringVar, str)):
+ raise_unsupported_operand_types("<=", (type(self), type(other)))
+
+ return string_le_operation(self, other)
+
+ @overload
+ def __ge__(self, other: StringVar | str) -> BooleanVar: ...
+
+ @overload
+ def __ge__(self, other: NoReturn) -> NoReturn: ...
+
+ def __ge__(self, other: Any):
+ """Check if the string is greater than or equal to another string.
+
+ Args:
+ other: The other string.
+
+ Returns:
+ The string greater than or equal operation.
+ """
+ if not isinstance(other, (StringVar, str)):
+ raise_unsupported_operand_types(">=", (type(self), type(other)))
+
+ return string_ge_operation(self, other)
+
+
+@var_operation
+def string_lt_operation(lhs: StringVar[Any] | str, rhs: StringVar[Any] | str):
+ """Check if a string is less than another string.
+
+ Args:
+ lhs: The left-hand side string.
+ rhs: The right-hand side string.
+
+ Returns:
+ The string less than operation.
+ """
+ return var_operation_return(js_expression=f"{lhs} < {rhs}", var_type=bool)
+
+
+@var_operation
+def string_gt_operation(lhs: StringVar[Any] | str, rhs: StringVar[Any] | str):
+ """Check if a string is greater than another string.
+
+ Args:
+ lhs: The left-hand side string.
+ rhs: The right-hand side string.
+
+ Returns:
+ The string greater than operation.
+ """
+ return var_operation_return(js_expression=f"{lhs} > {rhs}", var_type=bool)
+
+
+@var_operation
+def string_le_operation(lhs: StringVar[Any] | str, rhs: StringVar[Any] | str):
+ """Check if a string is less than or equal to another string.
+
+ Args:
+ lhs: The left-hand side string.
+ rhs: The right-hand side string.
+
+ Returns:
+ The string less than or equal operation.
+ """
+ return var_operation_return(js_expression=f"{lhs} <= {rhs}", var_type=bool)
+
+
+@var_operation
+def string_ge_operation(lhs: StringVar[Any] | str, rhs: StringVar[Any] | str):
+ """Check if a string is greater than or equal to another string.
+
+ Args:
+ lhs: The left-hand side string.
+ rhs: The right-hand side string.
+
+ Returns:
+ The string greater than or equal operation.
+ """
+ return var_operation_return(js_expression=f"{lhs} >= {rhs}", var_type=bool)
+
+
+@var_operation
+def string_lower_operation(string: StringVar[Any]):
+ """Convert a string to lowercase.
+
+ Args:
+ string: The string to convert.
+
+ Returns:
+ The lowercase string.
+ """
+ return var_operation_return(js_expression=f"{string}.toLowerCase()", var_type=str)
+
+
+@var_operation
+def string_upper_operation(string: StringVar[Any]):
+ """Convert a string to uppercase.
+
+ Args:
+ string: The string to convert.
+
+ Returns:
+ The uppercase string.
+ """
+ return var_operation_return(js_expression=f"{string}.toUpperCase()", var_type=str)
+
+
+@var_operation
+def string_strip_operation(string: StringVar[Any]):
+ """Strip a string.
+
+ Args:
+ string: The string to strip.
+
+ Returns:
+ The stripped string.
+ """
+ return var_operation_return(js_expression=f"{string}.trim()", var_type=str)
+
+
+@var_operation
+def string_contains_field_operation(
+ haystack: StringVar[Any], needle: StringVar[Any] | str, field: StringVar[Any] | str
+):
+ """Check if a string contains another string.
+
+ Args:
+ haystack: The haystack.
+ needle: The needle.
+ field: The field to check.
+
+ Returns:
+ The string contains operation.
+ """
+ return var_operation_return(
+ js_expression=f"{haystack}.some(obj => obj[{field}] === {needle})",
+ var_type=bool,
+ )
+
+
+@var_operation
+def string_contains_operation(haystack: StringVar[Any], needle: StringVar[Any] | str):
+ """Check if a string contains another string.
+
+ Args:
+ haystack: The haystack.
+ needle: The needle.
+
+ Returns:
+ The string contains operation.
+ """
+ return var_operation_return(
+ js_expression=f"{haystack}.includes({needle})", var_type=bool
+ )
+
+
+@var_operation
+def string_starts_with_operation(
+ full_string: StringVar[Any], prefix: StringVar[Any] | str
+):
+ """Check if a string starts with a prefix.
+
+ Args:
+ full_string: The full string.
+ prefix: The prefix.
+
+ Returns:
+ Whether the string starts with the prefix.
+ """
+ return var_operation_return(
+ js_expression=f"{full_string}.startsWith({prefix})", var_type=bool
+ )
+
+
+@var_operation
+def string_item_operation(string: StringVar[Any], index: NumberVar | int):
+ """Get an item from a string.
+
+ Args:
+ string: The string.
+ index: The index of the item.
+
+ Returns:
+ The item from the string.
+ """
+ return var_operation_return(js_expression=f"{string}.at({index})", var_type=str)
+
+
+@var_operation
+def array_join_operation(array: ArrayVar, sep: StringVar[Any] | str = ""):
+ """Join the elements of an array.
+
+ Args:
+ array: The array.
+ sep: The separator.
+
+ Returns:
+ The joined elements.
+ """
+ return var_operation_return(js_expression=f"{array}.join({sep})", var_type=str)
+
+
+@var_operation
+def string_replace_operation(
+ string: StringVar, search_value: StringVar | str, new_value: StringVar | str
+):
+ """Replace a string with a value.
+
+ Args:
+ string: The string.
+ search_value: The string to search.
+ new_value: The value to be replaced with.
+
+ Returns:
+ The string replace operation.
+ """
+ return var_operation_return(
+ js_expression=f"{string}.replace({search_value}, {new_value})",
+ var_type=str,
+ )
+
+
+# Compile regex for finding reflex var tags.
+_decode_var_pattern_re = (
+ rf"{constants.REFLEX_VAR_OPENING_TAG}(.*?){constants.REFLEX_VAR_CLOSING_TAG}"
+)
+_decode_var_pattern = re.compile(_decode_var_pattern_re, flags=re.DOTALL)
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class LiteralStringVar(LiteralVar, StringVar[str]):
+ """Base class for immutable literal string vars."""
+
+ _var_value: str = dataclasses.field(default="")
+
+ @classmethod
+ def create(
+ cls,
+ value: str,
+ _var_type: GenericType | None = None,
+ _var_data: VarData | None = None,
+ ) -> StringVar:
+ """Create a var from a string value.
+
+ Args:
+ value: The value to create the var from.
+ _var_type: The type of the var.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The var.
+ """
+ # Determine var type in case the value is inherited from str.
+ _var_type = _var_type or type(value) or str
+
+ if REFLEX_VAR_OPENING_TAG in value:
+ strings_and_vals: list[Var | str] = []
+ offset = 0
+
+ # Find all tags
+ while m := _decode_var_pattern.search(value):
+ start, end = m.span()
+
+ strings_and_vals.append(value[:start])
+
+ serialized_data = m.group(1)
+
+ if serialized_data.isnumeric() or (
+ serialized_data[0] == "-" and serialized_data[1:].isnumeric()
+ ):
+ # This is a global immutable var.
+ var = _global_vars[int(serialized_data)]
+ strings_and_vals.append(var)
+ value = value[(end + len(var._js_expr)) :]
+
+ offset += end - start
+
+ strings_and_vals.append(value)
+
+ filtered_strings_and_vals = [
+ s for s in strings_and_vals if isinstance(s, Var) or s
+ ]
+ if len(filtered_strings_and_vals) == 1:
+ only_string = filtered_strings_and_vals[0]
+ if isinstance(only_string, str):
+ return LiteralVar.create(only_string).to(StringVar, _var_type)
+ else:
+ return only_string.to(StringVar, only_string._var_type)
+
+ if len(
+ literal_strings := [
+ s
+ for s in filtered_strings_and_vals
+ if isinstance(s, (str, LiteralStringVar))
+ ]
+ ) == len(filtered_strings_and_vals):
+ return LiteralStringVar.create(
+ "".join(
+ s._var_value if isinstance(s, LiteralStringVar) else s
+ for s in literal_strings
+ ),
+ _var_type=_var_type,
+ _var_data=VarData.merge(
+ _var_data,
+ *(
+ s._get_all_var_data()
+ for s in filtered_strings_and_vals
+ if isinstance(s, Var)
+ ),
+ ),
+ )
+
+ concat_result = ConcatVarOperation.create(
+ *filtered_strings_and_vals,
+ _var_data=_var_data,
+ )
+
+ return (
+ concat_result
+ if _var_type is str
+ else concat_result.to(StringVar, _var_type)
+ )
+
+ return LiteralStringVar(
+ _js_expr=json.dumps(value),
+ _var_type=_var_type,
+ _var_data=_var_data,
+ _var_value=value,
+ )
+
+ def __hash__(self) -> int:
+ """Get the hash of the var.
+
+ Returns:
+ The hash of the var.
+ """
+ return hash((type(self).__name__, self._var_value))
+
+ def json(self) -> str:
+ """Get the JSON representation of the var.
+
+ Returns:
+ The JSON representation of the var.
+ """
+ return json.dumps(self._var_value)
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class ConcatVarOperation(CachedVarOperation, StringVar[str]):
+ """Representing a concatenation of literal string vars."""
+
+ _var_value: Tuple[Var, ...] = dataclasses.field(default_factory=tuple)
+
+ @cached_property_no_lock
+ def _cached_var_name(self) -> str:
+ """The name of the var.
+
+ Returns:
+ The name of the var.
+ """
+ list_of_strs: List[Union[str, Var]] = []
+ last_string = ""
+ for var in self._var_value:
+ if isinstance(var, LiteralStringVar):
+ last_string += var._var_value
+ else:
+ if last_string:
+ list_of_strs.append(last_string)
+ last_string = ""
+ list_of_strs.append(var)
+
+ if last_string:
+ list_of_strs.append(last_string)
+
+ list_of_strs_filtered = [
+ str(LiteralVar.create(s)) for s in list_of_strs if isinstance(s, Var) or s
+ ]
+
+ if len(list_of_strs_filtered) == 1:
+ return list_of_strs_filtered[0]
+
+ return "(" + "+".join(list_of_strs_filtered) + ")"
+
+ @cached_property_no_lock
+ def _cached_get_all_var_data(self) -> VarData | None:
+ """Get all the VarData asVarDatae Var.
+
+ Returns:
+ The VarData associated with the Var.
+ """
+ return VarData.merge(
+ *[
+ var._get_all_var_data()
+ for var in self._var_value
+ if isinstance(var, Var)
+ ],
+ self._var_data,
+ )
+
+ @classmethod
+ def create(
+ cls,
+ *value: Var | str,
+ _var_data: VarData | None = None,
+ ) -> ConcatVarOperation:
+ """Create a var from a string value.
+
+ Args:
+ value: The values to concatenate.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The var.
+ """
+ return cls(
+ _js_expr="",
+ _var_type=str,
+ _var_data=_var_data,
+ _var_value=tuple(map(LiteralVar.create, value)),
+ )
+
+
+ARRAY_VAR_TYPE = TypeVar("ARRAY_VAR_TYPE", bound=Union[List, Tuple, Set])
+
+OTHER_TUPLE = TypeVar("OTHER_TUPLE")
+
+INNER_ARRAY_VAR = TypeVar("INNER_ARRAY_VAR")
+
+KEY_TYPE = TypeVar("KEY_TYPE")
+VALUE_TYPE = TypeVar("VALUE_TYPE")
+
+
+class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(list, tuple, set)):
+ """Base class for immutable array vars."""
+
+ @overload
+ def join(self, sep: StringVar | str = "") -> StringVar: ...
+
+ @overload
+ def join(self, sep: NoReturn) -> NoReturn: ...
+
+ def join(self, sep: Any = "") -> StringVar:
+ """Join the elements of the array.
+
+ Args:
+ sep: The separator between elements.
+
+ Returns:
+ The joined elements.
+ """
+ if not isinstance(sep, (StringVar, str)):
+ raise_unsupported_operand_types("join", (type(self), type(sep)))
+ if (
+ isinstance(self, LiteralArrayVar)
+ and (
+ len(
+ args := [
+ x
+ for x in self._var_value
+ if isinstance(x, (LiteralStringVar, str))
+ ]
+ )
+ == len(self._var_value)
+ )
+ and isinstance(sep, (LiteralStringVar, str))
+ ):
+ sep_str = sep._var_value if isinstance(sep, LiteralStringVar) else sep
+ return LiteralStringVar.create(
+ sep_str.join(
+ i._var_value if isinstance(i, LiteralStringVar) else i for i in args
+ )
+ )
+ return array_join_operation(self, sep)
+
+ def reverse(self) -> ArrayVar[ARRAY_VAR_TYPE]:
+ """Reverse the array.
+
+ Returns:
+ The reversed array.
+ """
+ return array_reverse_operation(self)
+
+ @overload
+ def __add__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> ArrayVar[ARRAY_VAR_TYPE]: ...
+
+ @overload
+ def __add__(self, other: NoReturn) -> NoReturn: ...
+
+ def __add__(self, other: Any) -> ArrayVar[ARRAY_VAR_TYPE]:
+ """Concatenate two arrays.
+
+ Parameters:
+ other: The other array to concatenate.
+
+ Returns:
+ ArrayConcatOperation: The concatenation of the two arrays.
+ """
+ if not isinstance(other, ArrayVar):
+ raise_unsupported_operand_types("+", (type(self), type(other)))
+
+ return array_concat_operation(self, other)
+
+ @overload
+ def __getitem__(self, i: slice) -> ArrayVar[ARRAY_VAR_TYPE]: ...
+
+ @overload
+ def __getitem__(
+ self: (
+ ArrayVar[Tuple[int, OTHER_TUPLE]]
+ | ArrayVar[Tuple[float, OTHER_TUPLE]]
+ | ArrayVar[Tuple[int | float, OTHER_TUPLE]]
+ ),
+ i: Literal[0, -2],
+ ) -> NumberVar: ...
+
+ @overload
+ def __getitem__(
+ self: (
+ ArrayVar[Tuple[Any, int]]
+ | ArrayVar[Tuple[Any, float]]
+ | ArrayVar[Tuple[Any, int | float]]
+ ),
+ i: Literal[1, -1],
+ ) -> NumberVar: ...
+
+ @overload
+ def __getitem__(
+ self: ArrayVar[Tuple[str, Any]], i: Literal[0, -2]
+ ) -> StringVar: ...
+
+ @overload
+ def __getitem__(
+ self: ArrayVar[Tuple[Any, str]], i: Literal[1, -1]
+ ) -> StringVar: ...
+
+ @overload
+ def __getitem__(
+ self: ArrayVar[Tuple[bool, Any]], i: Literal[0, -2]
+ ) -> BooleanVar: ...
+
+ @overload
+ def __getitem__(
+ self: ArrayVar[Tuple[Any, bool]], i: Literal[1, -1]
+ ) -> BooleanVar: ...
+
+ @overload
+ def __getitem__(
+ self: (
+ ARRAY_VAR_OF_LIST_ELEMENT[int]
+ | ARRAY_VAR_OF_LIST_ELEMENT[float]
+ | ARRAY_VAR_OF_LIST_ELEMENT[int | float]
+ ),
+ i: int | NumberVar,
+ ) -> NumberVar: ...
+
+ @overload
+ def __getitem__(
+ self: ARRAY_VAR_OF_LIST_ELEMENT[str], i: int | NumberVar
+ ) -> StringVar: ...
+
+ @overload
+ def __getitem__(
+ self: ARRAY_VAR_OF_LIST_ELEMENT[bool], i: int | NumberVar
+ ) -> BooleanVar: ...
+
+ @overload
+ def __getitem__(
+ self: ARRAY_VAR_OF_LIST_ELEMENT[List[INNER_ARRAY_VAR]],
+ i: int | NumberVar,
+ ) -> ArrayVar[List[INNER_ARRAY_VAR]]: ...
+
+ @overload
+ def __getitem__(
+ self: ARRAY_VAR_OF_LIST_ELEMENT[Set[INNER_ARRAY_VAR]],
+ i: int | NumberVar,
+ ) -> ArrayVar[Set[INNER_ARRAY_VAR]]: ...
+
+ @overload
+ def __getitem__(
+ self: ARRAY_VAR_OF_LIST_ELEMENT[Tuple[KEY_TYPE, VALUE_TYPE]],
+ i: int | NumberVar,
+ ) -> ArrayVar[Tuple[KEY_TYPE, VALUE_TYPE]]: ...
+
+ @overload
+ def __getitem__(
+ self: ARRAY_VAR_OF_LIST_ELEMENT[Tuple[INNER_ARRAY_VAR, ...]],
+ i: int | NumberVar,
+ ) -> ArrayVar[Tuple[INNER_ARRAY_VAR, ...]]: ...
+
+ @overload
+ def __getitem__(
+ self: ARRAY_VAR_OF_LIST_ELEMENT[Dict[KEY_TYPE, VALUE_TYPE]],
+ i: int | NumberVar,
+ ) -> ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]]: ...
+
+ @overload
+ def __getitem__(self, i: int | NumberVar) -> Var: ...
+
+ def __getitem__(self, i: Any) -> ArrayVar[ARRAY_VAR_TYPE] | Var:
+ """Get a slice of the array.
+
+ Args:
+ i: The slice.
+
+ Returns:
+ The array slice operation.
+ """
+ if isinstance(i, slice):
+ return ArraySliceOperation.create(self, i)
+ if not isinstance(i, (int, NumberVar)) or (
+ isinstance(i, NumberVar) and i._is_strict_float()
+ ):
+ raise_unsupported_operand_types("[]", (type(self), type(i)))
+ return array_item_operation(self, i)
+
+ def length(self) -> NumberVar:
+ """Get the length of the array.
+
+ Returns:
+ The length of the array.
+ """
+ return array_length_operation(self)
+
+ @overload
+ @classmethod
+ def range(cls, stop: int | NumberVar, /) -> ArrayVar[List[int]]: ...
+
+ @overload
+ @classmethod
+ def range(
+ cls,
+ start: int | NumberVar,
+ end: int | NumberVar,
+ step: int | NumberVar = 1,
+ /,
+ ) -> ArrayVar[List[int]]: ...
+
+ @overload
+ @classmethod
+ def range(
+ cls,
+ first_endpoint: int | NumberVar,
+ second_endpoint: int | NumberVar | None = None,
+ step: int | NumberVar | None = None,
+ ) -> ArrayVar[List[int]]: ...
+
+ @classmethod
+ def range(
+ cls,
+ first_endpoint: int | NumberVar,
+ second_endpoint: int | NumberVar | None = None,
+ step: int | NumberVar | None = None,
+ ) -> ArrayVar[List[int]]:
+ """Create a range of numbers.
+
+ Args:
+ first_endpoint: The end of the range if second_endpoint is not provided, otherwise the start of the range.
+ second_endpoint: The end of the range.
+ step: The step of the range.
+
+ Returns:
+ The range of numbers.
+ """
+ if any(
+ not isinstance(i, (int, NumberVar))
+ for i in (first_endpoint, second_endpoint, step)
+ if i is not None
+ ):
+ raise_unsupported_operand_types(
+ "range", (type(first_endpoint), type(second_endpoint), type(step))
+ )
+ if second_endpoint is None:
+ start = 0
+ end = first_endpoint
+ else:
+ start = first_endpoint
+ end = second_endpoint
+
+ return array_range_operation(start, end, step or 1)
+
+ @overload
+ def contains(self, other: Any) -> BooleanVar: ...
+
+ @overload
+ def contains(self, other: Any, field: StringVar | str) -> BooleanVar: ...
+
+ def contains(self, other: Any, field: Any = None) -> BooleanVar:
+ """Check if the array contains an element.
+
+ Args:
+ other: The element to check for.
+ field: The field to check.
+
+ Returns:
+ The array contains operation.
+ """
+ if field is not None:
+ if not isinstance(field, (StringVar, str)):
+ raise_unsupported_operand_types("contains", (type(self), type(field)))
+ return array_contains_field_operation(self, other, field)
+ return array_contains_operation(self, other)
+
+ def pluck(self, field: StringVar | str) -> ArrayVar:
+ """Pluck a field from the array.
+
+ Args:
+ field: The field to pluck from the array.
+
+ Returns:
+ The array pluck operation.
+ """
+ return array_pluck_operation(self, field)
+
+ @overload
+ def __mul__(self, other: NumberVar | int) -> ArrayVar[ARRAY_VAR_TYPE]: ...
+
+ @overload
+ def __mul__(self, other: NoReturn) -> NoReturn: ...
+
+ def __mul__(self, other: Any) -> ArrayVar[ARRAY_VAR_TYPE]:
+ """Multiply the sequence by a number or integer.
+
+ Parameters:
+ other: The number or integer to multiply the sequence by.
+
+ Returns:
+ ArrayVar[ARRAY_VAR_TYPE]: The result of multiplying the sequence by the given number or integer.
+ """
+ if not isinstance(other, (NumberVar, int)) or (
+ isinstance(other, NumberVar) and other._is_strict_float()
+ ):
+ raise_unsupported_operand_types("*", (type(self), type(other)))
+
+ return repeat_array_operation(self, other)
+
+ __rmul__ = __mul__ # type: ignore
+
+ @overload
+ def __lt__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> BooleanVar: ...
+
+ @overload
+ def __lt__(self, other: list | tuple) -> BooleanVar: ...
+
+ def __lt__(self, other: Any):
+ """Check if the array is less than another array.
+
+ Args:
+ other: The other array.
+
+ Returns:
+ The array less than operation.
+ """
+ if not isinstance(other, (ArrayVar, list, tuple)):
+ raise_unsupported_operand_types("<", (type(self), type(other)))
+
+ return array_lt_operation(self, other)
+
+ @overload
+ def __gt__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> BooleanVar: ...
+
+ @overload
+ def __gt__(self, other: list | tuple) -> BooleanVar: ...
+
+ def __gt__(self, other: Any):
+ """Check if the array is greater than another array.
+
+ Args:
+ other: The other array.
+
+ Returns:
+ The array greater than operation.
+ """
+ if not isinstance(other, (ArrayVar, list, tuple)):
+ raise_unsupported_operand_types(">", (type(self), type(other)))
+
+ return array_gt_operation(self, other)
+
+ @overload
+ def __le__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> BooleanVar: ...
+
+ @overload
+ def __le__(self, other: list | tuple) -> BooleanVar: ...
+
+ def __le__(self, other: Any):
+ """Check if the array is less than or equal to another array.
+
+ Args:
+ other: The other array.
+
+ Returns:
+ The array less than or equal operation.
+ """
+ if not isinstance(other, (ArrayVar, list, tuple)):
+ raise_unsupported_operand_types("<=", (type(self), type(other)))
+
+ return array_le_operation(self, other)
+
+ @overload
+ def __ge__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> BooleanVar: ...
+
+ @overload
+ def __ge__(self, other: list | tuple) -> BooleanVar: ...
+
+ def __ge__(self, other: Any):
+ """Check if the array is greater than or equal to another array.
+
+ Args:
+ other: The other array.
+
+ Returns:
+ The array greater than or equal operation.
+ """
+ if not isinstance(other, (ArrayVar, list, tuple)):
+ raise_unsupported_operand_types(">=", (type(self), type(other)))
+
+ return array_ge_operation(self, other)
+
+ def foreach(self, fn: Any):
+ """Apply a function to each element of the array.
+
+ Args:
+ fn: The function to apply.
+
+ Returns:
+ The array after applying the function.
+
+ Raises:
+ VarTypeError: If the function takes more than one argument.
+ """
+ from .function import ArgsFunctionOperation
+
+ if not callable(fn):
+ raise_unsupported_operand_types("foreach", (type(self), type(fn)))
+ # get the number of arguments of the function
+ num_args = len(inspect.signature(fn).parameters)
+ if num_args > 1:
+ raise VarTypeError(
+ "The function passed to foreach should take at most one argument."
+ )
+
+ if num_args == 0:
+ return_value = fn()
+ function_var = ArgsFunctionOperation.create((), return_value)
+ else:
+ # generic number var
+ number_var = Var("").to(NumberVar, int)
+
+ first_arg_type = self[number_var]._var_type
+
+ arg_name = get_unique_variable_name()
+
+ # get first argument type
+ first_arg = Var(
+ _js_expr=arg_name,
+ _var_type=first_arg_type,
+ ).guess_type()
+
+ function_var = ArgsFunctionOperation.create(
+ (arg_name,),
+ Var.create(fn(first_arg)),
+ )
+
+ return map_array_operation(self, function_var)
+
+
+LIST_ELEMENT = TypeVar("LIST_ELEMENT")
+
+ARRAY_VAR_OF_LIST_ELEMENT = Union[
+ ArrayVar[List[LIST_ELEMENT]],
+ ArrayVar[Set[LIST_ELEMENT]],
+ ArrayVar[Tuple[LIST_ELEMENT, ...]],
+]
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class LiteralArrayVar(CachedVarOperation, LiteralVar, ArrayVar[ARRAY_VAR_TYPE]):
+ """Base class for immutable literal array vars."""
+
+ _var_value: Union[
+ List[Union[Var, Any]],
+ Set[Union[Var, Any]],
+ Tuple[Union[Var, Any], ...],
+ ] = dataclasses.field(default_factory=list)
+
+ @cached_property_no_lock
+ def _cached_var_name(self) -> str:
+ """The name of the var.
+
+ Returns:
+ The name of the var.
+ """
+ return (
+ "["
+ + ", ".join(
+ [str(LiteralVar.create(element)) for element in self._var_value]
+ )
+ + "]"
+ )
+
+ @cached_property_no_lock
+ def _cached_get_all_var_data(self) -> VarData | None:
+ """Get all the VarData associated with the Var.
+
+ Returns:
+ The VarData associated with the Var.
+ """
+ return VarData.merge(
+ *[
+ LiteralVar.create(element)._get_all_var_data()
+ for element in self._var_value
+ ],
+ self._var_data,
+ )
+
+ def __hash__(self) -> int:
+ """Get the hash of the var.
+
+ Returns:
+ The hash of the var.
+ """
+ return hash((self.__class__.__name__, self._js_expr))
+
+ def json(self) -> str:
+ """Get the JSON representation of the var.
+
+ Returns:
+ The JSON representation of the var.
+ """
+ return (
+ "["
+ + ", ".join(
+ [LiteralVar.create(element).json() for element in self._var_value]
+ )
+ + "]"
+ )
+
+ @classmethod
+ def create(
+ cls,
+ value: ARRAY_VAR_TYPE,
+ _var_type: Type[ARRAY_VAR_TYPE] | None = None,
+ _var_data: VarData | None = None,
+ ) -> LiteralArrayVar[ARRAY_VAR_TYPE]:
+ """Create a var from a string value.
+
+ Args:
+ value: The value to create the var from.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The var.
+ """
+ return cls(
+ _js_expr="",
+ _var_type=figure_out_type(value) if _var_type is None else _var_type,
+ _var_data=_var_data,
+ _var_value=value,
+ )
+
+
+@var_operation
+def string_split_operation(string: StringVar[Any], sep: StringVar | str = ""):
+ """Split a string.
+
+ Args:
+ string: The string to split.
+ sep: The separator.
+
+ Returns:
+ The split string.
+ """
+ return var_operation_return(
+ js_expression=f"{string}.split({sep})", var_type=List[str]
+ )
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class ArraySliceOperation(CachedVarOperation, ArrayVar):
+ """Base class for immutable string vars that are the result of a string slice operation."""
+
+ _array: ArrayVar = dataclasses.field(
+ default_factory=lambda: LiteralArrayVar.create([])
+ )
+ _start: NumberVar | int = dataclasses.field(default_factory=lambda: 0)
+ _stop: NumberVar | int = dataclasses.field(default_factory=lambda: 0)
+ _step: NumberVar | int = dataclasses.field(default_factory=lambda: 1)
+
+ @cached_property_no_lock
+ def _cached_var_name(self) -> str:
+ """The name of the var.
+
+ Returns:
+ The name of the var.
+
+ Raises:
+ ValueError: If the slice step is zero.
+ """
+ start, end, step = self._start, self._stop, self._step
+
+ normalized_start = (
+ LiteralVar.create(start) if start is not None else Var(_js_expr="undefined")
+ )
+ normalized_end = (
+ LiteralVar.create(end) if end is not None else Var(_js_expr="undefined")
+ )
+ if step is None:
+ return f"{self._array!s}.slice({normalized_start!s}, {normalized_end!s})"
+ if not isinstance(step, Var):
+ if step < 0:
+ actual_start = end + 1 if end is not None else 0
+ actual_end = start + 1 if start is not None else self._array.length()
+ return str(self._array[actual_start:actual_end].reverse()[::-step])
+ if step == 0:
+ raise ValueError("slice step cannot be zero")
+ return f"{self._array!s}.slice({normalized_start!s}, {normalized_end!s}).filter((_, i) => i % {step!s} === 0)"
+
+ actual_start_reverse = end + 1 if end is not None else 0
+ actual_end_reverse = start + 1 if start is not None else self._array.length()
+
+ return f"{self.step!s} > 0 ? {self._array!s}.slice({normalized_start!s}, {normalized_end!s}).filter((_, i) => i % {step!s} === 0) : {self._array!s}.slice({actual_start_reverse!s}, {actual_end_reverse!s}).reverse().filter((_, i) => i % {-step!s} === 0)"
+
+ @classmethod
+ def create(
+ cls,
+ array: ArrayVar,
+ slice: slice,
+ _var_data: VarData | None = None,
+ ) -> ArraySliceOperation:
+ """Create a var from a string value.
+
+ Args:
+ array: The array.
+ slice: The slice.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The var.
+ """
+ return cls(
+ _js_expr="",
+ _var_type=array._var_type,
+ _var_data=_var_data,
+ _array=array,
+ _start=slice.start,
+ _stop=slice.stop,
+ _step=slice.step,
+ )
+
+
+@var_operation
+def array_pluck_operation(
+ array: ArrayVar[ARRAY_VAR_TYPE],
+ field: StringVar | str,
+) -> CustomVarOperationReturn[ARRAY_VAR_TYPE]:
+ """Pluck a field from an array of objects.
+
+ Args:
+ array: The array to pluck from.
+ field: The field to pluck from the objects in the array.
+
+ Returns:
+ The reversed array.
+ """
+ return var_operation_return(
+ js_expression=f"{array}.map(e=>e?.[{field}])",
+ var_type=array._var_type,
+ )
+
+
+@var_operation
+def array_reverse_operation(
+ array: ArrayVar[ARRAY_VAR_TYPE],
+) -> CustomVarOperationReturn[ARRAY_VAR_TYPE]:
+ """Reverse an array.
+
+ Args:
+ array: The array to reverse.
+
+ Returns:
+ The reversed array.
+ """
+ return var_operation_return(
+ js_expression=f"{array}.slice().reverse()",
+ var_type=array._var_type,
+ )
+
+
+@var_operation
+def array_lt_operation(lhs: ArrayVar | list | tuple, rhs: ArrayVar | list | tuple):
+ """Check if an array is less than another array.
+
+ Args:
+ lhs: The left-hand side array.
+ rhs: The right-hand side array.
+
+ Returns:
+ The array less than operation.
+ """
+ return var_operation_return(js_expression=f"{lhs} < {rhs}", var_type=bool)
+
+
+@var_operation
+def array_gt_operation(lhs: ArrayVar | list | tuple, rhs: ArrayVar | list | tuple):
+ """Check if an array is greater than another array.
+
+ Args:
+ lhs: The left-hand side array.
+ rhs: The right-hand side array.
+
+ Returns:
+ The array greater than operation.
+ """
+ return var_operation_return(js_expression=f"{lhs} > {rhs}", var_type=bool)
+
+
+@var_operation
+def array_le_operation(lhs: ArrayVar | list | tuple, rhs: ArrayVar | list | tuple):
+ """Check if an array is less than or equal to another array.
+
+ Args:
+ lhs: The left-hand side array.
+ rhs: The right-hand side array.
+
+ Returns:
+ The array less than or equal operation.
+ """
+ return var_operation_return(js_expression=f"{lhs} <= {rhs}", var_type=bool)
+
+
+@var_operation
+def array_ge_operation(lhs: ArrayVar | list | tuple, rhs: ArrayVar | list | tuple):
+ """Check if an array is greater than or equal to another array.
+
+ Args:
+ lhs: The left-hand side array.
+ rhs: The right-hand side array.
+
+ Returns:
+ The array greater than or equal operation.
+ """
+ return var_operation_return(js_expression=f"{lhs} >= {rhs}", var_type=bool)
+
+
+@var_operation
+def array_length_operation(array: ArrayVar):
+ """Get the length of an array.
+
+ Args:
+ array: The array.
+
+ Returns:
+ The length of the array.
+ """
+ return var_operation_return(
+ js_expression=f"{array}.length",
+ var_type=int,
+ )
+
+
+def is_tuple_type(t: GenericType) -> bool:
+ """Check if a type is a tuple type.
+
+ Args:
+ t: The type to check.
+
+ Returns:
+ Whether the type is a tuple type.
+ """
+ if inspect.isclass(t):
+ return issubclass(t, tuple)
+ return get_origin(t) is tuple
+
+
+@var_operation
+def array_item_operation(array: ArrayVar, index: NumberVar | int):
+ """Get an item from an array.
+
+ Args:
+ array: The array.
+ index: The index of the item.
+
+ Returns:
+ The item from the array.
+ """
+ args = typing.get_args(array._var_type)
+ if args and isinstance(index, LiteralNumberVar) and is_tuple_type(array._var_type):
+ index_value = int(index._var_value)
+ element_type = args[index_value % len(args)]
+ else:
+ element_type = unionize(*args)
+
+ return var_operation_return(
+ js_expression=f"{array!s}.at({index!s})",
+ var_type=element_type,
+ )
+
+
+@var_operation
+def array_range_operation(
+ start: NumberVar | int, stop: NumberVar | int, step: NumberVar | int
+):
+ """Create a range of numbers.
+
+ Args:
+ start: The start of the range.
+ stop: The end of the range.
+ step: The step of the range.
+
+ Returns:
+ The range of numbers.
+ """
+ return var_operation_return(
+ js_expression=f"Array.from({{ length: ({stop!s} - {start!s}) / {step!s} }}, (_, i) => {start!s} + i * {step!s})",
+ var_type=List[int],
+ )
+
+
+@var_operation
+def array_contains_field_operation(
+ haystack: ArrayVar, needle: Any | Var, field: StringVar | str
+):
+ """Check if an array contains an element.
+
+ Args:
+ haystack: The array to check.
+ needle: The element to check for.
+ field: The field to check.
+
+ Returns:
+ The array contains operation.
+ """
+ return var_operation_return(
+ js_expression=f"{haystack}.some(obj => obj[{field}] === {needle})",
+ var_type=bool,
+ )
+
+
+@var_operation
+def array_contains_operation(haystack: ArrayVar, needle: Any | Var):
+ """Check if an array contains an element.
+
+ Args:
+ haystack: The array to check.
+ needle: The element to check for.
+
+ Returns:
+ The array contains operation.
+ """
+ return var_operation_return(
+ js_expression=f"{haystack}.includes({needle})",
+ var_type=bool,
+ )
+
+
+@var_operation
+def repeat_array_operation(
+ array: ArrayVar[ARRAY_VAR_TYPE], count: NumberVar | int
+) -> CustomVarOperationReturn[ARRAY_VAR_TYPE]:
+ """Repeat an array a number of times.
+
+ Args:
+ array: The array to repeat.
+ count: The number of times to repeat the array.
+
+ Returns:
+ The repeated array.
+ """
+ return var_operation_return(
+ js_expression=f"Array.from({{ length: {count} }}).flatMap(() => {array})",
+ var_type=array._var_type,
+ )
+
+
+if TYPE_CHECKING:
+ from .function import FunctionVar
+
+
+@var_operation
+def map_array_operation(
+ array: ArrayVar[ARRAY_VAR_TYPE],
+ function: FunctionVar,
+):
+ """Map a function over an array.
+
+ Args:
+ array: The array.
+ function: The function to map.
+
+ Returns:
+ The mapped array.
+ """
+ return var_operation_return(
+ js_expression=f"{array}.map({function})", var_type=List[Any]
+ )
+
+
+@var_operation
+def array_concat_operation(
+ lhs: ArrayVar[ARRAY_VAR_TYPE], rhs: ArrayVar[ARRAY_VAR_TYPE]
+) -> CustomVarOperationReturn[ARRAY_VAR_TYPE]:
+ """Concatenate two arrays.
+
+ Args:
+ lhs: The left-hand side array.
+ rhs: The right-hand side array.
+
+ Returns:
+ The concatenated array.
+ """
+ return var_operation_return(
+ js_expression=f"[...{lhs}, ...{rhs}]",
+ var_type=Union[lhs._var_type, rhs._var_type],
+ )
+
+
+class ColorVar(StringVar[Color], python_types=Color):
+ """Base class for immutable color vars."""
+
+
+@dataclasses.dataclass(
+ eq=False,
+ frozen=True,
+ **{"slots": True} if sys.version_info >= (3, 10) else {},
+)
+class LiteralColorVar(CachedVarOperation, LiteralVar, ColorVar):
+ """Base class for immutable literal color vars."""
+
+ _var_value: Color = dataclasses.field(default_factory=lambda: Color(color="black"))
+
+ @classmethod
+ def create(
+ cls,
+ value: Color,
+ _var_type: Type[Color] | None = None,
+ _var_data: VarData | None = None,
+ ) -> ColorVar:
+ """Create a var from a string value.
+
+ Args:
+ value: The value to create the var from.
+ _var_type: The type of the var.
+ _var_data: Additional hooks and imports associated with the Var.
+
+ Returns:
+ The var.
+ """
+ return cls(
+ _js_expr="",
+ _var_type=_var_type or Color,
+ _var_data=_var_data,
+ _var_value=value,
+ )
+
+ def __hash__(self) -> int:
+ """Get the hash of the var.
+
+ Returns:
+ The hash of the var.
+ """
+ return hash(
+ (
+ self.__class__.__name__,
+ self._var_value.color,
+ self._var_value.alpha,
+ self._var_value.shade,
+ )
+ )
+
+ @cached_property_no_lock
+ def _cached_var_name(self) -> str:
+ """The name of the var.
+
+ Returns:
+ The name of the var.
+ """
+ alpha = self._var_value.alpha
+ alpha = (
+ ternary_operation(
+ alpha,
+ LiteralStringVar.create("a"),
+ LiteralStringVar.create(""),
+ )
+ if isinstance(alpha, Var)
+ else LiteralStringVar.create("a" if alpha else "")
+ )
+
+ shade = self._var_value.shade
+ shade = (
+ shade.to_string(use_json=False)
+ if isinstance(shade, Var)
+ else LiteralStringVar.create(str(shade))
+ )
+ return str(
+ ConcatVarOperation.create(
+ LiteralStringVar.create("var(--"),
+ self._var_value.color,
+ LiteralStringVar.create("-"),
+ alpha,
+ shade,
+ LiteralStringVar.create(")"),
+ )
+ )
+
+ @cached_property_no_lock
+ def _cached_get_all_var_data(self) -> VarData | None:
+ """Get all the var data.
+
+ Returns:
+ The var data.
+ """
+ return VarData.merge(
+ *[
+ LiteralVar.create(var)._get_all_var_data()
+ for var in (
+ self._var_value.color,
+ self._var_value.alpha,
+ self._var_value.shade,
+ )
+ ],
+ self._var_data,
+ )
+
+ def json(self) -> str:
+ """Get the JSON representation of the var.
+
+ Returns:
+ The JSON representation of the var.
+
+ Raises:
+ TypeError: If the color is not a valid color.
+ """
+ color, alpha, shade = map(
+ get_python_literal,
+ (self._var_value.color, self._var_value.alpha, self._var_value.shade),
+ )
+ if color is None or alpha is None or shade is None:
+ raise TypeError("Cannot serialize color that contains non-literal vars.")
+ if (
+ not isinstance(color, str)
+ or not isinstance(alpha, bool)
+ or not isinstance(shade, int)
+ ):
+ raise TypeError("Color is not a valid color.")
+ return f"var(--{color}-{'a' if alpha else ''}{shade})"
diff --git a/scripts/bun_install.sh b/scripts/bun_install.sh
new file mode 100644
index 000000000..08a0817f6
--- /dev/null
+++ b/scripts/bun_install.sh
@@ -0,0 +1,311 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+platform=$(uname -ms)
+
+if [[ ${OS:-} = Windows_NT ]]; then
+ if [[ $platform != MINGW64* ]]; then
+ powershell -c "irm bun.sh/install.ps1|iex"
+ exit $?
+ fi
+fi
+
+# Reset
+Color_Off=''
+
+# Regular Colors
+Red=''
+Green=''
+Dim='' # White
+
+# Bold
+Bold_White=''
+Bold_Green=''
+
+if [[ -t 1 ]]; then
+ # Reset
+ Color_Off='\033[0m' # Text Reset
+
+ # Regular Colors
+ Red='\033[0;31m' # Red
+ Green='\033[0;32m' # Green
+ Dim='\033[0;2m' # White
+
+ # Bold
+ Bold_Green='\033[1;32m' # Bold Green
+ Bold_White='\033[1m' # Bold White
+fi
+
+error() {
+ echo -e "${Red}error${Color_Off}:" "$@" >&2
+ exit 1
+}
+
+info() {
+ echo -e "${Dim}$@ ${Color_Off}"
+}
+
+info_bold() {
+ echo -e "${Bold_White}$@ ${Color_Off}"
+}
+
+success() {
+ echo -e "${Green}$@ ${Color_Off}"
+}
+
+command -v unzip >/dev/null ||
+ error 'unzip is required to install bun'
+
+if [[ $# -gt 2 ]]; then
+ error 'Too many arguments, only 2 are allowed. The first can be a specific tag of bun to install. (e.g. "bun-v0.1.4") The second can be a build variant of bun to install. (e.g. "debug-info")'
+fi
+
+case $platform in
+'Darwin x86_64')
+ target=darwin-x64
+ ;;
+'Darwin arm64')
+ target=darwin-aarch64
+ ;;
+'Linux aarch64' | 'Linux arm64')
+ target=linux-aarch64
+ ;;
+'MINGW64'*)
+ target=windows-x64
+ ;;
+'Linux x86_64' | *)
+ target=linux-x64
+ ;;
+esac
+
+if [[ $target = darwin-x64 ]]; then
+ # Is this process running in Rosetta?
+ # redirect stderr to devnull to avoid error message when not running in Rosetta
+ if [[ $(sysctl -n sysctl.proc_translated 2>/dev/null) = 1 ]]; then
+ target=darwin-aarch64
+ info "Your shell is running in Rosetta 2. Downloading bun for $target instead"
+ fi
+fi
+
+GITHUB=${GITHUB-"https://github.com"}
+
+github_repo="$GITHUB/oven-sh/bun"
+
+if [[ $target = darwin-x64 ]]; then
+ # If AVX2 isn't supported, use the -baseline build
+ if [[ $(sysctl -a | grep machdep.cpu | grep AVX2) == '' ]]; then
+ target=darwin-x64-baseline
+ fi
+fi
+
+if [[ $target = linux-x64 ]]; then
+ # If AVX2 isn't supported, use the -baseline build
+ if [[ $(cat /proc/cpuinfo | grep avx2) = '' ]]; then
+ target=linux-x64-baseline
+ fi
+fi
+
+exe_name=bun
+
+if [[ $# = 2 && $2 = debug-info ]]; then
+ target=$target-profile
+ exe_name=bun-profile
+ info "You requested a debug build of bun. More information will be shown if a crash occurs."
+fi
+
+if [[ $# = 0 ]]; then
+ bun_uri=$github_repo/releases/latest/download/bun-$target.zip
+else
+ bun_uri=$github_repo/releases/download/$1/bun-$target.zip
+fi
+
+install_env=BUN_INSTALL
+bin_env=\$$install_env/bin
+
+install_dir=${!install_env:-$HOME/.bun}
+bin_dir=$install_dir/bin
+exe=$bin_dir/bun
+
+if [[ ! -d $bin_dir ]]; then
+ mkdir -p "$bin_dir" ||
+ error "Failed to create install directory \"$bin_dir\""
+fi
+
+curl --fail --location --progress-bar --output "$exe.zip" "$bun_uri" ||
+ error "Failed to download bun from \"$bun_uri\""
+
+unzip -oqd "$bin_dir" "$exe.zip" ||
+ error 'Failed to extract bun'
+
+mv "$bin_dir/bun-$target/$exe_name" "$exe" ||
+ error 'Failed to move extracted bun to destination'
+
+chmod +x "$exe" ||
+ error 'Failed to set permissions on bun executable'
+
+rm -r "$bin_dir/bun-$target" "$exe.zip"
+
+tildify() {
+ if [[ $1 = $HOME/* ]]; then
+ local replacement=\~/
+
+ echo "${1/$HOME\//$replacement}"
+ else
+ echo "$1"
+ fi
+}
+
+success "bun was installed successfully to $Bold_Green$(tildify "$exe")"
+
+if command -v bun >/dev/null; then
+ # Install completions, but we don't care if it fails
+ IS_BUN_AUTO_UPDATE=true $exe completions &>/dev/null || :
+
+ echo "Run 'bun --help' to get started"
+ exit
+fi
+
+refresh_command=''
+
+tilde_bin_dir=$(tildify "$bin_dir")
+quoted_install_dir=\"${install_dir//\"/\\\"}\"
+
+if [[ $quoted_install_dir = \"$HOME/* ]]; then
+ quoted_install_dir=${quoted_install_dir/$HOME\//\$HOME/}
+fi
+
+echo
+
+case $(basename "$SHELL") in
+fish)
+ # Install completions, but we don't care if it fails
+ IS_BUN_AUTO_UPDATE=true SHELL=fish $exe completions &>/dev/null || :
+
+ commands=(
+ "set --export $install_env $quoted_install_dir"
+ "set --export PATH $bin_env \$PATH"
+ )
+
+ fish_config=$HOME/.config/fish/config.fish
+ tilde_fish_config=$(tildify "$fish_config")
+
+ if [[ -w $fish_config ]]; then
+ {
+ echo -e '\n# bun'
+
+ for command in "${commands[@]}"; do
+ echo "$command"
+ done
+ } >>"$fish_config"
+
+ info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_fish_config\""
+
+ refresh_command="source $tilde_fish_config"
+ else
+ echo "Manually add the directory to $tilde_fish_config (or similar):"
+
+ for command in "${commands[@]}"; do
+ info_bold " $command"
+ done
+ fi
+ ;;
+zsh)
+ # Install completions, but we don't care if it fails
+ IS_BUN_AUTO_UPDATE=true SHELL=zsh $exe completions &>/dev/null || :
+
+ commands=(
+ "export $install_env=$quoted_install_dir"
+ "export PATH=\"$bin_env:\$PATH\""
+ )
+
+ zsh_config=$HOME/.zshrc
+ tilde_zsh_config=$(tildify "$zsh_config")
+
+ if [[ -w $zsh_config ]]; then
+ {
+ echo -e '\n# bun'
+
+ for command in "${commands[@]}"; do
+ echo "$command"
+ done
+ } >>"$zsh_config"
+
+ info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_zsh_config\""
+
+ refresh_command="exec $SHELL"
+ else
+ echo "Manually add the directory to $tilde_zsh_config (or similar):"
+
+ for command in "${commands[@]}"; do
+ info_bold " $command"
+ done
+ fi
+ ;;
+bash)
+ # Install completions, but we don't care if it fails
+ IS_BUN_AUTO_UPDATE=true SHELL=bash $exe completions &>/dev/null || :
+
+ commands=(
+ "export $install_env=$quoted_install_dir"
+ "export PATH=\"$bin_env:\$PATH\""
+ )
+
+ bash_configs=(
+ "$HOME/.bashrc"
+ "$HOME/.bash_profile"
+ )
+
+ if [[ ${XDG_CONFIG_HOME:-} ]]; then
+ bash_configs+=(
+ "$XDG_CONFIG_HOME/.bash_profile"
+ "$XDG_CONFIG_HOME/.bashrc"
+ "$XDG_CONFIG_HOME/bash_profile"
+ "$XDG_CONFIG_HOME/bashrc"
+ )
+ fi
+
+ set_manually=true
+ for bash_config in "${bash_configs[@]}"; do
+ tilde_bash_config=$(tildify "$bash_config")
+
+ if [[ -w $bash_config ]]; then
+ {
+ echo -e '\n# bun'
+
+ for command in "${commands[@]}"; do
+ echo "$command"
+ done
+ } >>"$bash_config"
+
+ info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_bash_config\""
+
+ refresh_command="source $bash_config"
+ set_manually=false
+ break
+ fi
+ done
+
+ if [[ $set_manually = true ]]; then
+ echo "Manually add the directory to $tilde_bash_config (or similar):"
+
+ for command in "${commands[@]}"; do
+ info_bold " $command"
+ done
+ fi
+ ;;
+*)
+ echo 'Manually add the directory to ~/.bashrc (or similar):'
+ info_bold " export $install_env=$quoted_install_dir"
+ info_bold " export PATH=\"$bin_env:\$PATH\""
+ ;;
+esac
+
+echo
+info "To get started, run:"
+echo
+
+if [[ $refresh_command ]]; then
+ info_bold " $refresh_command"
+fi
+
+info_bold " bun --help"
diff --git a/scripts/migrate_project_to_rx_chakra.py b/scripts/migrate_project_to_rx_chakra.py
deleted file mode 100644
index b13cccafd..000000000
--- a/scripts/migrate_project_to_rx_chakra.py
+++ /dev/null
@@ -1,13 +0,0 @@
-"""Migrate project to rx.chakra. I.e. switch usage of rx. to rx.chakra.."""
-
-import argparse
-
-if __name__ == "__main__":
- # parse args just for the help message (-h, etc)
- parser = argparse.ArgumentParser(
- description="Migrate project to rx.chakra. I.e. switch usage of rx. to rx.chakra.."
- )
- args = parser.parse_args()
- from reflex.utils.prerequisites import migrate_to_rx_chakra
-
- migrate_to_rx_chakra()
diff --git a/scripts/wait_for_listening_port.py b/scripts/wait_for_listening_port.py
index 247ff4fba..857ee7c6d 100644
--- a/scripts/wait_for_listening_port.py
+++ b/scripts/wait_for_listening_port.py
@@ -49,11 +49,10 @@ def main():
parser.add_argument("--server-pid", type=int)
args = parser.parse_args()
executor = ThreadPoolExecutor(max_workers=len(args.port))
- futures = []
- for p in args.port:
- futures.append(
- executor.submit(_wait_for_port, p, args.server_pid, args.timeout)
- )
+ futures = [
+ executor.submit(_wait_for_port, p, args.server_pid, args.timeout)
+ for p in args.port
+ ]
for f in as_completed(futures):
ok, msg = f.result()
if ok:
diff --git a/tests/components/core/test_colors.py b/tests/components/core/test_colors.py
deleted file mode 100644
index 0c14c8a7c..000000000
--- a/tests/components/core/test_colors.py
+++ /dev/null
@@ -1,125 +0,0 @@
-import pytest
-
-import reflex as rx
-from reflex.components.datadisplay.code import CodeBlock
-from reflex.constants.colors import Color
-from reflex.vars import Var
-
-
-class ColorState(rx.State):
- """Test color state."""
-
- color: str = "mint"
- color_part: str = "tom"
- shade: int = 4
-
-
-color_state_name = ColorState.get_full_name().replace(".", "__")
-
-
-def create_color_var(color):
- return Var.create(color)
-
-
-@pytest.mark.parametrize(
- "color, expected",
- [
- (create_color_var(rx.color("mint")), "var(--mint-7)"),
- (create_color_var(rx.color("mint", 3)), "var(--mint-3)"),
- (create_color_var(rx.color("mint", 3, True)), "var(--mint-a3)"),
- (
- create_color_var(rx.color(ColorState.color, ColorState.shade)), # type: ignore
- f"var(--${{{color_state_name}.color}}-${{{color_state_name}.shade}})",
- ),
- (
- create_color_var(rx.color(f"{ColorState.color}", f"{ColorState.shade}")), # type: ignore
- f"var(--${{{color_state_name}.color}}-${{{color_state_name}.shade}})",
- ),
- (
- create_color_var(
- rx.color(f"{ColorState.color_part}ato", f"{ColorState.shade}") # type: ignore
- ),
- f"var(--${{{color_state_name}.color_part}}ato-${{{color_state_name}.shade}})",
- ),
- (
- create_color_var(f'{rx.color(ColorState.color, f"{ColorState.shade}")}'), # type: ignore
- f"var(--${{{color_state_name}.color}}-${{{color_state_name}.shade}})",
- ),
- (
- create_color_var(
- f'{rx.color(f"{ColorState.color}", f"{ColorState.shade}")}' # type: ignore
- ),
- f"var(--${{{color_state_name}.color}}-${{{color_state_name}.shade}})",
- ),
- ],
-)
-def test_color(color, expected):
- assert color._var_is_string or color._var_type is str
- assert color._var_full_name == expected
- if color._var_type == Color:
- assert str(color) == f"{{`{expected}`}}"
- else:
- assert str(color) == expected
-
-
-@pytest.mark.parametrize(
- "cond_var, expected",
- [
- (
- rx.cond(True, rx.color("mint"), rx.color("tomato", 5)),
- "{isTrue(true) ? `var(--mint-7)` : `var(--tomato-5)`}",
- ),
- (
- rx.cond(True, rx.color(ColorState.color), rx.color(ColorState.color, 5)), # type: ignore
- f"{{isTrue(true) ? `var(--${{{color_state_name}.color}}-7)` : `var(--${{{color_state_name}.color}}-5)`}}",
- ),
- (
- rx.match(
- "condition",
- ("first", rx.color("mint")),
- ("second", rx.color("tomato", 5)),
- rx.color(ColorState.color, 2), # type: ignore
- ),
- "{(() => { switch (JSON.stringify(`condition`)) {case JSON.stringify(`first`): return (`var(--mint-7)`);"
- " break;case JSON.stringify(`second`): return (`var(--tomato-5)`); break;default: "
- f"return (`var(--${{{color_state_name}.color}}-2)`); break;}};}})()}}",
- ),
- (
- rx.match(
- "condition",
- ("first", rx.color(ColorState.color)), # type: ignore
- ("second", rx.color(ColorState.color, 5)), # type: ignore
- rx.color(ColorState.color, 2), # type: ignore
- ),
- "{(() => { switch (JSON.stringify(`condition`)) {case JSON.stringify(`first`): "
- f"return (`var(--${{{color_state_name}.color}}-7)`); break;case JSON.stringify(`second`): "
- f"return (`var(--${{{color_state_name}.color}}-5)`); break;default: "
- f"return (`var(--${{{color_state_name}.color}}-2)`); break;}};}})()}}",
- ),
- ],
-)
-def test_color_with_conditionals(cond_var, expected):
- assert str(cond_var) == expected
-
-
-@pytest.mark.parametrize(
- "color, expected",
- [
- (create_color_var(rx.color("red")), "{`var(--red-7)`}"),
- (create_color_var(rx.color("green", shade=1)), "{`var(--green-1)`}"),
- (create_color_var(rx.color("blue", alpha=True)), "{`var(--blue-a7)`}"),
- ("red", "red"),
- ("green", "green"),
- ("blue", "blue"),
- ],
-)
-def test_radix_color(color, expected):
- """Test that custom_style can accept both string
- literals and rx.color inputs.
-
- Args:
- color (Color): A Color made with rx.color
- expected (str): The expected custom_style string, radix or literal
- """
- code_block = CodeBlock.create("Hello World", background_color=color)
- assert code_block.custom_style["backgroundColor"].__format__("") == expected # type: ignore
diff --git a/tests/components/core/test_html.py b/tests/components/core/test_html.py
deleted file mode 100644
index 325bdcaf9..000000000
--- a/tests/components/core/test_html.py
+++ /dev/null
@@ -1,22 +0,0 @@
-import pytest
-
-from reflex.components.core.html import Html
-
-
-def test_html_no_children():
- with pytest.raises(ValueError):
- _ = Html.create()
-
-
-def test_html_many_children():
- with pytest.raises(ValueError):
- _ = Html.create("foo", "bar")
-
-
-def test_html_create():
- html = Html.create("Hello !
")
- assert str(html.dangerouslySetInnerHTML) == '{"__html": "Hello !
"}' # type: ignore
- assert (
- str(html)
- == 'Hello !"}}/>'
- )
diff --git a/tests/components/datadisplay/test_code.py b/tests/components/datadisplay/test_code.py
deleted file mode 100644
index 64452e90c..000000000
--- a/tests/components/datadisplay/test_code.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import pytest
-
-from reflex.components.datadisplay.code import CodeBlock
-
-
-@pytest.mark.parametrize(
- "theme, expected", [("light", "one-light"), ("dark", "one-dark")]
-)
-def test_code_light_dark_theme(theme, expected):
- code_block = CodeBlock.create(theme=theme)
-
- assert code_block.theme._var_name == expected # type: ignore
-
-
-def generate_custom_code(language, expected_case):
- return f"SyntaxHighlighter.registerLanguage('{language}', {expected_case})"
-
-
-@pytest.mark.parametrize(
- "language, expected_case",
- [
- ("python", "python"),
- ("firestore-security-rules", "firestoreSecurityRules"),
- ("typescript", "typescript"),
- ],
-)
-def test_get_custom_code(language, expected_case):
- code_block = CodeBlock.create(language=language)
- assert code_block._get_custom_code() == generate_custom_code(
- language, expected_case
- )
diff --git a/tests/components/datadisplay/test_table.py b/tests/components/datadisplay/test_table.py
deleted file mode 100644
index 1cec624e9..000000000
--- a/tests/components/datadisplay/test_table.py
+++ /dev/null
@@ -1,177 +0,0 @@
-import sys
-from typing import List, Tuple
-
-import pytest
-
-from reflex.components.chakra.datadisplay.table import Tbody, Tfoot, Thead
-from reflex.state import BaseState
-
-PYTHON_GT_V38 = sys.version_info.major >= 3 and sys.version_info.minor > 8
-
-
-class TableState(BaseState):
- """Test State class."""
-
- rows_List_List_str: List[List[str]] = [["random", "row"]]
- rows_List_List: List[List] = [["random", "row"]]
- rows_List_str: List[str] = ["random", "row"]
- rows_Tuple_List_str: Tuple[List[str]] = (["random", "row"],)
- rows_Tuple_List: Tuple[List] = ["random", "row"] # type: ignore
- rows_Tuple_str_str: Tuple[str, str] = (
- "random",
- "row",
- )
- rows_Tuple_Tuple_str_str: Tuple[Tuple[str, str]] = (
- (
- "random",
- "row",
- ),
- )
- rows_Tuple_Tuple: Tuple[Tuple] = (
- (
- "random",
- "row",
- ),
- )
- rows_str: str = "random, row"
- headers_List_str: List[str] = ["header1", "header2"]
- headers_Tuple_str_str: Tuple[str, str] = (
- "header1",
- "header2",
- )
- headers_str: str = "headers1, headers2"
- footers_List_str: List[str] = ["footer1", "footer2"]
- footers_Tuple_str_str: Tuple[str, str] = (
- "footer1",
- "footer2",
- )
- footers_str: str = "footer1, footer2"
-
- if sys.version_info.major >= 3 and sys.version_info.minor > 8:
- rows_list_list_str: list[list[str]] = [["random", "row"]]
- rows_list_list: list[list] = [["random", "row"]]
- rows_list_str: list[str] = ["random", "row"]
- rows_tuple_list_str: tuple[list[str]] = (["random", "row"],)
- rows_tuple_list: tuple[list] = ["random", "row"] # type: ignore
- rows_tuple_str_str: tuple[str, str] = (
- "random",
- "row",
- )
- rows_tuple_tuple_str_str: tuple[tuple[str, str]] = (
- (
- "random",
- "row",
- ),
- )
- rows_tuple_tuple: tuple[tuple] = (
- (
- "random",
- "row",
- ),
- )
-
-
-valid_extras = (
- [
- TableState.rows_list_list_str,
- TableState.rows_list_list,
- TableState.rows_tuple_list_str,
- TableState.rows_tuple_list,
- TableState.rows_tuple_tuple_str_str,
- TableState.rows_tuple_tuple,
- ]
- if PYTHON_GT_V38
- else []
-)
-invalid_extras = (
- [TableState.rows_list_str, TableState.rows_tuple_str_str] if PYTHON_GT_V38 else []
-)
-
-
-@pytest.mark.parametrize(
- "rows",
- [
- [["random", "row"]],
- TableState.rows_List_List_str,
- TableState.rows_List_List,
- TableState.rows_Tuple_List_str,
- TableState.rows_Tuple_List,
- TableState.rows_Tuple_Tuple_str_str,
- TableState.rows_Tuple_Tuple,
- *valid_extras,
- ],
-)
-def test_create_table_body_with_valid_rows_prop(rows):
- render_dict = Tbody.create(rows=rows).render()
- assert render_dict["name"] == "Tbody"
- assert len(render_dict["children"]) == 1
-
-
-@pytest.mark.parametrize(
- "rows",
- [
- ["random", "row"],
- "random, rows",
- TableState.rows_List_str,
- TableState.rows_Tuple_str_str,
- TableState.rows_str,
- *invalid_extras,
- ],
-)
-def test_create_table_body_with_invalid_rows_prop(rows):
- with pytest.raises(TypeError):
- Tbody.create(rows=rows)
-
-
-@pytest.mark.parametrize(
- "headers",
- [
- ["random", "header"],
- TableState.headers_List_str,
- TableState.headers_Tuple_str_str,
- ],
-)
-def test_create_table_head_with_valid_headers_prop(headers):
- render_dict = Thead.create(headers=headers).render()
- assert render_dict["name"] == "Thead"
- assert len(render_dict["children"]) == 1
- assert render_dict["children"][0]["name"] == "Tr"
-
-
-@pytest.mark.parametrize(
- "headers",
- [
- "random, header",
- TableState.headers_str,
- ],
-)
-def test_create_table_head_with_invalid_headers_prop(headers):
- with pytest.raises(TypeError):
- Thead.create(headers=headers)
-
-
-@pytest.mark.parametrize(
- "footers",
- [
- ["random", "footers"],
- TableState.footers_List_str,
- TableState.footers_Tuple_str_str,
- ],
-)
-def test_create_table_footer_with_valid_footers_prop(footers):
- render_dict = Tfoot.create(footers=footers).render()
- assert render_dict["name"] == "Tfoot"
- assert len(render_dict["children"]) == 1
- assert render_dict["children"][0]["name"] == "Tr"
-
-
-@pytest.mark.parametrize(
- "footers",
- [
- "random, footers",
- TableState.footers_str,
- ],
-)
-def test_create_table_footer_with_invalid_footers_prop(footers):
- with pytest.raises(TypeError):
- Tfoot.create(footers=footers)
diff --git a/tests/components/forms/test_uploads.py b/tests/components/forms/test_uploads.py
deleted file mode 100644
index f8856a20f..000000000
--- a/tests/components/forms/test_uploads.py
+++ /dev/null
@@ -1,205 +0,0 @@
-import pytest
-
-import reflex as rx
-
-
-@pytest.fixture
-def upload_root_component():
- """A test upload component function.
-
- Returns:
- A test upload component function.
- """
-
- def upload_root_component():
- return rx.upload.root(
- rx.button("select file"),
- rx.text("Drag and drop files here or click to select files"),
- border="1px dotted black",
- )
-
- return upload_root_component()
-
-
-@pytest.fixture
-def upload_component():
- """A test upload component function.
-
- Returns:
- A test upload component function.
- """
-
- def upload_component():
- return rx.upload(
- rx.button("select file"),
- rx.text("Drag and drop files here or click to select files"),
- border="1px dotted black",
- )
-
- return upload_component()
-
-
-@pytest.fixture
-def upload_component_id_special():
- def upload_component():
- return rx.upload(
- rx.button("select file"),
- rx.text("Drag and drop files here or click to select files"),
- border="1px dotted black",
- id="#spec!`al-_98ID",
- )
-
- return upload_component()
-
-
-@pytest.fixture
-def upload_component_with_props():
- """A test upload component with props function.
-
- Returns:
- A test upload component with props function.
- """
-
- def upload_component_with_props():
- return rx.upload(
- rx.button("select file"),
- rx.text("Drag and drop files here or click to select files"),
- border="1px dotted black",
- no_drag=True,
- max_files=2,
- )
-
- return upload_component_with_props()
-
-
-def test_upload_root_component_render(upload_root_component):
- """Test that the render function is set correctly.
-
- Args:
- upload_root_component: component fixture
- """
- upload = upload_root_component.render()
-
- # upload
- assert upload["name"] == "ReactDropzone"
- assert upload["props"] == [
- "id={`default`}",
- "multiple={true}",
- "onDrop={e => setFilesById(filesById => {\n"
- " const updatedFilesById = Object.assign({}, filesById);\n"
- " updatedFilesById[`default`] = e;\n"
- " return updatedFilesById;\n"
- " })\n"
- " }",
- "ref={ref_default}",
- ]
- assert upload["args"] == ("getRootProps", "getInputProps")
-
- # box inside of upload
- [box] = upload["children"]
- assert box["name"] == "RadixThemesBox"
- assert box["props"] == [
- "className={`rx-Upload`}",
- 'css={{"border": "1px dotted black"}}',
- "{...getRootProps()}",
- ]
-
- # input, button and text inside of box
- [input, button, text] = box["children"]
- assert input["name"] == "input"
- assert input["props"] == ["type={`file`}", "{...getInputProps()}"]
-
- assert button["name"] == "RadixThemesButton"
- assert button["children"][0]["contents"] == "{`select file`}"
-
- assert text["name"] == "RadixThemesText"
- assert (
- text["children"][0]["contents"]
- == "{`Drag and drop files here or click to select files`}"
- )
-
-
-def test_upload_component_render(upload_component):
- """Test that the render function is set correctly.
-
- Args:
- upload_component: component fixture
- """
- upload = upload_component.render()
-
- # upload
- assert upload["name"] == "ReactDropzone"
- assert upload["props"] == [
- "id={`default`}",
- "multiple={true}",
- "onDrop={e => setFilesById(filesById => {\n"
- " const updatedFilesById = Object.assign({}, filesById);\n"
- " updatedFilesById[`default`] = e;\n"
- " return updatedFilesById;\n"
- " })\n"
- " }",
- "ref={ref_default}",
- ]
- assert upload["args"] == ("getRootProps", "getInputProps")
-
- # box inside of upload
- [box] = upload["children"]
- assert box["name"] == "RadixThemesBox"
- assert box["props"] == [
- "className={`rx-Upload`}",
- 'css={{"border": "1px dotted black", "padding": "5em", "textAlign": "center"}}',
- "{...getRootProps()}",
- ]
-
- # input, button and text inside of box
- [input, button, text] = box["children"]
- assert input["name"] == "input"
- assert input["props"] == ["type={`file`}", "{...getInputProps()}"]
-
- assert button["name"] == "RadixThemesButton"
- assert button["children"][0]["contents"] == "{`select file`}"
-
- assert text["name"] == "RadixThemesText"
- assert (
- text["children"][0]["contents"]
- == "{`Drag and drop files here or click to select files`}"
- )
-
-
-def test_upload_component_with_props_render(upload_component_with_props):
- """Test that the render function is set correctly.
-
- Args:
- upload_component_with_props: component fixture
- """
- upload = upload_component_with_props.render()
-
- assert upload["props"] == [
- "id={`default`}",
- "maxFiles={2}",
- "multiple={true}",
- "noDrag={true}",
- "onDrop={e => setFilesById(filesById => {\n"
- " const updatedFilesById = Object.assign({}, filesById);\n"
- " updatedFilesById[`default`] = e;\n"
- " return updatedFilesById;\n"
- " })\n"
- " }",
- "ref={ref_default}",
- ]
-
-
-def test_upload_component_id_with_special_chars(upload_component_id_special):
- upload = upload_component_id_special.render()
-
- assert upload["props"] == [
- r"id={`#spec!\`al-_98ID`}",
- "multiple={true}",
- "onDrop={e => setFilesById(filesById => {\n"
- " const updatedFilesById = Object.assign({}, filesById);\n"
- " updatedFilesById[`#spec!\\`al-_98ID`] = e;\n"
- " return updatedFilesById;\n"
- " })\n"
- " }",
- "ref={ref__spec_al__98ID}",
- ]
diff --git a/tests/components/media/test_icon.py b/tests/components/media/test_icon.py
deleted file mode 100644
index 95dc8de28..000000000
--- a/tests/components/media/test_icon.py
+++ /dev/null
@@ -1,55 +0,0 @@
-import pytest
-
-from reflex.components.chakra.media.icon import ICON_LIST, Icon
-from reflex.utils import format
-
-
-def test_no_tag_errors():
- """Test that an icon without a tag raises an error."""
- with pytest.raises(AttributeError):
- Icon.create()
-
-
-def test_children_errors():
- """Test that an icon with children raises an error."""
- with pytest.raises(AttributeError):
- Icon.create("child", tag="search")
-
-
-@pytest.mark.parametrize(
- "tag",
- ICON_LIST,
-)
-def test_valid_icon(tag: str):
- """Test that a valid icon does not raise an error.
-
- Args:
- tag: The icon tag.
- """
- icon = Icon.create(tag=tag)
- assert icon.tag == format.to_title_case(tag) + "Icon"
-
-
-@pytest.mark.parametrize("tag", ["", " ", "invalid", 123])
-def test_invalid_icon(tag):
- """Test that an invalid icon raises an error.
-
- Args:
- tag: The icon tag.
- """
- with pytest.raises(ValueError):
- Icon.create(tag=tag)
-
-
-@pytest.mark.parametrize(
- "tag",
- ["Check", "Close", "eDit"],
-)
-def test_tag_with_capital(tag: str):
- """Test that an icon that tag with capital does not raise an error.
-
- Args:
- tag: The icon tag.
- """
- icon = Icon.create(tag=tag)
- assert icon.tag == format.to_title_case(tag) + "Icon"
diff --git a/tests/experimental/test_assets.py b/tests/experimental/test_assets.py
deleted file mode 100644
index 8037bcc75..000000000
--- a/tests/experimental/test_assets.py
+++ /dev/null
@@ -1,36 +0,0 @@
-import shutil
-from pathlib import Path
-
-import pytest
-
-import reflex as rx
-
-
-def test_asset():
- # Test the asset function.
-
- # The asset function copies a file to the app's external assets directory.
- asset = rx._x.asset("custom_script.js", "subfolder")
- assert asset == "/external/test_assets/subfolder/custom_script.js"
- result_file = Path(
- Path.cwd(), "assets/external/test_assets/subfolder/custom_script.js"
- )
- assert result_file.exists()
-
- # Running a second time should not raise an error.
- asset = rx._x.asset("custom_script.js", "subfolder")
-
- # Test the asset function without a subfolder.
- asset = rx._x.asset("custom_script.js")
- assert asset == "/external/test_assets/custom_script.js"
- result_file = Path(Path.cwd(), "assets/external/test_assets/custom_script.js")
- assert result_file.exists()
-
- # clean up
- shutil.rmtree(Path.cwd() / "assets/external")
-
- with pytest.raises(FileNotFoundError):
- asset = rx._x.asset("non_existent_file.js")
-
- # Nothing is done to assets when file does not exist.
- assert not Path(Path.cwd() / "assets/external").exists()
diff --git a/integration/__init__.py b/tests/integration/__init__.py
similarity index 100%
rename from integration/__init__.py
rename to tests/integration/__init__.py
diff --git a/integration/conftest.py b/tests/integration/conftest.py
similarity index 70%
rename from integration/conftest.py
rename to tests/integration/conftest.py
index 212ac9981..d11344903 100644
--- a/integration/conftest.py
+++ b/tests/integration/conftest.py
@@ -6,6 +6,8 @@ from pathlib import Path
import pytest
+import reflex.app
+from reflex.config import environment
from reflex.testing import AppHarness, AppHarnessProd
DISPLAY = None
@@ -21,7 +23,7 @@ def xvfb():
Yields:
the pyvirtualdisplay object that the browser will be open on
"""
- if os.environ.get("GITHUB_ACTIONS") and not os.environ.get("APP_HARNESS_HEADLESS"):
+ if os.environ.get("GITHUB_ACTIONS") and not environment.APP_HARNESS_HEADLESS.get():
from pyvirtualdisplay.smartdisplay import ( # pyright: ignore [reportMissingImports]
SmartDisplay,
)
@@ -42,7 +44,7 @@ def pytest_exception_interact(node, call, report):
call: The pytest call describing when/where the test was invoked.
report: The pytest log report object.
"""
- screenshot_dir = os.environ.get("SCREENSHOT_DIR")
+ screenshot_dir = environment.SCREENSHOT_DIR.get()
if DISPLAY is None or screenshot_dir is None:
return
@@ -75,3 +77,25 @@ def app_harness_env(request):
The AppHarness class to use for the test.
"""
return request.param
+
+
+@pytest.fixture(autouse=True)
+def raise_console_error(request, mocker):
+ """Spy on calls to `console.error` used by the framework.
+
+ Help catch spurious error conditions that might otherwise go unnoticed.
+
+ If a test is marked with `ignore_console_error`, the spy will be ignored
+ after the test.
+
+ Args:
+ request: The pytest request object.
+ mocker: The pytest mocker object.
+
+ Yields:
+ control to the test function.
+ """
+ spy = mocker.spy(reflex.app.console, "error")
+ yield
+ if "ignore_console_error" not in request.keywords:
+ spy.assert_not_called()
diff --git a/integration/init-test/Dockerfile b/tests/integration/init-test/Dockerfile
similarity index 91%
rename from integration/init-test/Dockerfile
rename to tests/integration/init-test/Dockerfile
index aa11344b1..f30466e7f 100644
--- a/integration/init-test/Dockerfile
+++ b/tests/integration/init-test/Dockerfile
@@ -1,4 +1,4 @@
-FROM python:3.8
+FROM python:3.9
ARG USERNAME=kerrigan
RUN useradd -m $USERNAME
diff --git a/integration/init-test/in_docker_test_script.sh b/tests/integration/init-test/in_docker_test_script.sh
similarity index 96%
rename from integration/init-test/in_docker_test_script.sh
rename to tests/integration/init-test/in_docker_test_script.sh
index 4e898ac99..31d245588 100755
--- a/integration/init-test/in_docker_test_script.sh
+++ b/tests/integration/init-test/in_docker_test_script.sh
@@ -13,7 +13,7 @@ function do_export () {
reflex init --template "$template"
reflex export
(
- cd "$SCRIPTPATH/../.."
+ cd "$SCRIPTPATH/../../.."
scripts/integration.sh ~/"$template" dev
pkill -9 -f 'next-server|python3' || true
sleep 10
diff --git a/integration/shared/state.py b/tests/integration/shared/state.py
similarity index 100%
rename from integration/shared/state.py
rename to tests/integration/shared/state.py
diff --git a/integration/test_background_task.py b/tests/integration/test_background_task.py
similarity index 85%
rename from integration/test_background_task.py
rename to tests/integration/test_background_task.py
index 98b6e48ff..d7fe20824 100644
--- a/integration/test_background_task.py
+++ b/tests/integration/test_background_task.py
@@ -1,4 +1,4 @@
-"""Test @rx.background task functionality."""
+"""Test @rx.event(background=True) task functionality."""
from typing import Generator
@@ -22,7 +22,7 @@ def BackgroundTask():
_task_id: int = 0
iterations: int = 10
- @rx.background
+ @rx.event(background=True)
async def handle_event(self):
async with self:
self._task_id += 1
@@ -31,7 +31,7 @@ def BackgroundTask():
self.counter += 1
await asyncio.sleep(0.005)
- @rx.background
+ @rx.event(background=True)
async def handle_event_yield_only(self):
async with self:
self._task_id += 1
@@ -42,21 +42,24 @@ def BackgroundTask():
yield State.increment() # type: ignore
await asyncio.sleep(0.005)
+ @rx.event
def increment(self):
self.counter += 1
- @rx.background
+ @rx.event(background=True)
async def increment_arbitrary(self, amount: int):
async with self:
self.counter += int(amount)
+ @rx.event
def reset_counter(self):
self.counter = 0
+ @rx.event
async def blocking_pause(self):
await asyncio.sleep(0.02)
- @rx.background
+ @rx.event(background=True)
async def non_blocking_pause(self):
await asyncio.sleep(0.02)
@@ -68,13 +71,13 @@ def BackgroundTask():
self.counter += 1
await asyncio.sleep(0.005)
- @rx.background
+ @rx.event(background=True)
async def handle_racy_event(self):
await asyncio.gather(
self.racy_task(), self.racy_task(), self.racy_task(), self.racy_task()
)
- @rx.background
+ @rx.event(background=True)
async def nested_async_with_self(self):
async with self:
self.counter += 1
@@ -86,8 +89,15 @@ def BackgroundTask():
third_state = await self.get_state(ThirdState)
await third_state._triple_count()
+ @rx.event(background=True)
+ async def yield_in_async_with_self(self):
+ async with self:
+ self.counter += 1
+ yield
+ self.counter += 1
+
class OtherState(rx.State):
- @rx.background
+ @rx.event(background=True)
async def get_other_state(self):
async with self:
state = await self.get_state(State)
@@ -108,11 +118,11 @@ def BackgroundTask():
def index() -> rx.Component:
return rx.vstack(
- rx.chakra.input(
+ rx.input(
id="token", value=State.router.session.client_token, is_read_only=True
),
rx.heading(State.counter, id="counter"),
- rx.chakra.input(
+ rx.input(
id="iterations",
placeholder="Iterations",
value=State.iterations.to_string(), # type: ignore
@@ -154,6 +164,11 @@ def BackgroundTask():
on_click=OtherState.get_other_state,
id="increment-from-other-state",
),
+ rx.button(
+ "Yield in Async with Self",
+ on_click=State.yield_in_async_with_self,
+ id="yield-in-async-with-self",
+ ),
rx.button("Reset", on_click=State.reset_counter, id="reset"),
)
@@ -174,8 +189,8 @@ def background_task(
running AppHarness instance
"""
with AppHarness.create(
- root=tmp_path_factory.mktemp(f"background_task"),
- app_source=BackgroundTask, # type: ignore
+ root=tmp_path_factory.mktemp("background_task"),
+ app_source=BackgroundTask,
) as harness:
yield harness
@@ -333,3 +348,30 @@ def test_get_state(
increment_button.click()
assert background_task._poll_for(lambda: counter.text == "13", timeout=5)
+
+
+def test_yield_in_async_with_self(
+ background_task: AppHarness,
+ driver: WebDriver,
+ token: str,
+):
+ """Test that yielding inside async with self does not disable mutability.
+
+ Args:
+ background_task: harness for BackgroundTask app.
+ driver: WebDriver instance.
+ token: The token for the connected client.
+ """
+ assert background_task.app_instance is not None
+
+ # get a reference to all buttons
+ yield_in_async_with_self_button = driver.find_element(
+ By.ID, "yield-in-async-with-self"
+ )
+
+ # get a reference to the counter
+ counter = driver.find_element(By.ID, "counter")
+ assert background_task._poll_for(lambda: counter.text == "0", timeout=5)
+
+ yield_in_async_with_self_button.click()
+ assert background_task._poll_for(lambda: counter.text == "2", timeout=5)
diff --git a/integration/test_call_script.py b/tests/integration/test_call_script.py
similarity index 64%
rename from integration/test_call_script.py
rename to tests/integration/test_call_script.py
index 5a3b83abf..203c20e9b 100644
--- a/integration/test_call_script.py
+++ b/tests/integration/test_call_script.py
@@ -15,6 +15,7 @@ from .utils import SessionStorage
def CallScript():
"""A test app for browser javascript integration."""
+ from pathlib import Path
from typing import Dict, List, Optional, Union
import reflex as rx
@@ -46,6 +47,7 @@ def CallScript():
inline_counter: int = 0
external_counter: int = 0
value: str = "Initial"
+ last_result: str = ""
def call_script_callback(self, result):
self.results.append(result)
@@ -53,15 +55,18 @@ def CallScript():
def call_script_callback_other_arg(self, result, other_arg):
self.results.append([other_arg, result])
+ @rx.event
def call_scripts_inline_yield(self):
yield rx.call_script("inline1()")
yield rx.call_script("inline2()")
yield rx.call_script("inline3()")
yield rx.call_script("inline4()")
+ @rx.event
def call_script_inline_return(self):
return rx.call_script("inline2()")
+ @rx.event
def call_scripts_inline_yield_callback(self):
yield rx.call_script(
"inline1()", callback=CallScriptState.call_script_callback
@@ -76,11 +81,13 @@ def CallScript():
"inline4()", callback=CallScriptState.call_script_callback
)
+ @rx.event
def call_script_inline_return_callback(self):
return rx.call_script(
"inline3()", callback=CallScriptState.call_script_callback
)
+ @rx.event
def call_script_inline_return_lambda(self):
return rx.call_script(
"inline2()",
@@ -89,21 +96,25 @@ def CallScript():
),
)
+ @rx.event
def get_inline_counter(self):
return rx.call_script(
"inline_counter",
callback=CallScriptState.set_inline_counter, # type: ignore
)
+ @rx.event
def call_scripts_external_yield(self):
yield rx.call_script("external1()")
yield rx.call_script("external2()")
yield rx.call_script("external3()")
yield rx.call_script("external4()")
+ @rx.event
def call_script_external_return(self):
return rx.call_script("external2()")
+ @rx.event
def call_scripts_external_yield_callback(self):
yield rx.call_script(
"external1()", callback=CallScriptState.call_script_callback
@@ -118,11 +129,13 @@ def CallScript():
"external4()", callback=CallScriptState.call_script_callback
)
+ @rx.event
def call_script_external_return_callback(self):
return rx.call_script(
"external3()", callback=CallScriptState.call_script_callback
)
+ @rx.event
def call_script_external_return_lambda(self):
return rx.call_script(
"external2()",
@@ -131,19 +144,50 @@ def CallScript():
),
)
+ @rx.event
def get_external_counter(self):
return rx.call_script(
"external_counter",
callback=CallScriptState.set_external_counter, # type: ignore
)
+ @rx.event
+ def call_with_var_f_string(self):
+ return rx.call_script(
+ f"{rx.Var('inline_counter')} + {rx.Var('external_counter')}",
+ callback=CallScriptState.set_last_result, # type: ignore
+ )
+
+ @rx.event
+ def call_with_var_str_cast(self):
+ return rx.call_script(
+ f"{rx.Var('inline_counter')!s} + {rx.Var('external_counter')!s}",
+ callback=CallScriptState.set_last_result, # type: ignore
+ )
+
+ @rx.event
+ def call_with_var_f_string_wrapped(self):
+ return rx.call_script(
+ rx.Var(f"{rx.Var('inline_counter')} + {rx.Var('external_counter')}"),
+ callback=CallScriptState.set_last_result, # type: ignore
+ )
+
+ @rx.event
+ def call_with_var_str_cast_wrapped(self):
+ return rx.call_script(
+ rx.Var(
+ f"{rx.Var('inline_counter')!s} + {rx.Var('external_counter')!s}"
+ ),
+ callback=CallScriptState.set_last_result, # type: ignore
+ )
+
+ @rx.event
def reset_(self):
yield rx.call_script("inline_counter = 0; external_counter = 0")
self.reset()
app = rx.App(state=rx.State)
- with open("assets/external.js", "w") as f:
- f.write(external_scripts)
+ Path("assets/external.js").write_text(external_scripts)
@app.add_page
def index():
@@ -234,6 +278,68 @@ def CallScript():
id="update_value",
),
rx.button("Reset", id="reset", on_click=CallScriptState.reset_),
+ rx.input(
+ value=CallScriptState.last_result,
+ id="last_result",
+ read_only=True,
+ on_click=CallScriptState.set_last_result(""), # type: ignore
+ ),
+ rx.button(
+ "call_with_var_f_string",
+ on_click=CallScriptState.call_with_var_f_string,
+ id="call_with_var_f_string",
+ ),
+ rx.button(
+ "call_with_var_str_cast",
+ on_click=CallScriptState.call_with_var_str_cast,
+ id="call_with_var_str_cast",
+ ),
+ rx.button(
+ "call_with_var_f_string_wrapped",
+ on_click=CallScriptState.call_with_var_f_string_wrapped,
+ id="call_with_var_f_string_wrapped",
+ ),
+ rx.button(
+ "call_with_var_str_cast_wrapped",
+ on_click=CallScriptState.call_with_var_str_cast_wrapped,
+ id="call_with_var_str_cast_wrapped",
+ ),
+ rx.button(
+ "call_with_var_f_string_inline",
+ on_click=rx.call_script(
+ f"{rx.Var('inline_counter')} + {CallScriptState.last_result}",
+ callback=CallScriptState.set_last_result, # type: ignore
+ ),
+ id="call_with_var_f_string_inline",
+ ),
+ rx.button(
+ "call_with_var_str_cast_inline",
+ on_click=rx.call_script(
+ f"{rx.Var('inline_counter')!s} + {rx.Var('external_counter')!s}",
+ callback=CallScriptState.set_last_result, # type: ignore
+ ),
+ id="call_with_var_str_cast_inline",
+ ),
+ rx.button(
+ "call_with_var_f_string_wrapped_inline",
+ on_click=rx.call_script(
+ rx.Var(
+ f"{rx.Var('inline_counter')} + {CallScriptState.last_result}"
+ ),
+ callback=CallScriptState.set_last_result, # type: ignore
+ ),
+ id="call_with_var_f_string_wrapped_inline",
+ ),
+ rx.button(
+ "call_with_var_str_cast_wrapped_inline",
+ on_click=rx.call_script(
+ rx.Var(
+ f"{rx.Var('inline_counter')!s} + {rx.Var('external_counter')!s}"
+ ),
+ callback=CallScriptState.set_last_result, # type: ignore
+ ),
+ id="call_with_var_str_cast_wrapped_inline",
+ ),
)
@@ -249,7 +355,7 @@ def call_script(tmp_path_factory) -> Generator[AppHarness, None, None]:
"""
with AppHarness.create(
root=tmp_path_factory.mktemp("call_script"),
- app_source=CallScript, # type: ignore
+ app_source=CallScript,
) as harness:
yield harness
@@ -363,3 +469,73 @@ def test_call_script(
call_script.poll_for_content(update_value_button, exp_not_equal="Initial")
== "updated"
)
+
+
+def test_call_script_w_var(
+ call_script: AppHarness,
+ driver: WebDriver,
+):
+ """Test evaluating javascript expressions containing Vars.
+
+ Args:
+ call_script: harness for CallScript app.
+ driver: WebDriver instance.
+ """
+ assert_token(driver)
+ last_result = driver.find_element(By.ID, "last_result")
+ assert last_result.get_attribute("value") == ""
+
+ inline_return_button = driver.find_element(By.ID, "inline_return")
+
+ call_with_var_f_string_button = driver.find_element(By.ID, "call_with_var_f_string")
+ call_with_var_str_cast_button = driver.find_element(By.ID, "call_with_var_str_cast")
+ call_with_var_f_string_wrapped_button = driver.find_element(
+ By.ID, "call_with_var_f_string_wrapped"
+ )
+ call_with_var_str_cast_wrapped_button = driver.find_element(
+ By.ID, "call_with_var_str_cast_wrapped"
+ )
+ call_with_var_f_string_inline_button = driver.find_element(
+ By.ID, "call_with_var_f_string_inline"
+ )
+ call_with_var_str_cast_inline_button = driver.find_element(
+ By.ID, "call_with_var_str_cast_inline"
+ )
+ call_with_var_f_string_wrapped_inline_button = driver.find_element(
+ By.ID, "call_with_var_f_string_wrapped_inline"
+ )
+ call_with_var_str_cast_wrapped_inline_button = driver.find_element(
+ By.ID, "call_with_var_str_cast_wrapped_inline"
+ )
+
+ inline_return_button.click()
+ call_with_var_f_string_button.click()
+ assert call_script.poll_for_value(last_result, exp_not_equal="") == "1"
+
+ inline_return_button.click()
+ call_with_var_str_cast_button.click()
+ assert call_script.poll_for_value(last_result, exp_not_equal="1") == "2"
+
+ inline_return_button.click()
+ call_with_var_f_string_wrapped_button.click()
+ assert call_script.poll_for_value(last_result, exp_not_equal="2") == "3"
+
+ inline_return_button.click()
+ call_with_var_str_cast_wrapped_button.click()
+ assert call_script.poll_for_value(last_result, exp_not_equal="3") == "4"
+
+ inline_return_button.click()
+ call_with_var_f_string_inline_button.click()
+ assert call_script.poll_for_value(last_result, exp_not_equal="4") == "9"
+
+ inline_return_button.click()
+ call_with_var_str_cast_inline_button.click()
+ assert call_script.poll_for_value(last_result, exp_not_equal="9") == "6"
+
+ inline_return_button.click()
+ call_with_var_f_string_wrapped_inline_button.click()
+ assert call_script.poll_for_value(last_result, exp_not_equal="6") == "13"
+
+ inline_return_button.click()
+ call_with_var_str_cast_wrapped_inline_button.click()
+ assert call_script.poll_for_value(last_result, exp_not_equal="13") == "8"
diff --git a/integration/test_client_storage.py b/tests/integration/test_client_storage.py
similarity index 83%
rename from integration/test_client_storage.py
rename to tests/integration/test_client_storage.py
index b69009a09..2652d6ccb 100644
--- a/integration/test_client_storage.py
+++ b/tests/integration/test_client_storage.py
@@ -10,6 +10,13 @@ from selenium.webdriver import Firefox
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webdriver import WebDriver
+from reflex.state import (
+ State,
+ StateManagerDisk,
+ StateManagerMemory,
+ StateManagerRedis,
+ _substate_key,
+)
from reflex.testing import AppHarness
from . import utils
@@ -55,6 +62,7 @@ def ClientSide():
def set_l6(self, my_param: str):
self.l6 = my_param
+ @rx.event
def set_var(self):
setattr(self, self.state_var, self.input_value)
self.state_var = self.input_value = ""
@@ -64,24 +72,25 @@ def ClientSide():
l1s: str = rx.LocalStorage()
s1s: str = rx.SessionStorage()
+ @rx.event
def set_var(self):
setattr(self, self.state_var, self.input_value)
self.state_var = self.input_value = ""
def index():
return rx.fragment(
- rx.chakra.input(
+ rx.input(
value=ClientSideState.router.session.client_token,
- is_read_only=True,
+ read_only=True,
id="token",
),
- rx.chakra.input(
+ rx.input(
placeholder="state var",
value=ClientSideState.state_var,
on_change=ClientSideState.set_state_var, # type: ignore
id="state_var",
),
- rx.chakra.input(
+ rx.input(
placeholder="input value",
value=ClientSideState.input_value,
on_change=ClientSideState.set_input_value, # type: ignore
@@ -135,7 +144,7 @@ def client_side(tmp_path_factory) -> Generator[AppHarness, None, None]:
"""
with AppHarness.create(
root=tmp_path_factory.mktemp("client_side"),
- app_source=ClientSide, # type: ignore
+ app_source=ClientSide,
) as harness:
yield harness
@@ -311,7 +320,6 @@ async def test_client_side_state(
# no cookies should be set yet!
assert not driver.get_cookies()
local_storage_items = local_storage.items()
- local_storage_items.pop("chakra-ui-color-mode", None)
local_storage_items.pop("last_compiled_time", None)
assert not local_storage_items
@@ -427,7 +435,6 @@ async def test_client_side_state(
assert f"{sub_state_name}.c3" not in cookie_info_map(driver)
local_storage_items = local_storage.items()
- local_storage_items.pop("chakra-ui-color-mode", None)
local_storage_items.pop("last_compiled_time", None)
assert local_storage_items.pop(f"{sub_state_name}.l1") == "l1 value"
assert local_storage_items.pop(f"{sub_state_name}.l2") == "l2 value"
@@ -604,6 +611,109 @@ async def test_client_side_state(
assert s2.text == "s2 value"
assert s3.text == "s3 value"
+ # Simulate state expiration
+ if isinstance(client_side.state_manager, StateManagerRedis):
+ await client_side.state_manager.redis.delete(
+ _substate_key(token, State.get_full_name())
+ )
+ await client_side.state_manager.redis.delete(_substate_key(token, state_name))
+ await client_side.state_manager.redis.delete(
+ _substate_key(token, sub_state_name)
+ )
+ await client_side.state_manager.redis.delete(
+ _substate_key(token, sub_sub_state_name)
+ )
+ elif isinstance(client_side.state_manager, (StateManagerMemory, StateManagerDisk)):
+ del client_side.state_manager.states[token]
+ if isinstance(client_side.state_manager, StateManagerDisk):
+ client_side.state_manager.token_expiration = 0
+ client_side.state_manager._purge_expired_states()
+
+ # Ensure the state is gone (not hydrated)
+ async def poll_for_not_hydrated():
+ state = await client_side.get_state(_substate_key(token or "", state_name))
+ return not state.is_hydrated
+
+ assert await AppHarness._poll_for_async(poll_for_not_hydrated)
+
+ # Trigger event to get a new instance of the state since the old was expired.
+ set_sub("c1", "c1 post expire")
+
+ # get new references to all cookie and local storage elements (again)
+ c1 = driver.find_element(By.ID, "c1")
+ c2 = driver.find_element(By.ID, "c2")
+ c3 = driver.find_element(By.ID, "c3")
+ c4 = driver.find_element(By.ID, "c4")
+ c5 = driver.find_element(By.ID, "c5")
+ c6 = driver.find_element(By.ID, "c6")
+ c7 = driver.find_element(By.ID, "c7")
+ l1 = driver.find_element(By.ID, "l1")
+ l2 = driver.find_element(By.ID, "l2")
+ l3 = driver.find_element(By.ID, "l3")
+ l4 = driver.find_element(By.ID, "l4")
+ s1 = driver.find_element(By.ID, "s1")
+ s2 = driver.find_element(By.ID, "s2")
+ s3 = driver.find_element(By.ID, "s3")
+ c1s = driver.find_element(By.ID, "c1s")
+ l1s = driver.find_element(By.ID, "l1s")
+ s1s = driver.find_element(By.ID, "s1s")
+
+ assert c1.text == "c1 post expire"
+ assert c2.text == "c2 value"
+ assert c3.text == "" # temporary cookie expired after reset state!
+ assert c4.text == "c4 value"
+ assert c5.text == "c5 value"
+ assert c6.text == "c6 value"
+ assert c7.text == "c7 value"
+ assert l1.text == "l1 value"
+ assert l2.text == "l2 value"
+ assert l3.text == "l3 value"
+ assert l4.text == "l4 value"
+ assert s1.text == "s1 value"
+ assert s2.text == "s2 value"
+ assert s3.text == "s3 value"
+ assert c1s.text == "c1s value"
+ assert l1s.text == "l1s value"
+ assert s1s.text == "s1s value"
+
+ # Get the backend state and ensure the values are still set
+ async def get_sub_state():
+ root_state = await client_side.get_state(
+ _substate_key(token or "", sub_state_name)
+ )
+ state = root_state.substates[client_side.get_state_name("_client_side_state")]
+ sub_state = state.substates[
+ client_side.get_state_name("_client_side_sub_state")
+ ]
+ return sub_state
+
+ async def poll_for_c1_set():
+ sub_state = await get_sub_state()
+ return sub_state.c1 == "c1 post expire"
+
+ assert await AppHarness._poll_for_async(poll_for_c1_set)
+ sub_state = await get_sub_state()
+ assert sub_state.c1 == "c1 post expire"
+ assert sub_state.c2 == "c2 value"
+ assert sub_state.c3 == ""
+ assert sub_state.c4 == "c4 value"
+ assert sub_state.c5 == "c5 value"
+ assert sub_state.c6 == "c6 value"
+ assert sub_state.c7 == "c7 value"
+ assert sub_state.l1 == "l1 value"
+ assert sub_state.l2 == "l2 value"
+ assert sub_state.l3 == "l3 value"
+ assert sub_state.l4 == "l4 value"
+ assert sub_state.s1 == "s1 value"
+ assert sub_state.s2 == "s2 value"
+ assert sub_state.s3 == "s3 value"
+ sub_sub_state = sub_state.substates[
+ client_side.get_state_name("_client_side_sub_sub_state")
+ ]
+ assert sub_sub_state.c1s == "c1s value"
+ assert sub_sub_state.l1s == "l1s value"
+ assert sub_sub_state.s1s == "s1s value"
+
# clear the cookie jar and local storage, ensure state reset to default
driver.delete_all_cookies()
local_storage.clear()
diff --git a/tests/integration/test_component_state.py b/tests/integration/test_component_state.py
new file mode 100644
index 000000000..97624e7c5
--- /dev/null
+++ b/tests/integration/test_component_state.py
@@ -0,0 +1,204 @@
+"""Test that per-component state scaffold works and operates independently."""
+
+from typing import Generator
+
+import pytest
+from selenium.webdriver.common.by import By
+
+from reflex.state import State, _substate_key
+from reflex.testing import AppHarness
+
+from . import utils
+
+
+def ComponentStateApp():
+ """App using per component state."""
+ from typing import Generic, TypeVar
+
+ import reflex as rx
+
+ E = TypeVar("E")
+
+ class MultiCounter(rx.ComponentState, Generic[E]):
+ """ComponentState style."""
+
+ count: int = 0
+ _be: E
+ _be_int: int
+ _be_str: str = "42"
+
+ @rx.event
+ def increment(self):
+ self.count += 1
+ self._be = self.count # type: ignore
+
+ @classmethod
+ def get_component(cls, *children, **props):
+ return rx.vstack(
+ *children,
+ rx.heading(cls.count, id=f"count-{props.get('id', 'default')}"),
+ rx.button(
+ "Increment",
+ on_click=cls.increment,
+ id=f"button-{props.get('id', 'default')}",
+ ),
+ **props,
+ )
+
+ def multi_counter_func(id: str = "default") -> rx.Component:
+ """Local-substate style.
+
+ Args:
+ id: identifier for this instance
+
+ Returns:
+ A new instance of the component with its own state.
+ """
+
+ class _Counter(rx.State):
+ count: int = 0
+
+ @rx.event
+ def increment(self):
+ self.count += 1
+
+ return rx.vstack(
+ rx.heading(_Counter.count, id=f"count-{id}"),
+ rx.button(
+ "Increment",
+ on_click=_Counter.increment,
+ id=f"button-{id}",
+ ),
+ State=_Counter,
+ )
+
+ app = rx.App(state=rx.State) # noqa
+
+ @rx.page()
+ def index():
+ mc_a = MultiCounter.create(id="a")
+ mc_b = MultiCounter.create(id="b")
+ mc_c = multi_counter_func(id="c")
+ mc_d = multi_counter_func(id="d")
+ assert mc_a.State != mc_b.State
+ assert mc_c.State != mc_d.State
+ return rx.vstack(
+ mc_a,
+ mc_b,
+ mc_c,
+ mc_d,
+ rx.button(
+ "Inc A",
+ on_click=mc_a.State.increment, # type: ignore
+ id="inc-a",
+ ),
+ rx.text(
+ mc_a.State.get_name() if mc_a.State is not None else "",
+ id="a_state_name",
+ ),
+ rx.text(
+ mc_b.State.get_name() if mc_b.State is not None else "",
+ id="b_state_name",
+ ),
+ )
+
+
+@pytest.fixture()
+def component_state_app(tmp_path) -> Generator[AppHarness, None, None]:
+ """Start ComponentStateApp app at tmp_path via AppHarness.
+
+ Args:
+ tmp_path: pytest tmp_path fixture
+
+ Yields:
+ running AppHarness instance
+ """
+ with AppHarness.create(
+ root=tmp_path,
+ app_source=ComponentStateApp,
+ ) as harness:
+ yield harness
+
+
+@pytest.mark.asyncio
+async def test_component_state_app(component_state_app: AppHarness):
+ """Increment counters independently.
+
+ Args:
+ component_state_app: harness for ComponentStateApp app
+ """
+ assert component_state_app.app_instance is not None, "app is not running"
+ driver = component_state_app.frontend()
+
+ ss = utils.SessionStorage(driver)
+ assert AppHarness._poll_for(lambda: ss.get("token") is not None), "token not found"
+ root_state_token = _substate_key(ss.get("token"), State)
+
+ count_a = driver.find_element(By.ID, "count-a")
+ count_b = driver.find_element(By.ID, "count-b")
+ button_a = driver.find_element(By.ID, "button-a")
+ button_b = driver.find_element(By.ID, "button-b")
+ button_inc_a = driver.find_element(By.ID, "inc-a")
+
+ # Check that backend vars in mixins are okay
+ a_state_name = driver.find_element(By.ID, "a_state_name").text
+ b_state_name = driver.find_element(By.ID, "b_state_name").text
+ root_state = await component_state_app.get_state(root_state_token)
+ a_state = root_state.substates[a_state_name]
+ b_state = root_state.substates[b_state_name]
+ assert a_state._backend_vars == a_state.backend_vars
+ assert a_state._backend_vars == b_state._backend_vars
+ assert a_state._backend_vars["_be"] is None
+ assert a_state._backend_vars["_be_int"] == 0
+ assert a_state._backend_vars["_be_str"] == "42"
+
+ assert count_a.text == "0"
+
+ button_a.click()
+ assert component_state_app.poll_for_content(count_a, exp_not_equal="0") == "1"
+
+ button_a.click()
+ assert component_state_app.poll_for_content(count_a, exp_not_equal="1") == "2"
+
+ button_inc_a.click()
+ assert component_state_app.poll_for_content(count_a, exp_not_equal="2") == "3"
+
+ root_state = await component_state_app.get_state(root_state_token)
+ a_state = root_state.substates[a_state_name]
+ b_state = root_state.substates[b_state_name]
+ assert a_state._backend_vars != a_state.backend_vars
+ assert a_state._be == a_state._backend_vars["_be"] == 3
+ assert b_state._be is None
+ assert b_state._backend_vars["_be"] is None
+
+ assert count_b.text == "0"
+
+ button_b.click()
+ assert component_state_app.poll_for_content(count_b, exp_not_equal="0") == "1"
+
+ button_b.click()
+ assert component_state_app.poll_for_content(count_b, exp_not_equal="1") == "2"
+
+ root_state = await component_state_app.get_state(root_state_token)
+ a_state = root_state.substates[a_state_name]
+ b_state = root_state.substates[b_state_name]
+ assert b_state._backend_vars != b_state.backend_vars
+ assert b_state._be == b_state._backend_vars["_be"] == 2
+
+ # Check locally-defined substate style
+ count_c = driver.find_element(By.ID, "count-c")
+ count_d = driver.find_element(By.ID, "count-d")
+ button_c = driver.find_element(By.ID, "button-c")
+ button_d = driver.find_element(By.ID, "button-d")
+
+ assert component_state_app.poll_for_content(count_c, exp_not_equal="") == "0"
+ assert component_state_app.poll_for_content(count_d, exp_not_equal="") == "0"
+ button_c.click()
+ assert component_state_app.poll_for_content(count_c, exp_not_equal="0") == "1"
+ assert component_state_app.poll_for_content(count_d, exp_not_equal="") == "0"
+ button_c.click()
+ assert component_state_app.poll_for_content(count_c, exp_not_equal="1") == "2"
+ assert component_state_app.poll_for_content(count_d, exp_not_equal="") == "0"
+ button_d.click()
+ assert component_state_app.poll_for_content(count_c, exp_not_equal="1") == "2"
+ assert component_state_app.poll_for_content(count_d, exp_not_equal="0") == "1"
diff --git a/integration/test_computed_vars.py b/tests/integration/test_computed_vars.py
similarity index 97%
rename from integration/test_computed_vars.py
rename to tests/integration/test_computed_vars.py
index 28f774de5..03aaf18b4 100644
--- a/integration/test_computed_vars.py
+++ b/tests/integration/test_computed_vars.py
@@ -58,9 +58,11 @@ def ComputedVars():
def depends_on_count3(self) -> int:
return self.count
+ @rx.event
def increment(self):
self.count += 1
+ @rx.event
def mark_dirty(self):
self._mark_dirty()
@@ -104,7 +106,6 @@ def ComputedVars():
),
)
- # raise Exception(State.count3._deps(objclass=State))
app = rx.App()
app.add_page(index)
@@ -122,8 +123,8 @@ def computed_vars(
running AppHarness instance
"""
with AppHarness.create(
- root=tmp_path_factory.mktemp(f"computed_vars"),
- app_source=ComputedVars, # type: ignore
+ root=tmp_path_factory.mktemp("computed_vars"),
+ app_source=ComputedVars,
) as harness:
yield harness
diff --git a/integration/test_connection_banner.py b/tests/integration/test_connection_banner.py
similarity index 98%
rename from integration/test_connection_banner.py
rename to tests/integration/test_connection_banner.py
index b83a493ce..44187c8ba 100644
--- a/integration/test_connection_banner.py
+++ b/tests/integration/test_connection_banner.py
@@ -20,6 +20,7 @@ def ConnectionBanner():
class State(rx.State):
foo: int = 0
+ @rx.event
async def delay(self):
await asyncio.sleep(5)
@@ -51,7 +52,7 @@ def connection_banner(tmp_path) -> Generator[AppHarness, None, None]:
"""
with AppHarness.create(
root=tmp_path,
- app_source=ConnectionBanner, # type: ignore
+ app_source=ConnectionBanner,
) as harness:
yield harness
diff --git a/integration/test_deploy_url.py b/tests/integration/test_deploy_url.py
similarity index 98%
rename from integration/test_deploy_url.py
rename to tests/integration/test_deploy_url.py
index b0421cfb7..5c840d24d 100644
--- a/integration/test_deploy_url.py
+++ b/tests/integration/test_deploy_url.py
@@ -17,6 +17,7 @@ def DeployUrlSample() -> None:
import reflex as rx
class State(rx.State):
+ @rx.event
def goto_self(self):
return rx.redirect(rx.config.get_config().deploy_url) # type: ignore
@@ -43,7 +44,7 @@ def deploy_url_sample(
"""
with AppHarness.create(
root=tmp_path_factory.mktemp("deploy_url_sample"),
- app_source=DeployUrlSample, # type: ignore
+ app_source=DeployUrlSample,
) as harness:
yield harness
diff --git a/tests/integration/test_dynamic_components.py b/tests/integration/test_dynamic_components.py
new file mode 100644
index 000000000..6a68aa1a1
--- /dev/null
+++ b/tests/integration/test_dynamic_components.py
@@ -0,0 +1,169 @@
+"""Integration tests for var operations."""
+
+import time
+from typing import Callable, Generator, TypeVar
+
+import pytest
+from selenium.webdriver.common.by import By
+
+from reflex.testing import AppHarness
+
+# pyright: reportOptionalMemberAccess=false, reportGeneralTypeIssues=false, reportUnknownMemberType=false
+
+
+def DynamicComponents():
+ """App with var operations."""
+ import reflex as rx
+
+ class DynamicComponentsState(rx.State):
+ value: int = 10
+
+ button: rx.Component = rx.button(
+ "Click me",
+ custom_attrs={
+ "id": "button",
+ },
+ )
+
+ def got_clicked(self):
+ self.button = rx.button(
+ "Clicked",
+ custom_attrs={
+ "id": "button",
+ },
+ )
+
+ @rx.var
+ def client_token_component(self) -> rx.Component:
+ return rx.vstack(
+ rx.el.input(
+ custom_attrs={
+ "id": "token",
+ },
+ value=self.router.session.client_token,
+ is_read_only=True,
+ ),
+ rx.button(
+ "Update",
+ custom_attrs={
+ "id": "update",
+ },
+ on_click=DynamicComponentsState.got_clicked,
+ ),
+ )
+
+ app = rx.App()
+
+ def factorial(n: int) -> int:
+ if n == 0:
+ return 1
+ return n * factorial(n - 1)
+
+ @app.add_page
+ def index():
+ return rx.vstack(
+ DynamicComponentsState.client_token_component,
+ DynamicComponentsState.button,
+ rx.text(
+ DynamicComponentsState._evaluate(
+ lambda state: factorial(state.value), of_type=int
+ ),
+ id="factorial",
+ ),
+ )
+
+
+@pytest.fixture(scope="module")
+def dynamic_components(tmp_path_factory) -> Generator[AppHarness, None, None]:
+ """Start VarOperations app at tmp_path via AppHarness.
+
+ Args:
+ tmp_path_factory: pytest tmp_path_factory fixture
+
+ Yields:
+ running AppHarness instance
+ """
+ with AppHarness.create(
+ root=tmp_path_factory.mktemp("dynamic_components"),
+ app_source=DynamicComponents,
+ ) as harness:
+ assert harness.app_instance is not None, "app is not running"
+ yield harness
+
+
+T = TypeVar("T")
+
+
+def poll_for_result(
+ f: Callable[[], T], exception=Exception, max_attempts=5, seconds_between_attempts=1
+) -> T:
+ """Poll for a result from a function.
+
+ Args:
+ f: function to call
+ exception: exception to catch
+ max_attempts: maximum number of attempts
+ seconds_between_attempts: seconds to wait between
+
+ Returns:
+ Result of the function
+
+ Raises:
+ AssertionError: if the function does not return a value
+ """
+ attempts = 0
+ while attempts < max_attempts:
+ try:
+ return f()
+ except exception:
+ attempts += 1
+ time.sleep(seconds_between_attempts)
+ raise AssertionError("Function did not return a value")
+
+
+@pytest.fixture
+def driver(dynamic_components: AppHarness):
+ """Get an instance of the browser open to the dynamic components app.
+
+ Args:
+ dynamic_components: AppHarness for the dynamic components
+
+ Yields:
+ WebDriver instance.
+ """
+ driver = dynamic_components.frontend()
+ try:
+ token_input = poll_for_result(lambda: driver.find_element(By.ID, "token"))
+ assert token_input
+ # wait for the backend connection to send the token
+ token = dynamic_components.poll_for_value(token_input)
+ assert token is not None
+
+ yield driver
+ finally:
+ driver.quit()
+
+
+def test_dynamic_components(driver, dynamic_components: AppHarness):
+ """Test that the var operations produce the right results.
+
+ Args:
+ driver: selenium WebDriver open to the app
+ dynamic_components: AppHarness for the dynamic components
+ """
+ button = poll_for_result(lambda: driver.find_element(By.ID, "button"))
+ assert button
+ assert button.text == "Click me"
+
+ update_button = driver.find_element(By.ID, "update")
+ assert update_button
+ update_button.click()
+
+ assert (
+ dynamic_components.poll_for_content(button, exp_not_equal="Click me")
+ == "Clicked"
+ )
+
+ factorial = poll_for_result(lambda: driver.find_element(By.ID, "factorial"))
+ assert factorial
+ assert factorial.text == "3628800"
diff --git a/integration/test_dynamic_routes.py b/tests/integration/test_dynamic_routes.py
similarity index 65%
rename from integration/test_dynamic_routes.py
rename to tests/integration/test_dynamic_routes.py
index e3686ee1a..8a3cde3a2 100644
--- a/integration/test_dynamic_routes.py
+++ b/tests/integration/test_dynamic_routes.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+import time
from typing import Callable, Coroutine, Generator, Type
from urllib.parse import urlsplit
@@ -21,14 +22,17 @@ def DynamicRoute():
class DynamicState(rx.State):
order: List[str] = []
- page_id: str = ""
def on_load(self):
- self.order.append(f"{self.router.page.path}-{self.page_id or 'no page id'}")
+ page_data = f"{self.router.page.path}-{self.page_id or 'no page id'}"
+ print(f"on_load: {page_data}")
+ self.order.append(page_data)
def on_load_redir(self):
query_params = self.router.page.params
- self.order.append(f"on_load_redir-{query_params}")
+ page_data = f"on_load_redir-{query_params}"
+ print(f"on_load_redir: {page_data}")
+ self.order.append(page_data)
return rx.redirect(f"/page/{query_params['page_id']}")
@rx.var
@@ -40,17 +44,15 @@ def DynamicRoute():
def index():
return rx.fragment(
- rx.chakra.input(
+ rx.input(
value=DynamicState.router.session.client_token,
- is_read_only=True,
+ read_only=True,
id="token",
),
- rx.chakra.input(
- value=DynamicState.page_id, is_read_only=True, id="page_id"
- ),
- rx.chakra.input(
+ rx.input(value=rx.State.page_id, read_only=True, id="page_id"), # type: ignore
+ rx.input(
value=DynamicState.router.page.raw_path,
- is_read_only=True,
+ read_only=True,
id="raw_path",
),
rx.link("index", href="/", id="link_index"),
@@ -61,22 +63,85 @@ def DynamicRoute():
id="link_page_next", # type: ignore
),
rx.link("missing", href="/missing", id="link_missing"),
- rx.chakra.list(
+ rx.list( # type: ignore
rx.foreach(
DynamicState.order, # type: ignore
- lambda i: rx.chakra.list_item(rx.text(i)),
+ lambda i: rx.list_item(rx.text(i)),
),
),
)
+ class ArgState(rx.State):
+ """The app state."""
+
+ @rx.var
+ def arg(self) -> int:
+ return int(self.arg_str or 0)
+
+ class ArgSubState(ArgState):
+ @rx.var(cache=True)
+ def cached_arg(self) -> int:
+ return self.arg
+
+ @rx.var(cache=True)
+ def cached_arg_str(self) -> str:
+ return self.arg_str
+
+ @rx.page(route="/arg/[arg_str]")
+ def arg() -> rx.Component:
+ return rx.vstack(
+ rx.input(
+ value=DynamicState.router.session.client_token,
+ read_only=True,
+ id="token",
+ ),
+ rx.data_list.root(
+ rx.data_list.item(
+ rx.data_list.label("rx.State.arg_str (dynamic)"),
+ rx.data_list.value(rx.State.arg_str, id="state-arg_str"), # type: ignore
+ ),
+ rx.data_list.item(
+ rx.data_list.label("ArgState.arg_str (dynamic) (inherited)"),
+ rx.data_list.value(ArgState.arg_str, id="argstate-arg_str"), # type: ignore
+ ),
+ rx.data_list.item(
+ rx.data_list.label("ArgState.arg"),
+ rx.data_list.value(ArgState.arg, id="argstate-arg"),
+ ),
+ rx.data_list.item(
+ rx.data_list.label("ArgSubState.arg_str (dynamic) (inherited)"),
+ rx.data_list.value(ArgSubState.arg_str, id="argsubstate-arg_str"), # type: ignore
+ ),
+ rx.data_list.item(
+ rx.data_list.label("ArgSubState.arg (inherited)"),
+ rx.data_list.value(ArgSubState.arg, id="argsubstate-arg"),
+ ),
+ rx.data_list.item(
+ rx.data_list.label("ArgSubState.cached_arg"),
+ rx.data_list.value(
+ ArgSubState.cached_arg, id="argsubstate-cached_arg"
+ ),
+ ),
+ rx.data_list.item(
+ rx.data_list.label("ArgSubState.cached_arg_str"),
+ rx.data_list.value(
+ ArgSubState.cached_arg_str, id="argsubstate-cached_arg_str"
+ ),
+ ),
+ ),
+ rx.link("+", href=f"/arg/{ArgState.arg + 1}", id="next-page"),
+ align="center",
+ height="100vh",
+ )
+
@rx.page(route="/redirect-page/[page_id]", on_load=DynamicState.on_load_redir) # type: ignore
def redirect_page():
return rx.fragment(rx.text("redirecting..."))
app = rx.App(state=rx.State)
- app.add_page(index)
app.add_page(index, route="/page/[page_id]", on_load=DynamicState.on_load) # type: ignore
app.add_page(index, route="/static/x", on_load=DynamicState.on_load) # type: ignore
+ app.add_page(index)
app.add_custom_404_page(on_load=DynamicState.on_load) # type: ignore
@@ -94,9 +159,9 @@ def dynamic_route(
running AppHarness instance
"""
with app_harness_env.create(
- root=tmp_path_factory.mktemp(f"dynamic_route"),
+ root=tmp_path_factory.mktemp("dynamic_route"),
app_name=f"dynamicroute_{app_harness_env.__name__.lower()}",
- app_source=DynamicRoute, # type: ignore
+ app_source=DynamicRoute,
) as harness:
yield harness
@@ -113,6 +178,8 @@ def driver(dynamic_route: AppHarness) -> Generator[WebDriver, None, None]:
"""
assert dynamic_route.app_instance is not None, "app is not running"
driver = dynamic_route.frontend()
+ # TODO: drop after flakiness is resolved
+ driver.implicitly_wait(30)
try:
yield driver
finally:
@@ -166,8 +233,11 @@ def poll_for_order(
dynamic_state_name
].order == exp_order
- await AppHarness._poll_for_async(_check)
- assert (await _backend_state()).substates[dynamic_state_name].order == exp_order
+ await AppHarness._poll_for_async(_check, timeout=60)
+ assert (
+ list((await _backend_state()).substates[dynamic_state_name].order)
+ == exp_order
+ )
return _poll_for_order
@@ -305,3 +375,56 @@ async def test_on_load_navigate_non_dynamic(
link.click()
assert urlsplit(driver.current_url).path == "/static/x/"
await poll_for_order(["/static/x-no page id", "/static/x-no page id"])
+
+
+@pytest.mark.asyncio
+async def test_render_dynamic_arg(
+ dynamic_route: AppHarness,
+ driver: WebDriver,
+ token: str,
+):
+ """Assert that dynamic arg var is rendered correctly in different contexts.
+
+ Args:
+ dynamic_route: harness for DynamicRoute app.
+ driver: WebDriver instance.
+ token: The token visible in the driver browser.
+ """
+ assert dynamic_route.app_instance is not None
+ with poll_for_navigation(driver):
+ driver.get(f"{dynamic_route.frontend_url}/arg/0")
+
+ # TODO: drop after flakiness is resolved
+ time.sleep(3)
+
+ def assert_content(expected: str, expect_not: str):
+ ids = [
+ "state-arg_str",
+ "argstate-arg",
+ "argstate-arg_str",
+ "argsubstate-arg_str",
+ "argsubstate-arg",
+ "argsubstate-cached_arg",
+ "argsubstate-cached_arg_str",
+ ]
+ for id in ids:
+ el = driver.find_element(By.ID, id)
+ assert el
+ assert (
+ dynamic_route.poll_for_content(el, timeout=30, exp_not_equal=expect_not)
+ == expected
+ )
+
+ assert_content("0", "")
+ next_page_link = driver.find_element(By.ID, "next-page")
+ assert next_page_link
+ with poll_for_navigation(driver):
+ next_page_link.click()
+ assert driver.current_url == f"{dynamic_route.frontend_url}/arg/1/"
+ assert_content("1", "0")
+ next_page_link = driver.find_element(By.ID, "next-page")
+ assert next_page_link
+ with poll_for_navigation(driver):
+ next_page_link.click()
+ assert driver.current_url == f"{dynamic_route.frontend_url}/arg/2/"
+ assert_content("2", "1")
diff --git a/integration/test_event_actions.py b/tests/integration/test_event_actions.py
similarity index 98%
rename from integration/test_event_actions.py
rename to tests/integration/test_event_actions.py
index e2704fa70..15f3c9877 100644
--- a/integration/test_event_actions.py
+++ b/tests/integration/test_event_actions.py
@@ -24,6 +24,7 @@ def TestEventAction():
def on_click(self, ev):
self.order.append(f"on_click:{ev}")
+ @rx.event
def on_click2(self):
self.order.append("on_click2")
@@ -53,7 +54,7 @@ def TestEventAction():
def index():
return rx.vstack(
- rx.chakra.input(
+ rx.input(
value=EventActionState.router.session.client_token,
is_read_only=True,
id="token",
@@ -146,10 +147,10 @@ def TestEventAction():
200
).stop_propagation,
),
- rx.chakra.list(
+ rx.list( # type: ignore
rx.foreach(
EventActionState.order, # type: ignore
- rx.chakra.list_item,
+ rx.list_item,
),
),
on_click=EventActionState.on_click("outer"), # type: ignore
@@ -170,8 +171,8 @@ def event_action(tmp_path_factory) -> Generator[AppHarness, None, None]:
running AppHarness instance
"""
with AppHarness.create(
- root=tmp_path_factory.mktemp(f"event_action"),
- app_source=TestEventAction, # type: ignore
+ root=tmp_path_factory.mktemp("event_action"),
+ app_source=TestEventAction,
) as harness:
yield harness
diff --git a/integration/test_event_chain.py b/tests/integration/test_event_chain.py
similarity index 97%
rename from integration/test_event_chain.py
rename to tests/integration/test_event_chain.py
index b0feb3e46..c4121ee94 100644
--- a/integration/test_event_chain.py
+++ b/tests/integration/test_event_chain.py
@@ -27,45 +27,55 @@ def EventChain():
event_order: List[str] = []
interim_value: str = ""
+ @rx.event
def event_no_args(self):
self.event_order.append("event_no_args")
+ @rx.event
def event_arg(self, arg):
self.event_order.append(f"event_arg:{arg}")
+ @rx.event
def event_arg_repr_type(self, arg):
self.event_order.append(f"event_arg_repr:{arg!r}_{type(arg).__name__}")
+ @rx.event
def event_nested_1(self):
self.event_order.append("event_nested_1")
yield State.event_nested_2
yield State.event_arg("nested_1") # type: ignore
+ @rx.event
def event_nested_2(self):
self.event_order.append("event_nested_2")
yield State.event_nested_3
yield rx.console_log("event_nested_2")
yield State.event_arg("nested_2") # type: ignore
+ @rx.event
def event_nested_3(self):
self.event_order.append("event_nested_3")
yield State.event_no_args
yield State.event_arg("nested_3") # type: ignore
+ @rx.event
def on_load_return_chain(self):
self.event_order.append("on_load_return_chain")
return [State.event_arg(1), State.event_arg(2), State.event_arg(3)] # type: ignore
+ @rx.event
def on_load_yield_chain(self):
self.event_order.append("on_load_yield_chain")
yield State.event_arg(4) # type: ignore
yield State.event_arg(5) # type: ignore
yield State.event_arg(6) # type: ignore
+ @rx.event
def click_return_event(self):
self.event_order.append("click_return_event")
return State.event_no_args
+ @rx.event
def click_return_events(self):
self.event_order.append("click_return_events")
return [
@@ -75,6 +85,7 @@ def EventChain():
State.event_arg(9), # type: ignore
]
+ @rx.event
def click_yield_chain(self):
self.event_order.append("click_yield_chain:0")
yield State.event_arg(10) # type: ignore
@@ -85,6 +96,7 @@ def EventChain():
yield State.event_arg(12) # type: ignore
self.event_order.append("click_yield_chain:3")
+ @rx.event
def click_yield_many_events(self):
self.event_order.append("click_yield_many_events")
for ix in range(MANY_EVENTS):
@@ -92,33 +104,40 @@ def EventChain():
yield rx.console_log(f"many_events_{ix}")
self.event_order.append("click_yield_many_events_done")
+ @rx.event
def click_yield_nested(self):
self.event_order.append("click_yield_nested")
yield State.event_nested_1
yield State.event_arg("yield_nested") # type: ignore
+ @rx.event
def redirect_return_chain(self):
self.event_order.append("redirect_return_chain")
yield rx.redirect("/on-load-return-chain")
+ @rx.event
def redirect_yield_chain(self):
self.event_order.append("redirect_yield_chain")
yield rx.redirect("/on-load-yield-chain")
+ @rx.event
def click_return_int_type(self):
self.event_order.append("click_return_int_type")
return State.event_arg_repr_type(1) # type: ignore
+ @rx.event
def click_return_dict_type(self):
self.event_order.append("click_return_dict_type")
return State.event_arg_repr_type({"a": 1}) # type: ignore
+ @rx.event
async def click_yield_interim_value_async(self):
self.interim_value = "interim"
yield
await asyncio.sleep(0.5)
self.interim_value = "final"
+ @rx.event
def click_yield_interim_value(self):
self.interim_value = "interim"
yield
@@ -127,7 +146,7 @@ def EventChain():
app = rx.App(state=rx.State)
- token_input = rx.chakra.input(
+ token_input = rx.input(
value=State.router.session.client_token, is_read_only=True, id="token"
)
@@ -135,9 +154,7 @@ def EventChain():
def index():
return rx.fragment(
token_input,
- rx.chakra.input(
- value=State.interim_value, is_read_only=True, id="interim_value"
- ),
+ rx.input(value=State.interim_value, is_read_only=True, id="interim_value"),
rx.button(
"Return Event",
id="return_event",
@@ -260,7 +277,7 @@ def event_chain(tmp_path_factory) -> Generator[AppHarness, None, None]:
"""
with AppHarness.create(
root=tmp_path_factory.mktemp("event_chain"),
- app_source=EventChain, # type: ignore
+ app_source=EventChain,
) as harness:
yield harness
diff --git a/integration/test_exception_handlers.py b/tests/integration/test_exception_handlers.py
similarity index 72%
rename from integration/test_exception_handlers.py
rename to tests/integration/test_exception_handlers.py
index 00683c48b..a645d1de6 100644
--- a/integration/test_exception_handlers.py
+++ b/tests/integration/test_exception_handlers.py
@@ -11,7 +11,9 @@ from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
-from reflex.testing import AppHarness
+from reflex.testing import AppHarness, AppHarnessProd
+
+pytestmark = [pytest.mark.ignore_console_error]
def TestApp():
@@ -26,6 +28,8 @@ def TestApp():
class TestAppState(rx.State):
"""State for the TestApp app."""
+ react_error: bool = False
+
def divide_by_number(self, number: int):
"""Divide by number and print the result.
@@ -50,6 +54,18 @@ def TestApp():
on_click=lambda: TestAppState.divide_by_number(0), # type: ignore
id="induce-backend-error-btn",
),
+ rx.button(
+ "induce_react_error",
+ on_click=TestAppState.set_react_error(True), # type: ignore
+ id="induce-react-error-btn",
+ ),
+ rx.box(
+ rx.cond(
+ TestAppState.react_error,
+ rx.Var.create({"invalid": "cannot have object as child"}),
+ "",
+ ),
+ ),
)
@@ -70,7 +86,7 @@ def test_app(
with app_harness_env.create(
root=tmp_path_factory.mktemp("test_app"),
app_name=f"testapp_{app_harness_env.__name__.lower()}",
- app_source=TestApp, # type: ignore
+ app_source=TestApp,
) as harness:
yield harness
@@ -152,3 +168,37 @@ def test_backend_exception_handler_during_runtime(
"divide_by_number" in captured_default_handler_output.out
and "ZeroDivisionError" in captured_default_handler_output.out
)
+
+
+def test_frontend_exception_handler_with_react(
+ test_app: AppHarness,
+ driver: WebDriver,
+ capsys,
+):
+ """Test calling frontend exception handler during runtime.
+
+ Render an object as a react child, which is invalid.
+
+ Args:
+ test_app: harness for TestApp app
+ driver: WebDriver instance.
+ capsys: pytest fixture for capturing stdout and stderr.
+
+ """
+ reset_button = WebDriverWait(driver, 20).until(
+ EC.element_to_be_clickable((By.ID, "induce-react-error-btn"))
+ )
+
+ reset_button.click()
+
+ # Wait for the error to be logged
+ time.sleep(2)
+
+ captured_default_handler_output = capsys.readouterr()
+ if isinstance(test_app, AppHarnessProd):
+ assert "Error: Minified React error #31" in captured_default_handler_output.out
+ else:
+ assert (
+ "Error: Objects are not valid as a React child (found: object with keys \n{invalid})"
+ in captured_default_handler_output.out
+ )
diff --git a/integration/test_form_submit.py b/tests/integration/test_form_submit.py
similarity index 76%
rename from integration/test_form_submit.py
rename to tests/integration/test_form_submit.py
index c9eb45146..ea8750595 100644
--- a/integration/test_form_submit.py
+++ b/tests/integration/test_form_submit.py
@@ -35,28 +35,29 @@ def FormSubmit(form_component):
@app.add_page
def index():
return rx.vstack(
- rx.chakra.input(
+ rx.input(
value=FormState.router.session.client_token,
is_read_only=True,
id="token",
),
eval(form_component)(
rx.vstack(
- rx.chakra.input(id="name_input"),
- rx.hstack(rx.chakra.pin_input(length=4, id="pin_input")),
- rx.chakra.number_input(id="number_input"),
+ rx.input(id="name_input"),
rx.checkbox(id="bool_input"),
rx.switch(id="bool_input2"),
rx.checkbox(id="bool_input3"),
rx.switch(id="bool_input4"),
rx.slider(id="slider_input", default_value=[50], width="100%"),
- rx.chakra.range_slider(id="range_input"),
rx.radio(["option1", "option2"], id="radio_input"),
rx.radio(FormState.var_options, id="radio_input_var"),
- rx.chakra.select(["option1", "option2"], id="select_input"),
- rx.chakra.select(FormState.var_options, id="select_input_var"),
+ rx.select(
+ ["option1", "option2"],
+ name="select_input",
+ default_value="option1",
+ ),
+ rx.select(FormState.var_options, id="select_input_var"),
rx.text_area(id="text_area_input"),
- rx.chakra.input(
+ rx.input(
id="debounce_input",
debounce_timeout=0,
on_change=rx.console_log,
@@ -94,22 +95,19 @@ def FormSubmitName(form_component):
@app.add_page
def index():
return rx.vstack(
- rx.chakra.input(
+ rx.input(
value=FormState.router.session.client_token,
is_read_only=True,
id="token",
),
eval(form_component)(
rx.vstack(
- rx.chakra.input(name="name_input"),
- rx.hstack(rx.chakra.pin_input(length=4, name="pin_input")),
- rx.chakra.number_input(name="number_input"),
+ rx.input(name="name_input"),
rx.checkbox(name="bool_input"),
rx.switch(name="bool_input2"),
rx.checkbox(name="bool_input3"),
rx.switch(name="bool_input4"),
rx.slider(name="slider_input", default_value=[50], width="100%"),
- rx.chakra.range_slider(name="range_input"),
rx.radio(FormState.options, name="radio_input"),
rx.select(
FormState.options,
@@ -117,21 +115,13 @@ def FormSubmitName(form_component):
default_value=FormState.options[0],
),
rx.text_area(name="text_area_input"),
- rx.chakra.input_group(
- rx.chakra.input_left_element(rx.icon(tag="chevron_right")),
- rx.chakra.input(
- name="debounce_input",
- debounce_timeout=0,
- on_change=rx.console_log,
- ),
- rx.chakra.input_right_element(rx.icon(tag="chevron_left")),
- ),
- rx.chakra.button_group(
- rx.button("Submit", type_="submit"),
- rx.icon_button(FormState.val, icon=rx.icon(tag="plus")),
- variant="outline",
- is_attached=True,
+ rx.input(
+ name="debounce_input",
+ debounce_timeout=0,
+ on_change=rx.console_log,
),
+ rx.button("Submit", type_="submit"),
+ rx.icon_button(rx.icon(tag="plus")),
),
on_submit=FormState.form_submit,
custom_attrs={"action": "/invalid"},
@@ -148,16 +138,12 @@ def FormSubmitName(form_component):
functools.partial(FormSubmitName, form_component="rx.form.root"),
functools.partial(FormSubmit, form_component="rx.el.form"),
functools.partial(FormSubmitName, form_component="rx.el.form"),
- functools.partial(FormSubmit, form_component="rx.chakra.form"),
- functools.partial(FormSubmitName, form_component="rx.chakra.form"),
],
ids=[
"id-radix",
"name-radix",
"id-html",
"name-html",
- "id-chakra",
- "name-chakra",
],
)
def form_submit(request, tmp_path_factory) -> Generator[AppHarness, None, None]:
@@ -173,7 +159,7 @@ def form_submit(request, tmp_path_factory) -> Generator[AppHarness, None, None]:
param_id = request._pyfuncitem.callspec.id.replace("-", "_")
with AppHarness.create(
root=tmp_path_factory.mktemp("form_submit"),
- app_source=request.param, # type: ignore
+ app_source=request.param,
app_name=request.param.func.__name__ + f"_{param_id}",
) as harness:
assert harness.app_instance is not None, "app is not running"
@@ -220,16 +206,6 @@ async def test_submit(driver, form_submit: AppHarness):
name_input = driver.find_element(by, "name_input")
name_input.send_keys("foo")
- pin_inputs = driver.find_elements(By.CLASS_NAME, "chakra-pin-input")
- pin_values = ["8", "1", "6", "4"]
- for i, pin_input in enumerate(pin_inputs):
- pin_input.send_keys(pin_values[i])
-
- number_input = driver.find_element(By.CLASS_NAME, "chakra-numberinput")
- buttons = number_input.find_elements(By.XPATH, "//div[@role='button']")
- for _ in range(3):
- buttons[1].click()
-
checkbox_input = driver.find_element(By.XPATH, "//button[@role='checkbox']")
checkbox_input.click()
@@ -268,16 +244,15 @@ async def test_submit(driver, form_submit: AppHarness):
form_data = format.collect_form_dict_names(form_data)
+ print(form_data)
+
assert form_data["name_input"] == "foo"
- assert form_data["pin_input"] == pin_values
- assert form_data["number_input"] == "-3"
assert form_data["bool_input"]
assert form_data["bool_input2"]
assert not form_data.get("bool_input3", False)
assert not form_data.get("bool_input4", False)
assert form_data["slider_input"] == "50"
- assert form_data["range_input"] == ["25", "75"]
assert form_data["radio_input"] == "option2"
assert form_data["select_input"] == "option1"
assert form_data["text_area_input"] == "Some\nText"
diff --git a/integration/test_input.py b/tests/integration/test_input.py
similarity index 96%
rename from integration/test_input.py
rename to tests/integration/test_input.py
index 4679104a4..e9fec7dc1 100644
--- a/integration/test_input.py
+++ b/tests/integration/test_input.py
@@ -63,7 +63,7 @@ def fully_controlled_input(tmp_path) -> Generator[AppHarness, None, None]:
"""
with AppHarness.create(
root=tmp_path,
- app_source=FullyControlledInput, # type: ignore
+ app_source=FullyControlledInput,
) as harness:
yield harness
@@ -183,6 +183,6 @@ async def test_fully_controlled_input(fully_controlled_input: AppHarness):
clear_button.click()
assert AppHarness._poll_for(lambda: on_change_input.get_attribute("value") == "")
# potential bug: clearing the on_change field doesn't itself trigger on_change
- # assert backend_state.text == ""
- # assert debounce_input.get_attribute("value") == ""
- # assert value_input.get_attribute("value") == ""
+ # assert backend_state.text == "" #noqa: ERA001
+ # assert debounce_input.get_attribute("value") == "" #noqa: ERA001
+ # assert value_input.get_attribute("value") == "" #noqa: ERA001
diff --git a/integration/test_large_state.py b/tests/integration/test_large_state.py
similarity index 97%
rename from integration/test_large_state.py
rename to tests/integration/test_large_state.py
index 23a534a2b..a9a8ff2ec 100644
--- a/integration/test_large_state.py
+++ b/tests/integration/test_large_state.py
@@ -58,7 +58,7 @@ def test_large_state(var_count: int, tmp_path_factory, benchmark):
large_state_rendered = template.render(var_count=var_count)
with AppHarness.create(
- root=tmp_path_factory.mktemp(f"large_state"),
+ root=tmp_path_factory.mktemp("large_state"),
app_source=large_state_rendered,
app_name="large_state",
) as large_state:
diff --git a/integration/test_lifespan.py b/tests/integration/test_lifespan.py
similarity index 98%
rename from integration/test_lifespan.py
rename to tests/integration/test_lifespan.py
index f8bcf2397..cb6c640ab 100644
--- a/integration/test_lifespan.py
+++ b/tests/integration/test_lifespan.py
@@ -51,6 +51,7 @@ def LifespanApp():
def context_global(self) -> int:
return lifespan_context_global
+ @rx.event
def tick(self, date):
pass
@@ -79,7 +80,7 @@ def lifespan_app(tmp_path) -> Generator[AppHarness, None, None]:
"""
with AppHarness.create(
root=tmp_path,
- app_source=LifespanApp, # type: ignore
+ app_source=LifespanApp,
) as harness:
yield harness
diff --git a/integration/test_login_flow.py b/tests/integration/test_login_flow.py
similarity index 98%
rename from integration/test_login_flow.py
rename to tests/integration/test_login_flow.py
index 7d583e433..1938672a3 100644
--- a/integration/test_login_flow.py
+++ b/tests/integration/test_login_flow.py
@@ -21,9 +21,11 @@ def LoginSample():
class State(rx.State):
auth_token: str = rx.LocalStorage("")
+ @rx.event
def logout(self):
self.set_auth_token("")
+ @rx.event
def login(self):
self.set_auth_token("12345")
yield rx.redirect("/")
@@ -60,7 +62,7 @@ def login_sample(tmp_path_factory) -> Generator[AppHarness, None, None]:
"""
with AppHarness.create(
root=tmp_path_factory.mktemp("login_sample"),
- app_source=LoginSample, # type: ignore
+ app_source=LoginSample,
) as harness:
yield harness
diff --git a/integration/test_media.py b/tests/integration/test_media.py
similarity index 99%
rename from integration/test_media.py
rename to tests/integration/test_media.py
index c10f7102b..10af26591 100644
--- a/integration/test_media.py
+++ b/tests/integration/test_media.py
@@ -84,7 +84,7 @@ def media_app(tmp_path) -> Generator[AppHarness, None, None]:
"""
with AppHarness.create(
root=tmp_path,
- app_source=MediaApp, # type: ignore
+ app_source=MediaApp,
) as harness:
yield harness
diff --git a/integration/test_navigation.py b/tests/integration/test_navigation.py
similarity index 95%
rename from integration/test_navigation.py
rename to tests/integration/test_navigation.py
index 492ae4510..4e81e4155 100644
--- a/integration/test_navigation.py
+++ b/tests/integration/test_navigation.py
@@ -52,7 +52,7 @@ def navigation_app(tmp_path) -> Generator[AppHarness, None, None]:
"""
with AppHarness.create(
root=tmp_path,
- app_source=NavigationApp, # type: ignore
+ app_source=NavigationApp,
) as harness:
yield harness
@@ -74,7 +74,7 @@ async def test_navigation_app(navigation_app: AppHarness):
with poll_for_navigation(driver):
internal_link.click()
- assert urlsplit(driver.current_url).path == f"/internal/"
+ assert urlsplit(driver.current_url).path == "/internal/"
with poll_for_navigation(driver):
driver.back()
diff --git a/integration/test_server_side_event.py b/tests/integration/test_server_side_event.py
similarity index 94%
rename from integration/test_server_side_event.py
rename to tests/integration/test_server_side_event.py
index 9bb20c345..f04cc3beb 100644
--- a/integration/test_server_side_event.py
+++ b/tests/integration/test_server_side_event.py
@@ -14,16 +14,19 @@ def ServerSideEvent():
import reflex as rx
class SSState(rx.State):
+ @rx.event
def set_value_yield(self):
yield rx.set_value("a", "")
yield rx.set_value("b", "")
yield rx.set_value("c", "")
+ @rx.event
def set_value_yield_return(self):
yield rx.set_value("a", "")
yield rx.set_value("b", "")
return rx.set_value("c", "")
+ @rx.event
def set_value_return(self):
return [
rx.set_value("a", ""),
@@ -31,6 +34,7 @@ def ServerSideEvent():
rx.set_value("c", ""),
]
+ @rx.event
def set_value_return_c(self):
return rx.set_value("c", "")
@@ -39,12 +43,12 @@ def ServerSideEvent():
@app.add_page
def index():
return rx.fragment(
- rx.chakra.input(
+ rx.input(
id="token", value=SSState.router.session.client_token, is_read_only=True
),
- rx.chakra.input(default_value="a", id="a"),
- rx.chakra.input(default_value="b", id="b"),
- rx.chakra.input(default_value="c", id="c"),
+ rx.input(default_value="a", id="a"),
+ rx.input(default_value="b", id="b"),
+ rx.input(default_value="c", id="c"),
rx.button(
"Clear Immediate",
id="clear_immediate",
@@ -89,7 +93,7 @@ def server_side_event(tmp_path_factory) -> Generator[AppHarness, None, None]:
"""
with AppHarness.create(
root=tmp_path_factory.mktemp("server_side_event"),
- app_source=ServerSideEvent, # type: ignore
+ app_source=ServerSideEvent,
) as harness:
yield harness
@@ -98,7 +102,6 @@ def server_side_event(tmp_path_factory) -> Generator[AppHarness, None, None]:
def driver(server_side_event: AppHarness):
"""Get an instance of the browser open to the server_side_event app.
-
Args:
server_side_event: harness for ServerSideEvent app
diff --git a/integration/test_shared_state.py b/tests/integration/test_shared_state.py
similarity index 93%
rename from integration/test_shared_state.py
rename to tests/integration/test_shared_state.py
index a1a3d6080..410669381 100644
--- a/integration/test_shared_state.py
+++ b/tests/integration/test_shared_state.py
@@ -12,7 +12,7 @@ from reflex.testing import AppHarness, WebDriver
def SharedStateApp():
"""Test that shared state works as expected."""
import reflex as rx
- from integration.shared.state import SharedState
+ from tests.integration.shared.state import SharedState
class State(SharedState):
pass
@@ -39,7 +39,7 @@ def shared_state(
"""
with AppHarness.create(
root=tmp_path_factory.mktemp("shared_state"),
- app_source=SharedStateApp, # type: ignore
+ app_source=SharedStateApp,
) as harness:
yield harness
diff --git a/integration/test_state_inheritance.py b/tests/integration/test_state_inheritance.py
similarity index 98%
rename from integration/test_state_inheritance.py
rename to tests/integration/test_state_inheritance.py
index 86ab625e1..6b93a2ed7 100644
--- a/integration/test_state_inheritance.py
+++ b/tests/integration/test_state_inheritance.py
@@ -73,7 +73,7 @@ def StateInheritance():
def on_click_other_mixin(self):
self.other_mixin_clicks += 1
self.other_mixin = (
- f"{self.__class__.__name__}.clicked.{self.other_mixin_clicks}"
+ f"{type(self).__name__}.clicked.{self.other_mixin_clicks}"
)
class Base1(Mixin, rx.State):
@@ -216,8 +216,8 @@ def state_inheritance(
running AppHarness instance
"""
with AppHarness.create(
- root=tmp_path_factory.mktemp(f"state_inheritance"),
- app_source=StateInheritance, # type: ignore
+ root=tmp_path_factory.mktemp("state_inheritance"),
+ app_source=StateInheritance,
) as harness:
yield harness
diff --git a/integration/test_tailwind.py b/tests/integration/test_tailwind.py
similarity index 97%
rename from integration/test_tailwind.py
rename to tests/integration/test_tailwind.py
index c7320cb21..eb0fde759 100644
--- a/integration/test_tailwind.py
+++ b/tests/integration/test_tailwind.py
@@ -34,7 +34,7 @@ def TailwindApp(
def index():
return rx.el.div(
- rx.chakra.text(paragraph_text, class_name=paragraph_class_name),
+ rx.text(paragraph_text, class_name=paragraph_class_name),
rx.el.p(paragraph_text, class_name=paragraph_class_name),
rx.text(paragraph_text, as_="p", class_name=paragraph_class_name),
rx.el.div("Test external stylesheet", class_name="external"),
@@ -78,7 +78,7 @@ def tailwind_app(tmp_path, tailwind_disabled) -> Generator[AppHarness, None, Non
"""
with AppHarness.create(
root=tmp_path,
- app_source=functools.partial(TailwindApp, tailwind_disabled=tailwind_disabled), # type: ignore
+ app_source=functools.partial(TailwindApp, tailwind_disabled=tailwind_disabled),
app_name="tailwind_disabled_app" if tailwind_disabled else "tailwind_app",
) as harness:
yield harness
diff --git a/integration/test_upload.py b/tests/integration/test_upload.py
similarity index 85%
rename from integration/test_upload.py
rename to tests/integration/test_upload.py
index 77199ca4e..156cf0e45 100644
--- a/integration/test_upload.py
+++ b/tests/integration/test_upload.py
@@ -4,6 +4,7 @@ from __future__ import annotations
import asyncio
import time
+from pathlib import Path
from typing import Generator
import pytest
@@ -18,10 +19,14 @@ def UploadFile():
import reflex as rx
+ LARGE_DATA = "DUMMY" * 1024 * 512
+
class UploadState(rx.State):
_file_data: Dict[str, str] = {}
event_order: List[str] = []
progress_dicts: List[dict] = []
+ disabled: bool = False
+ large_data: str = ""
async def handle_upload(self, files: List[rx.UploadFile]):
for file in files:
@@ -32,6 +37,7 @@ def UploadFile():
for file in files:
upload_data = await file.read()
self._file_data[file.filename or ""] = upload_data.decode("utf-8")
+ self.large_data = LARGE_DATA
yield UploadState.chain_event
def upload_progress(self, progress):
@@ -40,13 +46,15 @@ def UploadFile():
self.progress_dicts.append(progress)
def chain_event(self):
+ assert self.large_data == LARGE_DATA
+ self.large_data = ""
self.event_order.append("chain_event")
def index():
return rx.vstack(
- rx.chakra.input(
+ rx.input(
value=UploadState.router.session.client_token,
- is_read_only=True,
+ read_only=True,
id="token",
),
rx.heading("Default Upload"),
@@ -55,6 +63,7 @@ def UploadFile():
rx.button("Select File"),
rx.text("Drag and drop files here or click to select files"),
),
+ disabled=UploadState.disabled,
),
rx.button(
"Upload",
@@ -132,7 +141,7 @@ def upload_file(tmp_path_factory) -> Generator[AppHarness, None, None]:
"""
with AppHarness.create(
root=tmp_path_factory.mktemp("upload_file"),
- app_source=UploadFile, # type: ignore
+ app_source=UploadFile,
) as harness:
yield harness
@@ -205,11 +214,12 @@ async def test_upload_file(
file_data = await AppHarness._poll_for_async(get_file_data)
assert isinstance(file_data, dict)
- assert file_data[exp_name] == exp_contents
+ normalized_file_data = {Path(k).name: v for k, v in file_data.items()}
+ assert normalized_file_data[Path(exp_name).name] == exp_contents
# check that the selected files are displayed
selected_files = driver.find_element(By.ID, f"selected_files{suffix}")
- assert selected_files.text == exp_name
+ assert Path(selected_files.text).name == Path(exp_name).name
state = await upload_file.get_state(substate_token)
if secondary:
@@ -256,7 +266,9 @@ async def test_upload_file_multiple(tmp_path, upload_file: AppHarness, driver):
# check that the selected files are displayed
selected_files = driver.find_element(By.ID, "selected_files")
- assert selected_files.text == "\n".join(exp_files)
+ assert [Path(name).name for name in selected_files.text.split("\n")] == [
+ Path(name).name for name in exp_files
+ ]
# do the upload
upload_button.click()
@@ -271,8 +283,9 @@ async def test_upload_file_multiple(tmp_path, upload_file: AppHarness, driver):
file_data = await AppHarness._poll_for_async(get_file_data)
assert isinstance(file_data, dict)
+ normalized_file_data = {Path(k).name: v for k, v in file_data.items()}
for exp_name, exp_contents in exp_files.items():
- assert file_data[exp_name] == exp_contents
+ assert normalized_file_data[Path(exp_name).name] == exp_contents
@pytest.mark.parametrize("secondary", [False, True])
@@ -317,7 +330,9 @@ def test_clear_files(
# check that the selected files are displayed
selected_files = driver.find_element(By.ID, f"selected_files{suffix}")
- assert selected_files.text == "\n".join(exp_files)
+ assert [Path(name).name for name in selected_files.text.split("\n")] == [
+ Path(name).name for name in exp_files
+ ]
clear_button = driver.find_element(By.ID, f"clear_button{suffix}")
assert clear_button
@@ -352,8 +367,8 @@ async def test_cancel_upload(tmp_path, upload_file: AppHarness, driver: WebDrive
substate_token = f"{token}_{state_full_name}"
upload_box = driver.find_elements(By.XPATH, "//input[@type='file']")[1]
- upload_button = driver.find_element(By.ID, f"upload_button_secondary")
- cancel_button = driver.find_element(By.ID, f"cancel_button_secondary")
+ upload_button = driver.find_element(By.ID, "upload_button_secondary")
+ cancel_button = driver.find_element(By.ID, "cancel_button_secondary")
exp_name = "large.txt"
target_file = tmp_path / exp_name
@@ -366,9 +381,25 @@ async def test_cancel_upload(tmp_path, upload_file: AppHarness, driver: WebDrive
await asyncio.sleep(0.3)
cancel_button.click()
- # look up the backend state and assert on progress
+ # Wait a bit for the upload to get cancelled.
+ await asyncio.sleep(0.5)
+
+ # Get interim progress dicts saved in the on_upload_progress handler.
+ async def _progress_dicts():
+ state = await upload_file.get_state(substate_token)
+ return state.substates[state_name].progress_dicts
+
+ # We should have _some_ progress
+ assert await AppHarness._poll_for_async(_progress_dicts)
+
+ # But there should never be a final progress record for a cancelled upload.
+ for p in await _progress_dicts():
+ assert p["progress"] != 1
+
state = await upload_file.get_state(substate_token)
- assert state.substates[state_name].progress_dicts
- assert exp_name not in state.substates[state_name]._file_data
+ file_data = state.substates[state_name]._file_data
+ assert isinstance(file_data, dict)
+ normalized_file_data = {Path(k).name: v for k, v in file_data.items()}
+ assert Path(exp_name).name not in normalized_file_data
target_file.unlink()
diff --git a/tests/integration/test_urls.py b/tests/integration/test_urls.py
new file mode 100755
index 000000000..81689aa18
--- /dev/null
+++ b/tests/integration/test_urls.py
@@ -0,0 +1,68 @@
+"""Integration tests for all urls in Reflex."""
+
+import os
+import re
+from pathlib import Path
+
+import pytest
+import requests
+
+
+def check_urls(repo_dir: Path):
+ """Check that all URLs in the repo are valid and secure.
+
+ Args:
+ repo_dir: The directory of the repo.
+
+ Returns:
+ A list of errors.
+ """
+ url_pattern = re.compile(r'http[s]?://reflex\.dev[^\s")]*')
+ errors = []
+
+ for root, _dirs, files in os.walk(repo_dir):
+ root = Path(root)
+ if root.stem == "__pycache__":
+ continue
+
+ for file_name in files:
+ if not file_name.endswith(".py") and not file_name.endswith(".md"):
+ continue
+
+ file_path = root / file_name
+ try:
+ for line in file_path.read_text().splitlines():
+ urls = url_pattern.findall(line)
+ for url in set(urls):
+ if url.startswith("http://"):
+ errors.append(
+ f"Found insecure HTTP URL: {url} in {file_path}"
+ )
+ url = url.strip('"\n')
+ try:
+ response = requests.head(
+ url, allow_redirects=True, timeout=5
+ )
+ response.raise_for_status()
+ except requests.RequestException as e:
+ errors.append(
+ f"Error accessing URL: {url} in {file_path} | Error: {e}, , Check your path ends with a /"
+ )
+ except Exception as e:
+ errors.append(f"Error reading file: {file_path} | Error: {e}")
+
+ return errors
+
+
+@pytest.mark.parametrize(
+ "repo_dir",
+ [Path(__file__).resolve().parent.parent / "reflex"],
+)
+def test_find_and_check_urls(repo_dir: Path):
+ """Test that all URLs in the repo are valid and secure.
+
+ Args:
+ repo_dir: The directory of the repo.
+ """
+ errors = check_urls(repo_dir)
+ assert not errors, "\n".join(errors)
diff --git a/integration/test_var_operations.py b/tests/integration/test_var_operations.py
similarity index 94%
rename from integration/test_var_operations.py
rename to tests/integration/test_var_operations.py
index 5cf644ca2..7a7c8328d 100644
--- a/integration/test_var_operations.py
+++ b/tests/integration/test_var_operations.py
@@ -15,6 +15,11 @@ def VarOperations():
from typing import Dict, List
import reflex as rx
+ from reflex.vars.base import LiteralVar
+ from reflex.vars.sequence import ArrayVar
+
+ class Object(rx.Base):
+ str: str = "hello"
class VarOperationState(rx.State):
int_var1: int = 10
@@ -25,12 +30,13 @@ def VarOperations():
list1: List = [1, 2]
list2: List = [3, 4]
list3: List = ["first", "second", "third"]
+ list4: List = [Object(name="obj_1"), Object(name="obj_2")]
str_var1: str = "first"
str_var2: str = "second"
str_var3: str = "ThIrD"
str_var4: str = "a long string"
- dict1: Dict = {1: 2}
- dict2: Dict = {3: 4}
+ dict1: Dict[int, int] = {1: 2}
+ dict2: Dict[int, int] = {3: 4}
html_str: str = "
hello
"
app = rx.App(state=rx.State)
@@ -470,6 +476,7 @@ def VarOperations():
rx.text(
VarOperationState.list1.contains(1).to_string(), id="list_contains"
),
+ rx.text(VarOperationState.list4.pluck("name").to_string(), id="list_pluck"),
rx.text(VarOperationState.list1.reverse().to_string(), id="list_reverse"),
# LIST, INT
rx.text(
@@ -543,33 +550,30 @@ def VarOperations():
VarOperationState.html_str,
id="html_str",
),
- rx.chakra.highlight(
- "second",
- query=[VarOperationState.str_var2],
- ),
- rx.text(rx.Var.range(2, 5).join(","), id="list_join_range1"),
- rx.text(rx.Var.range(2, 10, 2).join(","), id="list_join_range2"),
- rx.text(rx.Var.range(5, 0, -1).join(","), id="list_join_range3"),
- rx.text(rx.Var.range(0, 3).join(","), id="list_join_range4"),
+ rx.el.mark("second"),
+ rx.text(ArrayVar.range(2, 5).join(","), id="list_join_range1"),
+ rx.text(ArrayVar.range(2, 10, 2).join(","), id="list_join_range2"),
+ rx.text(ArrayVar.range(5, 0, -1).join(","), id="list_join_range3"),
+ rx.text(ArrayVar.range(0, 3).join(","), id="list_join_range4"),
rx.box(
rx.foreach(
- rx.Var.range(0, 2),
+ ArrayVar.range(0, 2),
lambda x: rx.text(VarOperationState.list1[x], as_="p"),
),
id="foreach_list_arg",
),
rx.box(
rx.foreach(
- rx.Var.range(0, 2),
+ ArrayVar.range(0, 2),
lambda x, ix: rx.text(VarOperationState.list1[ix], as_="p"),
),
id="foreach_list_ix",
),
rx.box(
rx.foreach(
- rx.Var.create_safe(list(range(0, 3))).to(List[int]),
+ LiteralVar.create(list(range(0, 3))).to(ArrayVar, List[int]),
lambda x: rx.foreach(
- rx.Var.range(x),
+ ArrayVar.range(x),
lambda y: rx.text(VarOperationState.list1[y], as_="p"),
),
),
@@ -584,6 +588,16 @@ def VarOperations():
int_var2=VarOperationState.int_var2,
id="memo_comp_nested",
),
+ # foreach in a match
+ rx.box(
+ rx.match(
+ VarOperationState.list3.length(),
+ (0, rx.text("No choices")),
+ (1, rx.text("One choice")),
+ rx.foreach(VarOperationState.list3, lambda choice: rx.text(choice)),
+ ),
+ id="foreach_in_match",
+ ),
)
@@ -599,7 +613,7 @@ def var_operations(tmp_path_factory) -> Generator[AppHarness, None, None]:
"""
with AppHarness.create(
root=tmp_path_factory.mktemp("var_operations"),
- app_source=VarOperations, # type: ignore
+ app_source=VarOperations,
) as harness:
assert harness.app_instance is not None, "app is not running"
yield harness
@@ -745,6 +759,7 @@ def test_var_operations(driver, var_operations: AppHarness):
("list_and_list", "[3,4]"),
("list_or_list", "[1,2]"),
("list_contains", "true"),
+ ("list_pluck", '["obj_1","obj_2"]'),
("list_reverse", "[2,1]"),
("list_join", "firstsecondthird"),
("list_join_comma", "first,second,third"),
@@ -780,9 +795,12 @@ def test_var_operations(driver, var_operations: AppHarness):
# rx.memo component with state
("memo_comp", "1210"),
("memo_comp_nested", "345"),
+ # foreach in a match
+ ("foreach_in_match", "first\nsecond\nthird"),
]
for tag, expected in tests:
+ print(tag)
assert driver.find_element(By.ID, tag).text == expected
# Highlight component with var query (does not plumb ID)
diff --git a/tests/integration/tests_playwright/test_appearance.py b/tests/integration/tests_playwright/test_appearance.py
new file mode 100644
index 000000000..60aeeaa6b
--- /dev/null
+++ b/tests/integration/tests_playwright/test_appearance.py
@@ -0,0 +1,218 @@
+from typing import Generator
+
+import pytest
+from playwright.sync_api import Page, expect
+
+from reflex.testing import AppHarness
+
+
+def DefaultLightModeApp():
+ import reflex as rx
+ from reflex.style import color_mode
+
+ app = rx.App(theme=rx.theme(appearance="light"))
+
+ @app.add_page
+ def index():
+ return rx.text(color_mode)
+
+
+def DefaultDarkModeApp():
+ import reflex as rx
+ from reflex.style import color_mode
+
+ app = rx.App(theme=rx.theme(appearance="dark"))
+
+ @app.add_page
+ def index():
+ return rx.text(color_mode)
+
+
+def DefaultSystemModeApp():
+ import reflex as rx
+ from reflex.style import color_mode
+
+ app = rx.App()
+
+ @app.add_page
+ def index():
+ return rx.text(color_mode)
+
+
+def ColorToggleApp():
+ import reflex as rx
+ from reflex.style import color_mode, resolved_color_mode, set_color_mode
+
+ app = rx.App(theme=rx.theme(appearance="light"))
+
+ @app.add_page
+ def index():
+ return rx.box(
+ rx.segmented_control.root(
+ rx.segmented_control.item(
+ rx.icon(tag="monitor", size=20),
+ value="system",
+ ),
+ rx.segmented_control.item(
+ rx.icon(tag="sun", size=20),
+ value="light",
+ ),
+ rx.segmented_control.item(
+ rx.icon(tag="moon", size=20),
+ value="dark",
+ ),
+ on_change=set_color_mode,
+ variant="classic",
+ radius="large",
+ value=color_mode,
+ ),
+ rx.text(color_mode, id="current_color_mode"),
+ rx.text(resolved_color_mode, id="resolved_color_mode"),
+ rx.text(rx.color_mode_cond("LightMode", "DarkMode"), id="color_mode_cond"),
+ )
+
+
+@pytest.fixture()
+def light_mode_app(tmp_path_factory) -> Generator[AppHarness, None, None]:
+ """Start DefaultLightMode app at tmp_path via AppHarness.
+
+ Args:
+ tmp_path_factory: pytest tmp_path_factory fixture
+
+ Yields:
+ running AppHarness instance
+
+ """
+ with AppHarness.create(
+ root=tmp_path_factory.mktemp("appearance_app"),
+ app_source=DefaultLightModeApp, # type: ignore
+ ) as harness:
+ assert harness.app_instance is not None, "app is not running"
+ yield harness
+
+
+@pytest.fixture()
+def dark_mode_app(tmp_path_factory) -> Generator[AppHarness, None, None]:
+ """Start DefaultDarkMode app at tmp_path via AppHarness.
+
+ Args:
+ tmp_path_factory: pytest tmp_path_factory fixture
+
+ Yields:
+ running AppHarness instance
+
+ """
+ with AppHarness.create(
+ root=tmp_path_factory.mktemp("appearance_app"),
+ app_source=DefaultDarkModeApp, # type: ignore
+ ) as harness:
+ assert harness.app_instance is not None, "app is not running"
+ yield harness
+
+
+@pytest.fixture()
+def system_mode_app(tmp_path_factory) -> Generator[AppHarness, None, None]:
+ """Start DefaultSystemMode app at tmp_path via AppHarness.
+
+ Args:
+ tmp_path_factory: pytest tmp_path_factory fixture
+
+ Yields:
+ running AppHarness instance
+
+ """
+ with AppHarness.create(
+ root=tmp_path_factory.mktemp("appearance_app"),
+ app_source=DefaultSystemModeApp, # type: ignore
+ ) as harness:
+ assert harness.app_instance is not None, "app is not running"
+ yield harness
+
+
+@pytest.fixture()
+def color_toggle_app(tmp_path_factory) -> Generator[AppHarness, None, None]:
+ """Start ColorToggle app at tmp_path via AppHarness.
+
+ Args:
+ tmp_path_factory: pytest tmp_path_factory fixture
+
+ Yields:
+ running AppHarness instance
+
+ """
+ with AppHarness.create(
+ root=tmp_path_factory.mktemp("appearance_app"),
+ app_source=ColorToggleApp, # type: ignore
+ ) as harness:
+ assert harness.app_instance is not None, "app is not running"
+ yield harness
+
+
+def test_appearance_light_mode(light_mode_app: AppHarness, page: Page):
+ assert light_mode_app.frontend_url is not None
+ page.goto(light_mode_app.frontend_url)
+
+ expect(page.get_by_text("light")).to_be_visible()
+
+
+def test_appearance_dark_mode(dark_mode_app: AppHarness, page: Page):
+ assert dark_mode_app.frontend_url is not None
+ page.goto(dark_mode_app.frontend_url)
+
+ expect(page.get_by_text("dark")).to_be_visible()
+
+
+def test_appearance_system_mode(system_mode_app: AppHarness, page: Page):
+ assert system_mode_app.frontend_url is not None
+ page.goto(system_mode_app.frontend_url)
+
+ expect(page.get_by_text("system")).to_be_visible()
+
+
+def test_appearance_color_toggle(color_toggle_app: AppHarness, page: Page):
+ assert color_toggle_app.frontend_url is not None
+ page.goto(color_toggle_app.frontend_url)
+
+ # Radio buttons locators.
+ radio_system = page.get_by_role("radio").nth(0)
+ radio_light = page.get_by_role("radio").nth(1)
+ radio_dark = page.get_by_role("radio").nth(2)
+
+ # Text locators to check.
+ current_color_mode = page.locator("id=current_color_mode")
+ resolved_color_mode = page.locator("id=resolved_color_mode")
+ color_mode_cond = page.locator("id=color_mode_cond")
+ root_body = page.locator('div[data-is-root-theme="true"]')
+
+ # Background colors.
+ dark_background = "rgb(17, 17, 19)" # value based on dark native appearance, can change depending on the browser
+ light_background = "rgb(255, 255, 255)"
+
+ # check initial state
+ expect(current_color_mode).to_have_text("light")
+ expect(resolved_color_mode).to_have_text("light")
+ expect(color_mode_cond).to_have_text("LightMode")
+ expect(root_body).to_have_css("background-color", light_background)
+
+ # click dark mode
+ radio_dark.click()
+ expect(current_color_mode).to_have_text("dark")
+ expect(resolved_color_mode).to_have_text("dark")
+ expect(color_mode_cond).to_have_text("DarkMode")
+ expect(root_body).to_have_css("background-color", dark_background)
+
+ # click light mode
+ radio_light.click()
+ expect(current_color_mode).to_have_text("light")
+ expect(resolved_color_mode).to_have_text("light")
+ expect(color_mode_cond).to_have_text("LightMode")
+ expect(root_body).to_have_css("background-color", light_background)
+ page.reload()
+ expect(root_body).to_have_css("background-color", light_background)
+
+ # click system mode
+ radio_system.click()
+ expect(current_color_mode).to_have_text("system")
+ expect(resolved_color_mode).to_have_text("light")
+ expect(color_mode_cond).to_have_text("LightMode")
+ expect(root_body).to_have_css("background-color", light_background)
diff --git a/tests/integration/tests_playwright/test_datetime_operations.py b/tests/integration/tests_playwright/test_datetime_operations.py
new file mode 100644
index 000000000..fafd15c42
--- /dev/null
+++ b/tests/integration/tests_playwright/test_datetime_operations.py
@@ -0,0 +1,87 @@
+from typing import Generator
+
+import pytest
+from playwright.sync_api import Page, expect
+
+from reflex.testing import AppHarness
+
+
+def DatetimeOperationsApp():
+ from datetime import datetime
+
+ import reflex as rx
+
+ class DtOperationsState(rx.State):
+ date1: datetime = datetime(2021, 1, 1)
+ date2: datetime = datetime(2031, 1, 1)
+ date3: datetime = datetime(2021, 1, 1)
+
+ app = rx.App(state=DtOperationsState)
+
+ @app.add_page
+ def index():
+ return rx.vstack(
+ rx.text(DtOperationsState.date1, id="date1"),
+ rx.text(DtOperationsState.date2, id="date2"),
+ rx.text(DtOperationsState.date3, id="date3"),
+ rx.text("Operations between date1 and date2"),
+ rx.text(DtOperationsState.date1 == DtOperationsState.date2, id="1_eq_2"),
+ rx.text(DtOperationsState.date1 != DtOperationsState.date2, id="1_neq_2"),
+ rx.text(DtOperationsState.date1 < DtOperationsState.date2, id="1_lt_2"),
+ rx.text(DtOperationsState.date1 <= DtOperationsState.date2, id="1_le_2"),
+ rx.text(DtOperationsState.date1 > DtOperationsState.date2, id="1_gt_2"),
+ rx.text(DtOperationsState.date1 >= DtOperationsState.date2, id="1_ge_2"),
+ rx.text("Operations between date1 and date3"),
+ rx.text(DtOperationsState.date1 == DtOperationsState.date3, id="1_eq_3"),
+ rx.text(DtOperationsState.date1 != DtOperationsState.date3, id="1_neq_3"),
+ rx.text(DtOperationsState.date1 < DtOperationsState.date3, id="1_lt_3"),
+ rx.text(DtOperationsState.date1 <= DtOperationsState.date3, id="1_le_3"),
+ rx.text(DtOperationsState.date1 > DtOperationsState.date3, id="1_gt_3"),
+ rx.text(DtOperationsState.date1 >= DtOperationsState.date3, id="1_ge_3"),
+ )
+
+
+@pytest.fixture()
+def datetime_operations_app(tmp_path_factory) -> Generator[AppHarness, None, None]:
+ """Start Table app at tmp_path via AppHarness.
+
+ Args:
+ tmp_path_factory: pytest tmp_path_factory fixture
+
+ Yields:
+ running AppHarness instance
+
+ """
+ with AppHarness.create(
+ root=tmp_path_factory.mktemp("datetime_operations_app"),
+ app_source=DatetimeOperationsApp, # type: ignore
+ ) as harness:
+ assert harness.app_instance is not None, "app is not running"
+ yield harness
+
+
+def test_datetime_operations(datetime_operations_app: AppHarness, page: Page):
+ assert datetime_operations_app.frontend_url is not None
+
+ page.goto(datetime_operations_app.frontend_url)
+ expect(page).to_have_url(datetime_operations_app.frontend_url + "/")
+ # Check the actual values
+ expect(page.locator("id=date1")).to_have_text("2021-01-01 00:00:00")
+ expect(page.locator("id=date2")).to_have_text("2031-01-01 00:00:00")
+ expect(page.locator("id=date3")).to_have_text("2021-01-01 00:00:00")
+
+ # Check the operations between date1 and date2
+ expect(page.locator("id=1_eq_2")).to_have_text("false")
+ expect(page.locator("id=1_neq_2")).to_have_text("true")
+ expect(page.locator("id=1_lt_2")).to_have_text("true")
+ expect(page.locator("id=1_le_2")).to_have_text("true")
+ expect(page.locator("id=1_gt_2")).to_have_text("false")
+ expect(page.locator("id=1_ge_2")).to_have_text("false")
+
+ # Check the operations between date1 and date3
+ expect(page.locator("id=1_eq_3")).to_have_text("true")
+ expect(page.locator("id=1_neq_3")).to_have_text("false")
+ expect(page.locator("id=1_lt_3")).to_have_text("false")
+ expect(page.locator("id=1_le_3")).to_have_text("true")
+ expect(page.locator("id=1_gt_3")).to_have_text("false")
+ expect(page.locator("id=1_ge_3")).to_have_text("true")
diff --git a/tests/integration/tests_playwright/test_stateless_app.py b/tests/integration/tests_playwright/test_stateless_app.py
new file mode 100644
index 000000000..0c0b2959b
--- /dev/null
+++ b/tests/integration/tests_playwright/test_stateless_app.py
@@ -0,0 +1,59 @@
+"""Integration tests for a stateless app."""
+
+from typing import Generator
+
+import httpx
+import pytest
+from playwright.sync_api import Page, expect
+
+import reflex as rx
+from reflex.testing import AppHarness
+
+
+def StatelessApp():
+ """A stateless app that renders a heading."""
+ import reflex as rx
+
+ def index():
+ return rx.heading("This is a stateless app")
+
+ app = rx.App()
+ app.add_page(index)
+
+
+@pytest.fixture(scope="module")
+def stateless_app(tmp_path_factory) -> Generator[AppHarness, None, None]:
+ """Create a stateless app AppHarness.
+
+ Args:
+ tmp_path_factory: pytest fixture for creating temporary directories.
+
+ Yields:
+ AppHarness: A harness for testing the stateless app.
+ """
+ with AppHarness.create(
+ root=tmp_path_factory.mktemp("stateless_app"),
+ app_source=StatelessApp,
+ ) as harness:
+ yield harness
+
+
+def test_statelessness(stateless_app: AppHarness, page: Page):
+ """Test that the stateless app renders a heading but backend/_event is not mounted.
+
+ Args:
+ stateless_app: A harness for testing the stateless app.
+ page: A Playwright page.
+ """
+ assert stateless_app.frontend_url is not None
+ assert stateless_app.backend is not None
+ assert stateless_app.backend.started
+
+ res = httpx.get(rx.config.get_config().api_url + "/_event")
+ assert res.status_code == 404
+
+ res2 = httpx.get(rx.config.get_config().api_url + "/ping")
+ assert res2.status_code == 200
+
+ page.goto(stateless_app.frontend_url)
+ expect(page.get_by_role("heading")).to_have_text("This is a stateless app")
diff --git a/tests/integration/tests_playwright/test_table.py b/tests/integration/tests_playwright/test_table.py
new file mode 100644
index 000000000..db716aa5b
--- /dev/null
+++ b/tests/integration/tests_playwright/test_table.py
@@ -0,0 +1,101 @@
+"""Integration tests for table and related components."""
+
+from typing import Generator
+
+import pytest
+from playwright.sync_api import Page
+
+from reflex.testing import AppHarness
+
+expected_col_headers = ["Name", "Age", "Location"]
+expected_row_headers = ["John", "Jane", "Joe"]
+expected_cells_data = [
+ ["30", "New York"],
+ ["31", "San Fransisco"],
+ ["32", "Los Angeles"],
+]
+
+
+def Table():
+ """App using table component."""
+ import reflex as rx
+
+ app = rx.App(state=rx.State)
+
+ @app.add_page
+ def index():
+ return rx.center(
+ rx.table.root(
+ rx.table.header(
+ rx.table.row(
+ rx.table.column_header_cell("Name"),
+ rx.table.column_header_cell("Age"),
+ rx.table.column_header_cell("Location"),
+ ),
+ ),
+ rx.table.body(
+ rx.table.row(
+ rx.table.row_header_cell("John"),
+ rx.table.cell(30),
+ rx.table.cell("New York"),
+ ),
+ rx.table.row(
+ rx.table.row_header_cell("Jane"),
+ rx.table.cell(31),
+ rx.table.cell("San Fransisco"),
+ ),
+ rx.table.row(
+ rx.table.row_header_cell("Joe"),
+ rx.table.cell(32),
+ rx.table.cell("Los Angeles"),
+ ),
+ ),
+ width="100%",
+ ),
+ )
+
+
+@pytest.fixture()
+def table_app(tmp_path_factory) -> Generator[AppHarness, None, None]:
+ """Start Table app at tmp_path via AppHarness.
+
+ Args:
+ tmp_path_factory: pytest tmp_path_factory fixture
+
+ Yields:
+ running AppHarness instance
+
+ """
+ with AppHarness.create(
+ root=tmp_path_factory.mktemp("table"),
+ app_source=Table,
+ ) as harness:
+ assert harness.app_instance is not None, "app is not running"
+ yield harness
+
+
+def test_table(page: Page, table_app: AppHarness):
+ """Test that a table component is rendered properly.
+
+ Args:
+ table_app: Harness for Table app
+ page: Playwright page instance
+ """
+ assert table_app.frontend_url is not None, "frontend url is not available"
+
+ page.goto(table_app.frontend_url)
+ table = page.get_by_role("table")
+
+ # Check column headers
+ headers = table.get_by_role("columnheader").all_inner_texts()
+ assert headers == expected_col_headers
+
+ # Check rows headers
+ rows = table.get_by_role("rowheader").all_inner_texts()
+ assert rows == expected_row_headers
+
+ # Check cells
+ rows = table.get_by_role("cell").all_inner_texts()
+ for i, expected_row in enumerate(expected_cells_data):
+ idx = i * 2
+ assert [rows[idx], rows[idx + 1]] == expected_row
diff --git a/integration/utils.py b/tests/integration/utils.py
similarity index 100%
rename from integration/utils.py
rename to tests/integration/utils.py
diff --git a/tests/test_node_version.py b/tests/test_node_version.py
new file mode 100644
index 000000000..defba3d20
--- /dev/null
+++ b/tests/test_node_version.py
@@ -0,0 +1,73 @@
+"""Test for latest node version being able to run reflex."""
+
+from __future__ import annotations
+
+from typing import Any, Generator
+
+import httpx
+import pytest
+from playwright.sync_api import Page, expect
+
+from reflex.testing import AppHarness
+
+
+def TestNodeVersionApp():
+ """A test app for node latest version."""
+ import reflex as rx
+ from reflex.utils.prerequisites import get_node_version
+
+ class TestNodeVersionConfig(rx.Config):
+ pass
+
+ class TestNodeVersionState(rx.State):
+ @rx.var
+ def node_version(self) -> str:
+ return str(get_node_version())
+
+ app = rx.App()
+
+ @app.add_page
+ def index():
+ return rx.heading("Node Version check v", TestNodeVersionState.node_version)
+
+
+@pytest.fixture()
+def node_version_app(tmp_path) -> Generator[AppHarness, Any, None]:
+ """Fixture to start TestNodeVersionApp app at tmp_path via AppHarness.
+
+ Args:
+ tmp_path: pytest tmp_path fixture
+
+ Yields:
+ running AppHarness instance
+ """
+ with AppHarness.create(
+ root=tmp_path,
+ app_source=TestNodeVersionApp,
+ ) as harness:
+ yield harness
+
+
+def test_node_version(node_version_app: AppHarness, page: Page):
+ """Test for latest node version being able to run reflex.
+
+ Args:
+ node_version_app: running AppHarness instance
+ page: playwright page instance
+ """
+
+ def get_latest_node_version():
+ response = httpx.get("https://nodejs.org/dist/index.json")
+ versions = response.json()
+
+ # Assuming the first entry in the API response is the most recent version
+ if versions:
+ latest_version = versions[0]["version"]
+ return latest_version
+ return None
+
+ assert node_version_app.frontend_url is not None
+ page.goto(node_version_app.frontend_url)
+ expect(page.get_by_role("heading")).to_have_text(
+ f"Node Version check {get_latest_node_version()}"
+ )
diff --git a/tests/units/__init__.py b/tests/units/__init__.py
new file mode 100644
index 000000000..d0196603c
--- /dev/null
+++ b/tests/units/__init__.py
@@ -0,0 +1,5 @@
+"""Root directory for tests."""
+
+import os
+
+from reflex import constants
diff --git a/tests/experimental/custom_script.js b/tests/units/assets/custom_script.js
similarity index 100%
rename from tests/experimental/custom_script.js
rename to tests/units/assets/custom_script.js
diff --git a/tests/units/assets/test_assets.py b/tests/units/assets/test_assets.py
new file mode 100644
index 000000000..b957f1902
--- /dev/null
+++ b/tests/units/assets/test_assets.py
@@ -0,0 +1,94 @@
+import shutil
+from pathlib import Path
+from typing import Generator
+
+import pytest
+
+import reflex as rx
+import reflex.constants as constants
+
+
+def test_shared_asset() -> None:
+ """Test shared assets."""
+ # The asset function copies a file to the app's external assets directory.
+ asset = rx.asset(path="custom_script.js", shared=True, subfolder="subfolder")
+ assert asset == "/external/test_assets/subfolder/custom_script.js"
+ result_file = Path(
+ Path.cwd(), "assets/external/test_assets/subfolder/custom_script.js"
+ )
+ assert result_file.exists()
+
+ # Running a second time should not raise an error.
+ asset = rx.asset(path="custom_script.js", shared=True, subfolder="subfolder")
+
+ # Test the asset function without a subfolder.
+ asset = rx.asset(path="custom_script.js", shared=True)
+ assert asset == "/external/test_assets/custom_script.js"
+ result_file = Path(Path.cwd(), "assets/external/test_assets/custom_script.js")
+ assert result_file.exists()
+
+ # clean up
+ shutil.rmtree(Path.cwd() / "assets/external")
+
+ with pytest.raises(FileNotFoundError):
+ asset = rx.asset("non_existent_file.js")
+
+ # Nothing is done to assets when file does not exist.
+ assert not Path(Path.cwd() / "assets/external").exists()
+
+
+def test_deprecated_x_asset(capsys) -> None:
+ """Test that the deprecated asset function raises a warning.
+
+ Args:
+ capsys: Pytest fixture that captures stdout and stderr.
+ """
+ assert rx.asset("custom_script.js", shared=True) == rx._x.asset("custom_script.js")
+ assert (
+ "DeprecationWarning: rx._x.asset has been deprecated in version 0.6.6"
+ in capsys.readouterr().out
+ )
+
+
+@pytest.mark.parametrize(
+ "path,shared",
+ [
+ pytest.param("non_existing_file", True),
+ pytest.param("non_existing_file", False),
+ ],
+)
+def test_invalid_assets(path: str, shared: bool) -> None:
+ """Test that asset raises an error when the file does not exist.
+
+ Args:
+ path: The path to the asset.
+ shared: Whether the asset should be shared.
+ """
+ with pytest.raises(FileNotFoundError):
+ _ = rx.asset(path, shared=shared)
+
+
+@pytest.fixture
+def custom_script_in_asset_dir() -> Generator[Path, None, None]:
+ """Create a custom_script.js file in the app's assets directory.
+
+ Yields:
+ The path to the custom_script.js file.
+ """
+ asset_dir = Path.cwd() / constants.Dirs.APP_ASSETS
+ asset_dir.mkdir(exist_ok=True)
+ path = asset_dir / "custom_script.js"
+ path.touch()
+ yield path
+ path.unlink()
+
+
+def test_local_asset(custom_script_in_asset_dir: Path) -> None:
+ """Test that no error is raised if shared is set and both files exist.
+
+ Args:
+ custom_script_in_asset_dir: Fixture that creates a custom_script.js file in the app's assets directory.
+
+ """
+ asset = rx.asset("custom_script.js", shared=False)
+ assert asset == "/custom_script.js"
diff --git a/tests/compiler/__init__.py b/tests/units/compiler/__init__.py
similarity index 100%
rename from tests/compiler/__init__.py
rename to tests/units/compiler/__init__.py
diff --git a/tests/compiler/test_compiler.py b/tests/units/compiler/test_compiler.py
similarity index 92%
rename from tests/compiler/test_compiler.py
rename to tests/units/compiler/test_compiler.py
index 63014cf33..22f5c8483 100644
--- a/tests/compiler/test_compiler.py
+++ b/tests/units/compiler/test_compiler.py
@@ -1,4 +1,4 @@
-import os
+from pathlib import Path
from typing import List
import pytest
@@ -130,12 +130,12 @@ def test_compile_stylesheets(tmp_path, mocker):
]
assert compiler.compile_root_stylesheet(stylesheets) == (
- os.path.join(".web", "styles", "styles.css"),
- f"@import url('./tailwind.css'); \n"
- f"@import url('https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple'); \n"
- f"@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css'); \n"
- f"@import url('../public/styles.css'); \n"
- f"@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css'); \n",
+ str(Path(".web") / "styles" / "styles.css"),
+ "@import url('./tailwind.css'); \n"
+ "@import url('https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple'); \n"
+ "@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css'); \n"
+ "@import url('../public/styles.css'); \n"
+ "@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css'); \n",
)
@@ -164,7 +164,7 @@ def test_compile_stylesheets_exclude_tailwind(tmp_path, mocker):
]
assert compiler.compile_root_stylesheet(stylesheets) == (
- os.path.join(".web", "styles", "styles.css"),
+ str(Path(".web") / "styles" / "styles.css"),
"@import url('../public/styles.css'); \n",
)
diff --git a/tests/compiler/test_compiler_utils.py b/tests/units/compiler/test_compiler_utils.py
similarity index 100%
rename from tests/compiler/test_compiler_utils.py
rename to tests/units/compiler/test_compiler_utils.py
diff --git a/tests/components/__init__.py b/tests/units/components/__init__.py
similarity index 100%
rename from tests/components/__init__.py
rename to tests/units/components/__init__.py
diff --git a/tests/components/base/test_bare.py b/tests/units/components/base/test_bare.py
similarity index 66%
rename from tests/components/base/test_bare.py
rename to tests/units/components/base/test_bare.py
index 264d136cb..178820cff 100644
--- a/tests/components/base/test_bare.py
+++ b/tests/units/components/base/test_bare.py
@@ -1,16 +1,18 @@
import pytest
from reflex.components.base.bare import Bare
+from reflex.vars.base import Var
+
+STATE_VAR = Var(_js_expr="default_state.name")
@pytest.mark.parametrize(
"contents,expected",
[
- ("hello", "hello"),
- ("{}", "{}"),
- (None, ""),
- ("${default_state.name}", "${default_state.name}"),
- ("{state.name}", "{state.name}"),
+ ("hello", '{"hello"}'),
+ ("{}", '{"{}"}'),
+ (None, '{""}'),
+ (STATE_VAR, "{default_state.name}"),
],
)
def test_fstrings(contents, expected):
diff --git a/tests/units/components/base/test_link.py b/tests/units/components/base/test_link.py
new file mode 100644
index 000000000..7713330c4
--- /dev/null
+++ b/tests/units/components/base/test_link.py
@@ -0,0 +1,15 @@
+from reflex.components.base.link import RawLink, ScriptTag
+
+
+def test_raw_link():
+ raw_link = RawLink.create("https://example.com").render()
+ assert raw_link["name"] == "link"
+ assert raw_link["children"][0]["contents"] == '{"https://example.com"}'
+
+
+def test_script_tag():
+ script_tag = ScriptTag.create("console.log('Hello, world!');").render()
+ assert script_tag["name"] == "script"
+ assert (
+ script_tag["children"][0]["contents"] == "{\"console.log('Hello, world!');\"}"
+ )
diff --git a/tests/components/base/test_script.py b/tests/units/components/base/test_script.py
similarity index 73%
rename from tests/components/base/test_script.py
rename to tests/units/components/base/test_script.py
index 372178d5f..e9c40188b 100644
--- a/tests/components/base/test_script.py
+++ b/tests/units/components/base/test_script.py
@@ -2,6 +2,7 @@
import pytest
+import reflex as rx
from reflex.components.base.script import Script
from reflex.state import BaseState
@@ -13,7 +14,7 @@ def test_script_inline():
assert render_dict["name"] == "Script"
assert not render_dict["contents"]
assert len(render_dict["children"]) == 1
- assert render_dict["children"][0]["contents"] == "{`let x = 42`}"
+ assert render_dict["children"][0]["contents"] == '{"let x = 42"}'
def test_script_src():
@@ -23,7 +24,7 @@ def test_script_src():
assert render_dict["name"] == "Script"
assert not render_dict["contents"]
assert not render_dict["children"]
- assert "src={`foo.js`}" in render_dict["props"]
+ assert 'src={"foo.js"}' in render_dict["props"]
def test_script_neither():
@@ -35,14 +36,17 @@ def test_script_neither():
class EvState(BaseState):
"""State for testing event handlers."""
+ @rx.event
def on_ready(self):
"""Empty event handler."""
pass
+ @rx.event
def on_load(self):
"""Empty event handler."""
pass
+ @rx.event
def on_error(self):
"""Empty event handler."""
pass
@@ -58,14 +62,14 @@ def test_script_event_handler():
)
render_dict = component.render()
assert (
- f'onReady={{(...args) => addEvents([Event("{EvState.get_full_name()}.on_ready", {{}})], args, {{}})}}'
+ f'onReady={{((...args) => (addEvents([(Event("{EvState.get_full_name()}.on_ready", ({{ }}), ({{ }})))], args, ({{ }}))))}}'
in render_dict["props"]
)
assert (
- f'onLoad={{(...args) => addEvents([Event("{EvState.get_full_name()}.on_load", {{}})], args, {{}})}}'
+ f'onLoad={{((...args) => (addEvents([(Event("{EvState.get_full_name()}.on_load", ({{ }}), ({{ }})))], args, ({{ }}))))}}'
in render_dict["props"]
)
assert (
- f'onError={{(...args) => addEvents([Event("{EvState.get_full_name()}.on_error", {{}})], args, {{}})}}'
+ f'onError={{((...args) => (addEvents([(Event("{EvState.get_full_name()}.on_error", ({{ }}), ({{ }})))], args, ({{ }}))))}}'
in render_dict["props"]
)
diff --git a/reflex/.templates/apps/demo/code/webui/__init__.py b/tests/units/components/core/__init__.py
similarity index 100%
rename from reflex/.templates/apps/demo/code/webui/__init__.py
rename to tests/units/components/core/__init__.py
diff --git a/tests/components/core/test_banner.py b/tests/units/components/core/test_banner.py
similarity index 58%
rename from tests/components/core/test_banner.py
rename to tests/units/components/core/test_banner.py
index 184a65cc9..e1498d12c 100644
--- a/tests/components/core/test_banner.py
+++ b/tests/units/components/core/test_banner.py
@@ -4,24 +4,30 @@ from reflex.components.core.banner import (
ConnectionPulser,
WebsocketTargetURL,
)
+from reflex.components.radix.themes.base import RadixThemesComponent
from reflex.components.radix.themes.typography.text import Text
def test_websocket_target_url():
url = WebsocketTargetURL.create()
- _imports = url._get_all_imports(collapse=True)
- assert tuple(_imports) == ("/utils/state", "/env.json")
+ var_data = url._get_all_var_data()
+ assert var_data is not None
+ assert sorted(key for key, _ in var_data.imports) == sorted(
+ ("$/utils/state", "$/env.json")
+ )
def test_connection_banner():
banner = ConnectionBanner.create()
_imports = banner._get_all_imports(collapse=True)
- assert tuple(_imports) == (
- "react",
- "/utils/context",
- "/utils/state",
- "@radix-ui/themes@^3.0.0",
- "/env.json",
+ assert sorted(_imports) == sorted(
+ (
+ "react",
+ "$/utils/context",
+ "$/utils/state",
+ RadixThemesComponent().library or "",
+ "$/env.json",
+ )
)
msg = "Connection error"
@@ -32,12 +38,14 @@ def test_connection_banner():
def test_connection_modal():
modal = ConnectionModal.create()
_imports = modal._get_all_imports(collapse=True)
- assert tuple(_imports) == (
- "react",
- "/utils/context",
- "/utils/state",
- "@radix-ui/themes@^3.0.0",
- "/env.json",
+ assert sorted(_imports) == sorted(
+ (
+ "react",
+ "$/utils/context",
+ "$/utils/state",
+ RadixThemesComponent().library or "",
+ "$/env.json",
+ )
)
msg = "Connection error"
diff --git a/tests/units/components/core/test_colors.py b/tests/units/components/core/test_colors.py
new file mode 100644
index 000000000..c1295fb41
--- /dev/null
+++ b/tests/units/components/core/test_colors.py
@@ -0,0 +1,136 @@
+from typing import Type, Union
+
+import pytest
+
+import reflex as rx
+from reflex.components.datadisplay.code import CodeBlock
+from reflex.constants.colors import Color
+from reflex.vars.base import LiteralVar
+
+
+class ColorState(rx.State):
+ """Test color state."""
+
+ color: str = "mint"
+ color_part: str = "tom"
+ shade: int = 4
+ alpha: bool = False
+
+
+color_state_name = ColorState.get_full_name().replace(".", "__")
+
+
+def create_color_var(color):
+ return LiteralVar.create(color)
+
+
+@pytest.mark.parametrize(
+ "color, expected, expected_type",
+ [
+ (create_color_var(rx.color("mint")), '"var(--mint-7)"', Color),
+ (create_color_var(rx.color("mint", 3)), '"var(--mint-3)"', Color),
+ (create_color_var(rx.color("mint", 3, True)), '"var(--mint-a3)"', Color),
+ (
+ create_color_var(rx.color(ColorState.color, ColorState.shade)), # type: ignore
+ f'("var(--"+{color_state_name!s}.color+"-"+(((__to_string) => __to_string.toString())({color_state_name!s}.shade))+")")',
+ Color,
+ ),
+ (
+ create_color_var(
+ rx.color(ColorState.color, ColorState.shade, ColorState.alpha) # type: ignore
+ ),
+ f'("var(--"+{color_state_name!s}.color+"-"+({color_state_name!s}.alpha ? "a" : "")+(((__to_string) => __to_string.toString())({color_state_name!s}.shade))+")")',
+ Color,
+ ),
+ (
+ create_color_var(rx.color(f"{ColorState.color}", f"{ColorState.shade}")), # type: ignore
+ f'("var(--"+{color_state_name!s}.color+"-"+{color_state_name!s}.shade+")")',
+ Color,
+ ),
+ (
+ create_color_var(
+ rx.color(f"{ColorState.color_part}ato", f"{ColorState.shade}") # type: ignore
+ ),
+ f'("var(--"+({color_state_name!s}.color_part+"ato")+"-"+{color_state_name!s}.shade+")")',
+ Color,
+ ),
+ (
+ create_color_var(f'{rx.color(ColorState.color, f"{ColorState.shade}")}'), # type: ignore
+ f'("var(--"+{color_state_name!s}.color+"-"+{color_state_name!s}.shade+")")',
+ str,
+ ),
+ (
+ create_color_var(
+ f'{rx.color(f"{ColorState.color}", f"{ColorState.shade}")}' # type: ignore
+ ),
+ f'("var(--"+{color_state_name!s}.color+"-"+{color_state_name!s}.shade+")")',
+ str,
+ ),
+ ],
+)
+def test_color(color, expected, expected_type: Union[Type[str], Type[Color]]):
+ assert color._var_type is expected_type
+ assert str(color) == expected
+
+
+@pytest.mark.parametrize(
+ "cond_var, expected",
+ [
+ (
+ rx.cond(True, rx.color("mint"), rx.color("tomato", 5)),
+ '(true ? "var(--mint-7)" : "var(--tomato-5)")',
+ ),
+ (
+ rx.cond(True, rx.color(ColorState.color), rx.color(ColorState.color, 5)), # type: ignore
+ f'(true ? ("var(--"+{color_state_name!s}.color+"-7)") : ("var(--"+{color_state_name!s}.color+"-5)"))',
+ ),
+ (
+ rx.match(
+ "condition",
+ ("first", rx.color("mint")),
+ ("second", rx.color("tomato", 5)),
+ rx.color(ColorState.color, 2), # type: ignore
+ ),
+ '(() => { switch (JSON.stringify("condition")) {case JSON.stringify("first"): return ("var(--mint-7)");'
+ ' break;case JSON.stringify("second"): return ("var(--tomato-5)"); break;default: '
+ f'return (("var(--"+{color_state_name!s}.color+"-2)")); break;}};}})()',
+ ),
+ (
+ rx.match(
+ "condition",
+ ("first", rx.color(ColorState.color)), # type: ignore
+ ("second", rx.color(ColorState.color, 5)), # type: ignore
+ rx.color(ColorState.color, 2), # type: ignore
+ ),
+ '(() => { switch (JSON.stringify("condition")) {case JSON.stringify("first"): '
+ f'return (("var(--"+{color_state_name!s}.color+"-7)")); break;case JSON.stringify("second"): '
+ f'return (("var(--"+{color_state_name!s}.color+"-5)")); break;default: '
+ f'return (("var(--"+{color_state_name!s}.color+"-2)")); break;}};}})()',
+ ),
+ ],
+)
+def test_color_with_conditionals(cond_var, expected):
+ assert str(cond_var) == expected
+
+
+@pytest.mark.parametrize(
+ "color, expected",
+ [
+ (create_color_var(rx.color("red")), '"var(--red-7)"'),
+ (create_color_var(rx.color("green", shade=1)), '"var(--green-1)"'),
+ (create_color_var(rx.color("blue", alpha=True)), '"var(--blue-a7)"'),
+ ("red", '"red"'),
+ ("green", '"green"'),
+ ("blue", '"blue"'),
+ ],
+)
+def test_radix_color(color, expected):
+ """Test that custom_style can accept both string
+ literals and rx.color inputs.
+
+ Args:
+ color (Color): A Color made with rx.color
+ expected (str): The expected custom_style string, radix or literal
+ """
+ code_block = CodeBlock.create("Hello World", background_color=color)
+ assert str(code_block.custom_style["backgroundColor"]) == expected # type: ignore
diff --git a/tests/components/core/test_cond.py b/tests/units/components/core/test_cond.py
similarity index 79%
rename from tests/components/core/test_cond.py
rename to tests/units/components/core/test_cond.py
index e18be2217..e88f35c9a 100644
--- a/tests/components/core/test_cond.py
+++ b/tests/units/components/core/test_cond.py
@@ -6,9 +6,9 @@ import pytest
from reflex.components.base.fragment import Fragment
from reflex.components.core.cond import Cond, cond
from reflex.components.radix.themes.typography.text import Text
-from reflex.state import BaseState, State
+from reflex.state import BaseState
from reflex.utils.format import format_state_name
-from reflex.vars import BaseVar, Var, computed_var
+from reflex.vars.base import LiteralVar, Var, computed_var
@pytest.fixture
@@ -21,8 +21,8 @@ def cond_state(request):
def test_f_string_cond_interpolation():
# make sure backticks inside interpolation don't get escaped
- var = Var.create(f"x {cond(True, 'a', 'b')}")
- assert str(var) == "x ${isTrue(true) ? `a` : `b`}"
+ var = LiteralVar.create(f"x {cond(True, 'a', 'b')}")
+ assert str(var) == '("x "+(true ? "a" : "b"))'
@pytest.mark.parametrize(
@@ -45,7 +45,7 @@ def test_validate_cond(cond_state: BaseState):
Text.create("cond is True"),
Text.create("cond is False"),
)
- cond_dict = cond_component.render() if type(cond_component) == Fragment else {}
+ cond_dict = cond_component.render() if type(cond_component) is Fragment else {}
assert cond_dict["name"] == "Fragment"
[condition] = cond_dict["children"]
@@ -57,7 +57,7 @@ def test_validate_cond(cond_state: BaseState):
[true_value_text] = true_value["children"]
assert true_value_text["name"] == "RadixThemesText"
- assert true_value_text["children"][0]["contents"] == "{`cond is True`}"
+ assert true_value_text["children"][0]["contents"] == '{"cond is True"}'
# false value
false_value = condition["false_value"]
@@ -65,7 +65,7 @@ def test_validate_cond(cond_state: BaseState):
[false_value_text] = false_value["children"]
assert false_value_text["name"] == "RadixThemesText"
- assert false_value_text["children"][0]["contents"] == "{`cond is False`}"
+ assert false_value_text["children"][0]["contents"] == '{"cond is False"}'
@pytest.mark.parametrize(
@@ -75,7 +75,7 @@ def test_validate_cond(cond_state: BaseState):
(32, 0),
("hello", ""),
(2.3, 0.0),
- (Var.create("a"), Var.create("b")),
+ (LiteralVar.create("a"), LiteralVar.create("b")),
],
)
def test_prop_cond(c1: Any, c2: Any):
@@ -93,16 +93,16 @@ def test_prop_cond(c1: Any, c2: Any):
assert isinstance(prop_cond, Var)
if not isinstance(c1, Var):
- c1 = json.dumps(c1).replace('"', "`")
+ c1 = json.dumps(c1)
if not isinstance(c2, Var):
- c2 = json.dumps(c2).replace('"', "`")
- assert str(prop_cond) == f"{{isTrue(true) ? {c1} : {c2}}}"
+ c2 = json.dumps(c2)
+ assert str(prop_cond) == f"(true ? {c1!s} : {c2!s})"
def test_cond_no_mix():
"""Test if cond can't mix components and props."""
with pytest.raises(ValueError):
- cond(True, Var.create("hello"), Text.create("world"))
+ cond(True, LiteralVar.create("hello"), Text.create("world"))
def test_cond_no_else():
@@ -124,7 +124,7 @@ def test_cond_no_else():
def test_cond_computed_var():
"""Test if cond works with computed vars."""
- class CondStateComputed(State):
+ class CondStateComputed(BaseState):
@computed_var
def computed_int(self) -> int:
return 0
@@ -135,13 +135,12 @@ def test_cond_computed_var():
comp = cond(True, CondStateComputed.computed_int, CondStateComputed.computed_str)
- # TODO: shouln't this be a ComputedVar?
- assert isinstance(comp, BaseVar)
+ # TODO: shouldn't this be a ComputedVar?
+ assert isinstance(comp, Var)
state_name = format_state_name(CondStateComputed.get_full_name())
assert (
- str(comp)
- == f"{{isTrue(true) ? {state_name}.computed_int : {state_name}.computed_str}}"
+ str(comp) == f"(true ? {state_name}.computed_int : {state_name}.computed_str)"
)
assert comp._var_type == Union[int, str]
diff --git a/tests/components/core/test_debounce.py b/tests/units/components/core/test_debounce.py
similarity index 82%
rename from tests/components/core/test_debounce.py
rename to tests/units/components/core/test_debounce.py
index 8ad15ea58..29d3bcddc 100644
--- a/tests/components/core/test_debounce.py
+++ b/tests/units/components/core/test_debounce.py
@@ -5,7 +5,7 @@ import pytest
import reflex as rx
from reflex.components.core.debounce import DEFAULT_DEBOUNCE_TIMEOUT
from reflex.state import BaseState
-from reflex.vars import BaseVar
+from reflex.vars.base import LiteralVar, Var
def test_create_no_child():
@@ -37,10 +37,10 @@ class S(BaseState):
value: str = ""
+ @rx.event
def on_change(self, v: str):
"""Dummy on_change handler.
-
Args:
v: The changed value.
"""
@@ -57,14 +57,10 @@ def test_render_child_props():
on_change=S.on_change,
)
)._render()
- assert "css" in tag.props and isinstance(tag.props["css"], rx.Var)
+ assert "css" in tag.props and isinstance(tag.props["css"], rx.vars.Var)
for prop in ["foo", "bar", "baz", "quuc"]:
assert prop in str(tag.props["css"])
- assert tag.props["value"].equals(
- BaseVar(
- _var_name="real", _var_type=str, _var_is_local=True, _var_is_string=False
- )
- )
+ assert tag.props["value"].equals(LiteralVar.create("real"))
assert len(tag.props["onChange"].events) == 1
assert tag.props["onChange"].events[0].handler == S.on_change
assert tag.contents == ""
@@ -77,7 +73,7 @@ def test_render_with_class_name():
class_name="foo baz",
)
)._render()
- assert isinstance(tag.props["className"], rx.Var)
+ assert isinstance(tag.props["className"], rx.vars.Var)
assert "foo baz" in str(tag.props["className"])
@@ -88,7 +84,7 @@ def test_render_with_ref():
id="foo_bar",
)
)._render()
- assert isinstance(tag.props["inputRef"], rx.Var)
+ assert isinstance(tag.props["inputRef"], rx.vars.Var)
assert "foo_bar" in str(tag.props["inputRef"])
@@ -99,12 +95,12 @@ def test_render_with_key():
key="foo_bar",
)
)._render()
- assert isinstance(tag.props["key"], rx.Var)
+ assert isinstance(tag.props["key"], rx.vars.Var)
assert "foo_bar" in str(tag.props["key"])
def test_render_with_special_props():
- special_prop = rx.Var.create_safe("{foo_bar}", _var_is_string=False)
+ special_prop = Var(_js_expr="{foo_bar}")
tag = rx.debounce_input(
rx.input(
on_change=S.on_change,
@@ -112,7 +108,7 @@ def test_render_with_special_props():
)
)._render()
assert len(tag.special_props) == 1
- assert list(tag.special_props)[0].equals(special_prop)
+ assert next(iter(tag.special_props)).equals(special_prop)
def test_event_triggers():
@@ -153,17 +149,13 @@ def test_render_child_props_recursive():
),
force_notify_by_enter=False,
)._render()
- assert "css" in tag.props and isinstance(tag.props["css"], rx.Var)
+ assert "css" in tag.props and isinstance(tag.props["css"], rx.vars.Var)
for prop in ["foo", "bar", "baz", "quuc"]:
assert prop in str(tag.props["css"])
- assert tag.props["value"].equals(
- BaseVar(
- _var_name="outer", _var_type=str, _var_is_local=True, _var_is_string=False
- )
- )
- assert tag.props["forceNotifyOnBlur"]._var_name == "false"
- assert tag.props["forceNotifyByEnter"]._var_name == "false"
- assert tag.props["debounceTimeout"]._var_name == "42"
+ assert tag.props["value"].equals(LiteralVar.create("outer"))
+ assert tag.props["forceNotifyOnBlur"]._js_expr == "false"
+ assert tag.props["forceNotifyByEnter"]._js_expr == "false"
+ assert tag.props["debounceTimeout"]._js_expr == "42"
assert len(tag.props["onChange"].events) == 1
assert tag.props["onChange"].events[0].handler == S.on_change
assert tag.contents == ""
@@ -175,7 +167,7 @@ def test_full_control_implicit_debounce():
value=S.value,
on_change=S.on_change,
)._render()
- assert tag.props["debounceTimeout"]._var_name == str(DEFAULT_DEBOUNCE_TIMEOUT)
+ assert tag.props["debounceTimeout"]._js_expr == str(DEFAULT_DEBOUNCE_TIMEOUT)
assert len(tag.props["onChange"].events) == 1
assert tag.props["onChange"].events[0].handler == S.on_change
assert tag.contents == ""
@@ -187,7 +179,7 @@ def test_full_control_implicit_debounce_text_area():
value=S.value,
on_change=S.on_change,
)._render()
- assert tag.props["debounceTimeout"]._var_name == str(DEFAULT_DEBOUNCE_TIMEOUT)
+ assert tag.props["debounceTimeout"]._js_expr == str(DEFAULT_DEBOUNCE_TIMEOUT)
assert len(tag.props["onChange"].events) == 1
assert tag.props["onChange"].events[0].handler == S.on_change
assert tag.contents == ""
diff --git a/tests/components/core/test_foreach.py b/tests/units/components/core/test_foreach.py
similarity index 88%
rename from tests/components/core/test_foreach.py
rename to tests/units/components/core/test_foreach.py
index 6e4fa6b5e..094f6029d 100644
--- a/tests/components/core/test_foreach.py
+++ b/tests/units/components/core/test_foreach.py
@@ -1,8 +1,10 @@
from typing import Dict, List, Set, Tuple, Union
+import pydantic.v1
import pytest
from reflex import el
+from reflex.base import Base
from reflex.components.component import Component
from reflex.components.core.foreach import (
Foreach,
@@ -13,7 +15,15 @@ from reflex.components.core.foreach import (
from reflex.components.radix.themes.layout.box import box
from reflex.components.radix.themes.typography.text import text
from reflex.state import BaseState, ComponentState
-from reflex.vars import Var
+from reflex.vars.base import Var
+from reflex.vars.number import NumberVar
+from reflex.vars.sequence import ArrayVar
+
+
+class ForEachTag(Base):
+ """A tag for testing the ForEach component."""
+
+ name: str = ""
class ForEachState(BaseState):
@@ -44,8 +54,10 @@ class ForEachState(BaseState):
bad_annotation_list: list = [["red", "orange"], ["yellow", "blue"]]
color_index_tuple: Tuple[int, str] = (0, "red")
+ default_factory_list: list[ForEachTag] = pydantic.v1.Field(default_factory=list)
-class TestComponentState(ComponentState):
+
+class ComponentStateTest(ComponentState):
"""A test component state."""
foo: bool
@@ -65,7 +77,7 @@ class TestComponentState(ComponentState):
def display_color(color):
- assert color._var_type == str
+ assert color._var_type is str
return box(text(color))
@@ -104,18 +116,18 @@ def display_nested_color_with_shades_v2(color):
def display_color_tuple(color):
- assert color._var_type == str
+ assert color._var_type is str
return box(text(color))
def display_colors_set(color):
- assert color._var_type == str
+ assert color._var_type is str
return box(text(color))
-def display_nested_list_element(element: Var[str], index: Var[int]):
+def display_nested_list_element(element: ArrayVar[List[str]], index: NumberVar[int]):
assert element._var_type == List[str]
- assert index._var_type == int
+ assert index._var_type is int
return box(text(element[index]))
@@ -237,9 +249,9 @@ def test_foreach_render(state_var, render_fn, render_dict):
# Make sure the index vars are unique.
arg_index = rend["arg_index"]
assert isinstance(arg_index, Var)
- assert arg_index._var_name not in seen_index_vars
- assert arg_index._var_type == int
- seen_index_vars.add(arg_index._var_name)
+ assert arg_index._js_expr not in seen_index_vars
+ assert arg_index._var_type is int
+ seen_index_vars.add(arg_index._js_expr)
def test_foreach_bad_annotations():
@@ -278,7 +290,7 @@ def test_foreach_component_styles():
)
)
component._add_style_recursive({box: {"color": "red"}})
- assert 'css={{"color": "red"}}' in str(component)
+ assert 'css={({ ["color"] : "red" })}' in str(component)
def test_foreach_component_state():
@@ -286,5 +298,13 @@ def test_foreach_component_state():
with pytest.raises(TypeError):
Foreach.create(
ForEachState.colors_list,
- TestComponentState.create,
+ ComponentStateTest.create,
)
+
+
+def test_foreach_default_factory():
+ """Test that the default factory is called."""
+ _ = Foreach.create(
+ ForEachState.default_factory_list,
+ lambda tag: text(tag.name),
+ )
diff --git a/tests/units/components/core/test_html.py b/tests/units/components/core/test_html.py
new file mode 100644
index 000000000..79c258dfb
--- /dev/null
+++ b/tests/units/components/core/test_html.py
@@ -0,0 +1,41 @@
+import pytest
+
+from reflex.components.core.html import Html
+from reflex.state import State
+
+
+def test_html_no_children():
+ with pytest.raises(ValueError):
+ _ = Html.create()
+
+
+def test_html_many_children():
+ with pytest.raises(ValueError):
+ _ = Html.create("foo", "bar")
+
+
+def test_html_create():
+ html = Html.create("
Hello !
")
+ assert str(html.dangerouslySetInnerHTML) == '({ ["__html"] : "
Hello !
" })' # type: ignore
+ assert (
+ str(html)
+ == '
Hello !" })}/>'
+ )
+
+
+def test_html_fstring_create():
+ class TestState(State):
+ """The app state."""
+
+ myvar: str = "Blue"
+
+ html = Html.create(f"
Hello {TestState.myvar}!
")
+
+ assert (
+ str(html.dangerouslySetInnerHTML) # type: ignore
+ == f'({{ ["__html"] : ("
Hello "+{TestState.myvar!s}+"!
") }})'
+ )
+ assert (
+ str(html)
+ == f'
' # type: ignore
+ )
diff --git a/tests/components/core/test_match.py b/tests/units/components/core/test_match.py
similarity index 72%
rename from tests/components/core/test_match.py
rename to tests/units/components/core/test_match.py
index 883386ebd..f09e800e5 100644
--- a/tests/components/core/test_match.py
+++ b/tests/units/components/core/test_match.py
@@ -1,4 +1,4 @@
-from typing import Tuple
+from typing import Dict, List, Tuple
import pytest
@@ -6,7 +6,7 @@ import reflex as rx
from reflex.components.core.match import Match
from reflex.state import BaseState
from reflex.utils.exceptions import MatchTypeError
-from reflex.vars import BaseVar
+from reflex.vars.base import Var
class MatchState(BaseState):
@@ -35,53 +35,53 @@ def test_match_components():
[match_child] = match_dict["children"]
assert match_child["name"] == "match"
- assert str(match_child["cond"]) == f"{{{MatchState.get_name()}.value}}"
+ assert str(match_child["cond"]) == f"{MatchState.get_name()}.value"
match_cases = match_child["match_cases"]
assert len(match_cases) == 6
- assert match_cases[0][0]._var_name == "1"
- assert match_cases[0][0]._var_type == int
+ assert match_cases[0][0]._js_expr == "1"
+ assert match_cases[0][0]._var_type is int
first_return_value_render = match_cases[0][1].render()
assert first_return_value_render["name"] == "RadixThemesText"
- assert first_return_value_render["children"][0]["contents"] == "{`first value`}"
+ assert first_return_value_render["children"][0]["contents"] == '{"first value"}'
- assert match_cases[1][0]._var_name == "2"
- assert match_cases[1][0]._var_type == int
- assert match_cases[1][1]._var_name == "3"
- assert match_cases[1][1]._var_type == int
+ assert match_cases[1][0]._js_expr == "2"
+ assert match_cases[1][0]._var_type is int
+ assert match_cases[1][1]._js_expr == "3"
+ assert match_cases[1][1]._var_type is int
second_return_value_render = match_cases[1][2].render()
assert second_return_value_render["name"] == "RadixThemesText"
- assert second_return_value_render["children"][0]["contents"] == "{`second value`}"
+ assert second_return_value_render["children"][0]["contents"] == '{"second value"}'
- assert match_cases[2][0]._var_name == "[1, 2]"
- assert match_cases[2][0]._var_type == list
+ assert match_cases[2][0]._js_expr == "[1, 2]"
+ assert match_cases[2][0]._var_type == List[int]
third_return_value_render = match_cases[2][1].render()
assert third_return_value_render["name"] == "RadixThemesText"
- assert third_return_value_render["children"][0]["contents"] == "{`third value`}"
+ assert third_return_value_render["children"][0]["contents"] == '{"third value"}'
- assert match_cases[3][0]._var_name == "random"
- assert match_cases[3][0]._var_type == str
+ assert match_cases[3][0]._js_expr == '"random"'
+ assert match_cases[3][0]._var_type is str
fourth_return_value_render = match_cases[3][1].render()
assert fourth_return_value_render["name"] == "RadixThemesText"
- assert fourth_return_value_render["children"][0]["contents"] == "{`fourth value`}"
+ assert fourth_return_value_render["children"][0]["contents"] == '{"fourth value"}'
- assert match_cases[4][0]._var_name == '{"foo": "bar"}'
- assert match_cases[4][0]._var_type == dict
+ assert match_cases[4][0]._js_expr == '({ ["foo"] : "bar" })'
+ assert match_cases[4][0]._var_type == Dict[str, str]
fifth_return_value_render = match_cases[4][1].render()
assert fifth_return_value_render["name"] == "RadixThemesText"
- assert fifth_return_value_render["children"][0]["contents"] == "{`fifth value`}"
+ assert fifth_return_value_render["children"][0]["contents"] == '{"fifth value"}'
- assert match_cases[5][0]._var_name == f"(({MatchState.get_name()}.num) + (1))"
- assert match_cases[5][0]._var_type == int
+ assert match_cases[5][0]._js_expr == f"({MatchState.get_name()}.num + 1)"
+ assert match_cases[5][0]._var_type is int
fifth_return_value_render = match_cases[5][1].render()
assert fifth_return_value_render["name"] == "RadixThemesText"
- assert fifth_return_value_render["children"][0]["contents"] == "{`sixth value`}"
+ assert fifth_return_value_render["children"][0]["contents"] == '{"sixth value"}'
default = match_child["default"].render()
assert default["name"] == "RadixThemesText"
- assert default["children"][0]["contents"] == "{`default value`}"
+ assert default["children"][0]["contents"] == '{"default value"}'
@pytest.mark.parametrize(
@@ -99,12 +99,12 @@ def test_match_components():
(MatchState.string, f"{MatchState.value} - string"),
"default value",
),
- f"(() => {{ switch (JSON.stringify({MatchState.get_name()}.value)) {{case JSON.stringify(1): return (`first`); break;case JSON.stringify(2): case JSON.stringify(3): return "
- "(`second value`); break;case JSON.stringify([1, 2]): return (`third-value`); break;case JSON.stringify(`random`): "
- 'return (`fourth_value`); break;case JSON.stringify({"foo": "bar"}): return (`fifth value`); '
- f"break;case JSON.stringify((({MatchState.get_name()}.num) + (1))): return (`sixth value`); break;case JSON.stringify(`${{{MatchState.get_name()}.value}} - string`): "
- f"return ({MatchState.get_name()}.string); break;case JSON.stringify({MatchState.get_name()}.string): return (`${{{MatchState.get_name()}.value}} - string`); break;default: "
- "return (`default value`); break;};})()",
+ f'(() => {{ switch (JSON.stringify({MatchState.get_name()}.value)) {{case JSON.stringify(1): return ("first"); break;case JSON.stringify(2): case JSON.stringify(3): return '
+ '("second value"); break;case JSON.stringify([1, 2]): return ("third-value"); break;case JSON.stringify("random"): '
+ 'return ("fourth_value"); break;case JSON.stringify(({ ["foo"] : "bar" })): return ("fifth value"); '
+ f'break;case JSON.stringify(({MatchState.get_name()}.num + 1)): return ("sixth value"); break;case JSON.stringify(({MatchState.get_name()}.value+" - string")): '
+ f'return ({MatchState.get_name()}.string); break;case JSON.stringify({MatchState.get_name()}.string): return (({MatchState.get_name()}.value+" - string")); break;default: '
+ 'return ("default value"); break;};})()',
),
(
(
@@ -118,11 +118,11 @@ def test_match_components():
(MatchState.string, f"{MatchState.value} - string"),
MatchState.string,
),
- f"(() => {{ switch (JSON.stringify({MatchState.get_name()}.value)) {{case JSON.stringify(1): return (`first`); break;case JSON.stringify(2): case JSON.stringify(3): return "
- "(`second value`); break;case JSON.stringify([1, 2]): return (`third-value`); break;case JSON.stringify(`random`): "
- 'return (`fourth_value`); break;case JSON.stringify({"foo": "bar"}): return (`fifth value`); '
- f"break;case JSON.stringify((({MatchState.get_name()}.num) + (1))): return (`sixth value`); break;case JSON.stringify(`${{{MatchState.get_name()}.value}} - string`): "
- f"return ({MatchState.get_name()}.string); break;case JSON.stringify({MatchState.get_name()}.string): return (`${{{MatchState.get_name()}.value}} - string`); break;default: "
+ f'(() => {{ switch (JSON.stringify({MatchState.get_name()}.value)) {{case JSON.stringify(1): return ("first"); break;case JSON.stringify(2): case JSON.stringify(3): return '
+ '("second value"); break;case JSON.stringify([1, 2]): return ("third-value"); break;case JSON.stringify("random"): '
+ 'return ("fourth_value"); break;case JSON.stringify(({ ["foo"] : "bar" })): return ("fifth value"); '
+ f'break;case JSON.stringify(({MatchState.get_name()}.num + 1)): return ("sixth value"); break;case JSON.stringify(({MatchState.get_name()}.value+" - string")): '
+ f'return ({MatchState.get_name()}.string); break;case JSON.stringify({MatchState.get_name()}.string): return (({MatchState.get_name()}.value+" - string")); break;default: '
f"return ({MatchState.get_name()}.string); break;}};}})()",
),
],
@@ -135,8 +135,8 @@ def test_match_vars(cases, expected):
expected: The expected var full name.
"""
match_comp = Match.create(MatchState.value, *cases)
- assert isinstance(match_comp, BaseVar)
- assert match_comp._var_full_name == expected
+ assert isinstance(match_comp, Var)
+ assert str(match_comp) == expected
def test_match_on_component_without_default():
@@ -247,8 +247,8 @@ def test_match_case_tuple_elements(match_case):
(MatchState.num + 1, "black"),
rx.text("default value"),
),
- "Match cases should have the same return types. Case 3 with return value `red` of type "
- " is not ",
+ 'Match cases should have the same return types. Case 3 with return value `"red"` of type '
+ " is not ",
),
(
(
@@ -260,8 +260,8 @@ def test_match_case_tuple_elements(match_case):
([1, 2], rx.text("third value")),
rx.text("default value"),
),
- "Match cases should have the same return types. Case 3 with return value ` {`first value`} ` "
- "of type is not ",
+ 'Match cases should have the same return types. Case 3 with return value ` {"first value"} ` '
+ "of type is not ",
),
],
)
diff --git a/tests/components/core/test_responsive.py b/tests/units/components/core/test_responsive.py
similarity index 100%
rename from tests/components/core/test_responsive.py
rename to tests/units/components/core/test_responsive.py
diff --git a/tests/components/core/test_upload.py b/tests/units/components/core/test_upload.py
similarity index 79%
rename from tests/components/core/test_upload.py
rename to tests/units/components/core/test_upload.py
index e6b27effc..710baa161 100644
--- a/tests/components/core/test_upload.py
+++ b/tests/units/components/core/test_upload.py
@@ -1,3 +1,6 @@
+from typing import Any
+
+from reflex import event
from reflex.components.core.upload import (
StyledUpload,
Upload,
@@ -8,13 +11,14 @@ from reflex.components.core.upload import (
)
from reflex.event import EventSpec
from reflex.state import State
-from reflex.vars import Var
+from reflex.vars.base import LiteralVar, Var
-class TestUploadState(State):
+class UploadStateTest(State):
"""Test upload state."""
- def drop_handler(self, files):
+ @event
+ def drop_handler(self, files: Any):
"""Handle the drop event.
Args:
@@ -22,7 +26,8 @@ class TestUploadState(State):
"""
pass
- def not_drop_handler(self, not_files):
+ @event
+ def not_drop_handler(self, not_files: Any):
"""Handle the drop event without defining the files argument.
Args:
@@ -42,7 +47,7 @@ def test_get_upload_url():
def test__on_drop_spec():
- assert isinstance(_on_drop_spec(Var.create([])), list)
+ assert isinstance(_on_drop_spec(LiteralVar.create([])), tuple)
def test_upload_create():
@@ -55,7 +60,7 @@ def test_upload_create():
up_comp_2 = Upload.create(
id="foo_id",
- on_drop=TestUploadState.drop_handler([]), # type: ignore
+ on_drop=UploadStateTest.drop_handler([]), # type: ignore
)
assert isinstance(up_comp_2, Upload)
assert up_comp_2.is_used
@@ -65,7 +70,7 @@ def test_upload_create():
up_comp_3 = Upload.create(
id="foo_id",
- on_drop=TestUploadState.drop_handler,
+ on_drop=UploadStateTest.drop_handler,
)
assert isinstance(up_comp_3, Upload)
assert up_comp_3.is_used
@@ -75,7 +80,7 @@ def test_upload_create():
up_comp_4 = Upload.create(
id="foo_id",
- on_drop=TestUploadState.not_drop_handler([]), # type: ignore
+ on_drop=UploadStateTest.not_drop_handler([]), # type: ignore
)
assert isinstance(up_comp_4, Upload)
assert up_comp_4.is_used
@@ -91,7 +96,7 @@ def test_styled_upload_create():
styled_up_comp_2 = StyledUpload.create(
id="foo_id",
- on_drop=TestUploadState.drop_handler([]), # type: ignore
+ on_drop=UploadStateTest.drop_handler([]), # type: ignore
)
assert isinstance(styled_up_comp_2, StyledUpload)
assert styled_up_comp_2.is_used
@@ -101,7 +106,7 @@ def test_styled_upload_create():
styled_up_comp_3 = StyledUpload.create(
id="foo_id",
- on_drop=TestUploadState.drop_handler,
+ on_drop=UploadStateTest.drop_handler,
)
assert isinstance(styled_up_comp_3, StyledUpload)
assert styled_up_comp_3.is_used
@@ -111,7 +116,7 @@ def test_styled_upload_create():
styled_up_comp_4 = StyledUpload.create(
id="foo_id",
- on_drop=TestUploadState.not_drop_handler([]), # type: ignore
+ on_drop=UploadStateTest.not_drop_handler([]), # type: ignore
)
assert isinstance(styled_up_comp_4, StyledUpload)
assert styled_up_comp_4.is_used
diff --git a/tests/components/datadisplay/__init__.py b/tests/units/components/datadisplay/__init__.py
similarity index 100%
rename from tests/components/datadisplay/__init__.py
rename to tests/units/components/datadisplay/__init__.py
diff --git a/tests/components/datadisplay/conftest.py b/tests/units/components/datadisplay/conftest.py
similarity index 100%
rename from tests/components/datadisplay/conftest.py
rename to tests/units/components/datadisplay/conftest.py
diff --git a/tests/units/components/datadisplay/test_code.py b/tests/units/components/datadisplay/test_code.py
new file mode 100644
index 000000000..6b7168756
--- /dev/null
+++ b/tests/units/components/datadisplay/test_code.py
@@ -0,0 +1,13 @@
+import pytest
+
+from reflex.components.datadisplay.code import CodeBlock, Theme
+
+
+@pytest.mark.parametrize(
+ "theme, expected",
+ [(Theme.one_light, "oneLight"), (Theme.one_dark, "oneDark")],
+)
+def test_code_light_dark_theme(theme, expected):
+ code_block = CodeBlock.create(theme=theme)
+
+ assert code_block.theme._js_expr == expected # type: ignore
diff --git a/tests/units/components/datadisplay/test_dataeditor.py b/tests/units/components/datadisplay/test_dataeditor.py
new file mode 100644
index 000000000..63b156e74
--- /dev/null
+++ b/tests/units/components/datadisplay/test_dataeditor.py
@@ -0,0 +1,11 @@
+from reflex.components.datadisplay.dataeditor import DataEditor
+
+
+def test_dataeditor():
+ editor_wrapper = DataEditor.create().render()
+ editor = editor_wrapper["children"][0]
+ assert editor_wrapper["name"] == "div"
+ assert editor_wrapper["props"] == [
+ 'css={({ ["width"] : "100%", ["height"] : "100%" })}'
+ ]
+ assert editor["name"] == "DataEditor"
diff --git a/tests/components/datadisplay/test_datatable.py b/tests/units/components/datadisplay/test_datatable.py
similarity index 100%
rename from tests/components/datadisplay/test_datatable.py
rename to tests/units/components/datadisplay/test_datatable.py
diff --git a/tests/units/components/datadisplay/test_shiki_code.py b/tests/units/components/datadisplay/test_shiki_code.py
new file mode 100644
index 000000000..eb473ba06
--- /dev/null
+++ b/tests/units/components/datadisplay/test_shiki_code.py
@@ -0,0 +1,172 @@
+import pytest
+
+from reflex.components.datadisplay.shiki_code_block import (
+ ShikiBaseTransformers,
+ ShikiCodeBlock,
+ ShikiHighLevelCodeBlock,
+ ShikiJsTransformer,
+)
+from reflex.components.el.elements.forms import Button
+from reflex.components.lucide.icon import Icon
+from reflex.components.radix.themes.layout.box import Box
+from reflex.style import Style
+from reflex.vars import Var
+
+
+@pytest.mark.parametrize(
+ "library, fns, expected_output, raises_exception",
+ [
+ ("some_library", ["function_one"], ["function_one"], False),
+ ("some_library", [123], None, True),
+ ("some_library", [], [], False),
+ (
+ "some_library",
+ ["function_one", "function_two"],
+ ["function_one", "function_two"],
+ False,
+ ),
+ ("", ["function_one"], ["function_one"], False),
+ ("some_library", ["function_one", 789], None, True),
+ ("", [], [], False),
+ ],
+)
+def test_create_transformer(library, fns, expected_output, raises_exception):
+ if raises_exception:
+ # Ensure ValueError is raised for invalid cases
+ with pytest.raises(ValueError):
+ ShikiCodeBlock.create_transformer(library, fns)
+ else:
+ transformer = ShikiCodeBlock.create_transformer(library, fns)
+ assert isinstance(transformer, ShikiBaseTransformers)
+ assert transformer.library == library
+
+ # Verify that the functions are correctly wrapped in FunctionStringVar
+ function_names = [str(fn) for fn in transformer.fns]
+ assert function_names == expected_output
+
+
+@pytest.mark.parametrize(
+ "code_block, children, props, expected_first_child, expected_styles",
+ [
+ ("print('Hello')", ["print('Hello')"], {}, "print('Hello')", {}),
+ (
+ "print('Hello')",
+ ["print('Hello')", "More content"],
+ {},
+ "print('Hello')",
+ {},
+ ),
+ (
+ "print('Hello')",
+ ["print('Hello')"],
+ {
+ "transformers": [
+ ShikiBaseTransformers(
+ library="lib", fns=[], style=Style({"color": "red"})
+ )
+ ]
+ },
+ "print('Hello')",
+ {"color": "red"},
+ ),
+ (
+ "print('Hello')",
+ ["print('Hello')"],
+ {
+ "transformers": [
+ ShikiBaseTransformers(
+ library="lib", fns=[], style=Style({"color": "red"})
+ )
+ ],
+ "style": {"background": "blue"},
+ },
+ "print('Hello')",
+ {"color": "red", "background": "blue"},
+ ),
+ ],
+)
+def test_create_shiki_code_block(
+ code_block, children, props, expected_first_child, expected_styles
+):
+ component = ShikiCodeBlock.create(code_block, *children, **props)
+
+ # Test that the created component is a Box
+ assert isinstance(component, Box)
+
+ # Test that the first child is the code
+ code_block_component = component.children[0]
+ assert code_block_component.code._var_value == expected_first_child # type: ignore
+
+ applied_styles = component.style
+ for key, value in expected_styles.items():
+ assert Var.create(applied_styles[key])._var_value == value
+
+
+@pytest.mark.parametrize(
+ "children, props, expected_transformers, expected_button_type",
+ [
+ (["print('Hello')"], {"use_transformers": True}, [ShikiJsTransformer], None),
+ (["print('Hello')"], {"can_copy": True}, None, Button),
+ (
+ ["print('Hello')"],
+ {
+ "can_copy": True,
+ "copy_button": Button.create(Icon.create(tag="a_arrow_down")),
+ },
+ None,
+ Button,
+ ),
+ ],
+)
+def test_create_shiki_high_level_code_block(
+ children, props, expected_transformers, expected_button_type
+):
+ component = ShikiHighLevelCodeBlock.create(*children, **props)
+
+ # Test that the created component is a Box
+ assert isinstance(component, Box)
+
+ # Test that the first child is the code block component
+ code_block_component = component.children[0]
+ assert code_block_component.code._var_value == children[0] # type: ignore
+
+ # Check if the transformer is set correctly if expected
+ if expected_transformers:
+ exp_trans_names = [t.__name__ for t in expected_transformers]
+ for transformer in code_block_component.transformers._var_value: # type: ignore
+ assert type(transformer).__name__ in exp_trans_names
+
+ # Check if the second child is the copy button if can_copy is True
+ if props.get("can_copy", False):
+ if props.get("copy_button"):
+ assert isinstance(component.children[1], expected_button_type)
+ assert component.children[1] == props["copy_button"]
+ else:
+ assert isinstance(component.children[1], expected_button_type)
+ else:
+ assert len(component.children) == 1
+
+
+@pytest.mark.parametrize(
+ "children, props",
+ [
+ (["print('Hello')"], {"theme": "dark"}),
+ (["print('Hello')"], {"language": "javascript"}),
+ ],
+)
+def test_shiki_high_level_code_block_theme_language_mapping(children, props):
+ component = ShikiHighLevelCodeBlock.create(*children, **props)
+
+ # Test that the theme is mapped correctly
+ if "theme" in props:
+ assert component.children[
+ 0
+ ].theme._var_value == ShikiHighLevelCodeBlock._map_themes(props["theme"]) # type: ignore
+
+ # Test that the language is mapped correctly
+ if "language" in props:
+ assert component.children[
+ 0
+ ].language._var_value == ShikiHighLevelCodeBlock._map_languages( # type: ignore
+ props["language"]
+ )
diff --git a/tests/components/el/test_html.py b/tests/units/components/el/test_html.py
similarity index 100%
rename from tests/components/el/test_html.py
rename to tests/units/components/el/test_html.py
diff --git a/tests/units/components/el/test_svg.py b/tests/units/components/el/test_svg.py
new file mode 100644
index 000000000..29aaa96dd
--- /dev/null
+++ b/tests/units/components/el/test_svg.py
@@ -0,0 +1,74 @@
+from reflex.components.el.elements.media import (
+ Circle,
+ Defs,
+ Ellipse,
+ Line,
+ LinearGradient,
+ Path,
+ Polygon,
+ RadialGradient,
+ Rect,
+ Stop,
+ Svg,
+ Text,
+)
+
+
+def test_circle():
+ circle = Circle.create().render()
+ assert circle["name"] == "circle"
+
+
+def test_defs():
+ defs = Defs.create().render()
+ assert defs["name"] == "defs"
+
+
+def test_ellipse():
+ ellipse = Ellipse.create().render()
+ assert ellipse["name"] == "ellipse"
+
+
+def test_line():
+ line = Line.create().render()
+ assert line["name"] == "line"
+
+
+def test_linear_gradient():
+ linear_gradient = LinearGradient.create().render()
+ assert linear_gradient["name"] == "linearGradient"
+
+
+def test_path():
+ path = Path.create().render()
+ assert path["name"] == "path"
+
+
+def test_polygon():
+ polygon = Polygon.create().render()
+ assert polygon["name"] == "polygon"
+
+
+def test_radial_gradient():
+ radial_gradient = RadialGradient.create().render()
+ assert radial_gradient["name"] == "radialGradient"
+
+
+def test_rect():
+ rect = Rect.create().render()
+ assert rect["name"] == "rect"
+
+
+def test_svg():
+ svg = Svg.create().render()
+ assert svg["name"] == "svg"
+
+
+def test_text():
+ text = Text.create().render()
+ assert text["name"] == "text"
+
+
+def test_stop():
+ stop = Stop.create().render()
+ assert stop["name"] == "stop"
diff --git a/tests/components/core/__init__.py b/tests/units/components/forms/__init__.py
similarity index 100%
rename from tests/components/core/__init__.py
rename to tests/units/components/forms/__init__.py
diff --git a/tests/components/forms/test_form.py b/tests/units/components/forms/test_form.py
similarity index 54%
rename from tests/components/forms/test_form.py
rename to tests/units/components/forms/test_form.py
index b9eff2daf..5f3ba2d37 100644
--- a/tests/components/forms/test_form.py
+++ b/tests/units/components/forms/test_form.py
@@ -1,12 +1,12 @@
-from reflex.components.chakra.forms.form import Form
-from reflex.event import EventChain
-from reflex.vars import BaseVar
+from reflex.components.radix.primitives.form import Form
+from reflex.event import EventChain, prevent_default
+from reflex.vars.base import Var
def test_render_on_submit():
"""Test that on_submit event chain is rendered as a separate function."""
- submit_it = BaseVar(
- _var_name="submit_it",
+ submit_it = Var(
+ _js_expr="submit_it",
_var_type=EventChain,
)
f = Form.create(on_submit=submit_it)
@@ -15,7 +15,6 @@ def test_render_on_submit():
def test_render_no_on_submit():
- """A form without on_submit should not render a submit handler."""
+ """A form without on_submit should render a prevent_default handler."""
f = Form.create()
- for prop in f.render()["props"]:
- assert "onSubmit" not in prop
+ assert f.event_triggers["on_submit"] == prevent_default
diff --git a/tests/components/graphing/__init__.py b/tests/units/components/graphing/__init__.py
similarity index 100%
rename from tests/components/graphing/__init__.py
rename to tests/units/components/graphing/__init__.py
diff --git a/tests/components/graphing/test_plotly.py b/tests/units/components/graphing/test_plotly.py
similarity index 100%
rename from tests/components/graphing/test_plotly.py
rename to tests/units/components/graphing/test_plotly.py
diff --git a/tests/components/graphing/test_recharts.py b/tests/units/components/graphing/test_recharts.py
similarity index 100%
rename from tests/components/graphing/test_recharts.py
rename to tests/units/components/graphing/test_recharts.py
diff --git a/tests/components/layout/__init__.py b/tests/units/components/layout/__init__.py
similarity index 100%
rename from tests/components/layout/__init__.py
rename to tests/units/components/layout/__init__.py
diff --git a/tests/components/lucide/test_icon.py b/tests/units/components/lucide/test_icon.py
similarity index 59%
rename from tests/components/lucide/test_icon.py
rename to tests/units/components/lucide/test_icon.py
index d61f3a9aa..b0a3475dd 100644
--- a/tests/components/lucide/test_icon.py
+++ b/tests/units/components/lucide/test_icon.py
@@ -1,6 +1,6 @@
import pytest
-from reflex.components.lucide.icon import LUCIDE_ICON_LIST, RENAMED_ICONS_05, Icon
+from reflex.components.lucide.icon import LUCIDE_ICON_LIST, Icon
from reflex.utils import format
@@ -10,16 +10,6 @@ def test_icon(tag):
assert icon.alias == f"Lucide{format.to_title_case(tag)}Icon"
-RENAMED_TAGS = [tag for tag in RENAMED_ICONS_05.items()]
-
-
-@pytest.mark.parametrize("tag, new_tag", RENAMED_TAGS)
-def test_icon_renamed_tags(tag, new_tag):
- Icon.create(tag)
- # TODO: need a PR so we can pass the following test. Currently it fails and uses the old tag as the import.
- # assert icon.alias == f"Lucide{format.to_title_case(new_tag)}Icon"
-
-
def test_icon_missing_tag():
with pytest.raises(AttributeError):
_ = Icon.create()
diff --git a/tests/components/forms/__init__.py b/tests/units/components/markdown/__init__.py
similarity index 100%
rename from tests/components/forms/__init__.py
rename to tests/units/components/markdown/__init__.py
diff --git a/tests/units/components/markdown/test_markdown.py b/tests/units/components/markdown/test_markdown.py
new file mode 100644
index 000000000..866f32ae1
--- /dev/null
+++ b/tests/units/components/markdown/test_markdown.py
@@ -0,0 +1,190 @@
+from typing import Type
+
+import pytest
+
+from reflex.components.component import Component, memo
+from reflex.components.datadisplay.code import CodeBlock
+from reflex.components.datadisplay.shiki_code_block import ShikiHighLevelCodeBlock
+from reflex.components.markdown.markdown import Markdown, MarkdownComponentMap
+from reflex.components.radix.themes.layout.box import Box
+from reflex.components.radix.themes.typography.heading import Heading
+from reflex.vars.base import Var
+
+
+class CustomMarkdownComponent(Component, MarkdownComponentMap):
+ """A custom markdown component."""
+
+ tag = "CustomMarkdownComponent"
+ library = "custom"
+
+ @classmethod
+ def get_fn_args(cls) -> tuple[str, ...]:
+ """Return the function arguments.
+
+ Returns:
+ The function arguments.
+ """
+ return ("custom_node", "custom_children", "custom_props")
+
+ @classmethod
+ def get_fn_body(cls) -> Var:
+ """Return the function body.
+
+ Returns:
+ The function body.
+ """
+ return Var(_js_expr="{return custom_node + custom_children + custom_props}")
+
+
+def syntax_highlighter_memoized_component(codeblock: Type[Component]):
+ @memo
+ def code_block(code: str, language: str):
+ return Box.create(
+ codeblock.create(
+ code,
+ language=language,
+ class_name="code-block",
+ can_copy=True,
+ ),
+ class_name="relative mb-4",
+ )
+
+ def code_block_markdown(*children, **props):
+ return code_block(
+ code=children[0], language=props.pop("language", "plain"), **props
+ )
+
+ return code_block_markdown
+
+
+@pytest.mark.parametrize(
+ "fn_body, fn_args, explicit_return, expected",
+ [
+ (
+ None,
+ None,
+ False,
+ Var(_js_expr="(({node, children, ...props}) => undefined)"),
+ ),
+ ("return node", ("node",), True, Var(_js_expr="(({node}) => {return node})")),
+ (
+ "return node + children",
+ ("node", "children"),
+ True,
+ Var(_js_expr="(({node, children}) => {return node + children})"),
+ ),
+ (
+ "return node + props",
+ ("node", "...props"),
+ True,
+ Var(_js_expr="(({node, ...props}) => {return node + props})"),
+ ),
+ (
+ "return node + children + props",
+ ("node", "children", "...props"),
+ True,
+ Var(
+ _js_expr="(({node, children, ...props}) => {return node + children + props})"
+ ),
+ ),
+ ],
+)
+def test_create_map_fn_var(fn_body, fn_args, explicit_return, expected):
+ result = MarkdownComponentMap.create_map_fn_var(
+ fn_body=Var(_js_expr=fn_body, _var_type=str) if fn_body else None,
+ fn_args=fn_args,
+ explicit_return=explicit_return,
+ )
+ assert result._js_expr == expected._js_expr
+
+
+@pytest.mark.parametrize(
+ ("cls", "fn_body", "fn_args", "explicit_return", "expected"),
+ [
+ (
+ MarkdownComponentMap,
+ None,
+ None,
+ False,
+ Var(_js_expr="(({node, children, ...props}) => undefined)"),
+ ),
+ (
+ MarkdownComponentMap,
+ "return node",
+ ("node",),
+ True,
+ Var(_js_expr="(({node}) => {return node})"),
+ ),
+ (
+ CustomMarkdownComponent,
+ None,
+ None,
+ True,
+ Var(
+ _js_expr="(({custom_node, custom_children, custom_props}) => {return custom_node + custom_children + custom_props})"
+ ),
+ ),
+ (
+ CustomMarkdownComponent,
+ "return custom_node",
+ ("custom_node",),
+ True,
+ Var(_js_expr="(({custom_node}) => {return custom_node})"),
+ ),
+ ],
+)
+def test_create_map_fn_var_subclass(cls, fn_body, fn_args, explicit_return, expected):
+ result = cls.create_map_fn_var(
+ fn_body=Var(_js_expr=fn_body, _var_type=int) if fn_body else None,
+ fn_args=fn_args,
+ explicit_return=explicit_return,
+ )
+ assert result._js_expr == expected._js_expr
+
+
+@pytest.mark.parametrize(
+ "key,component_map, expected",
+ [
+ (
+ "code",
+ {},
+ """(({node, inline, className, children, ...props}) => { const match = (className || '').match(/language-(?.*)/); const _language = match ? match[1] : ''; if (_language) { (async () => { try { const module = await import(`react-syntax-highlighter/dist/cjs/languages/prism/${_language}`); SyntaxHighlighter.registerLanguage(_language, module.default); } catch (error) { console.error(`Error importing language module for ${_language}:`, error); } })(); } ; return inline ? ( {children} ) : ( ); })""",
+ ),
+ (
+ "code",
+ {
+ "codeblock": lambda value, **props: ShikiHighLevelCodeBlock.create(
+ value, **props
+ )
+ },
+ """(({node, inline, className, children, ...props}) => { const match = (className || '').match(/language-(?.*)/); const _language = match ? match[1] : ''; ; return inline ? ( {children} ) : ( ); })""",
+ ),
+ (
+ "h1",
+ {
+ "h1": lambda value: CustomMarkdownComponent.create(
+ Heading.create(value, as_="h1", size="6", margin_y="0.5em")
+ )
+ },
+ """(({custom_node, custom_children, custom_props}) => ({children} ))""",
+ ),
+ (
+ "code",
+ {"codeblock": syntax_highlighter_memoized_component(CodeBlock)},
+ """(({node, inline, className, children, ...props}) => { const match = (className || '').match(/language-(?.*)/); const _language = match ? match[1] : ''; if (_language) { (async () => { try { const module = await import(`react-syntax-highlighter/dist/cjs/languages/prism/${_language}`); SyntaxHighlighter.registerLanguage(_language, module.default); } catch (error) { console.error(`Error importing language module for ${_language}:`, error); } })(); } ; return inline ? ( {children} ) : ( ); })""",
+ ),
+ (
+ "code",
+ {
+ "codeblock": syntax_highlighter_memoized_component(
+ ShikiHighLevelCodeBlock
+ )
+ },
+ """(({node, inline, className, children, ...props}) => { const match = (className || '').match(/language-(?.*)/); const _language = match ? match[1] : ''; ; return inline ? ( {children} ) : ( ); })""",
+ ),
+ ],
+)
+def test_markdown_format_component(key, component_map, expected):
+ markdown = Markdown.create("# header", component_map=component_map)
+ result = markdown.format_component_map()
+ assert str(result[key]) == expected
diff --git a/tests/components/media/__init__.py b/tests/units/components/media/__init__.py
similarity index 100%
rename from tests/components/media/__init__.py
rename to tests/units/components/media/__init__.py
diff --git a/tests/components/media/test_image.py b/tests/units/components/media/test_image.py
similarity index 78%
rename from tests/components/media/test_image.py
rename to tests/units/components/media/test_image.py
index a39895c67..742bd8c38 100644
--- a/tests/components/media/test_image.py
+++ b/tests/units/components/media/test_image.py
@@ -1,4 +1,3 @@
-# PIL is only available in python 3.8+
import numpy as np
import PIL
import pytest
@@ -7,6 +6,7 @@ from PIL.Image import Image as Img
import reflex as rx
from reflex.components.next.image import Image # type: ignore
from reflex.utils.serializers import serialize, serialize_image
+from reflex.vars.sequence import StringVar
@pytest.fixture
@@ -36,9 +36,13 @@ def test_set_src_str():
"""Test that setting the src works."""
image = rx.image(src="pic2.jpeg")
# when using next/image, we explicitly create a _var_is_str Var
- # assert str(image.src) == "{`pic2.jpeg`}" # type: ignore
+ assert str(image.src) in ( # type: ignore
+ '"pic2.jpeg"',
+ "'pic2.jpeg'",
+ "`pic2.jpeg`",
+ )
# For plain rx.el.img, an explicit var is not created, so the quoting happens later
- assert str(image.src) == "pic2.jpeg" # type: ignore
+ # assert str(image.src) == "pic2.jpeg" # type: ignore #noqa: ERA001
def test_set_src_img(pil_image: Img):
@@ -48,7 +52,7 @@ def test_set_src_img(pil_image: Img):
pil_image: The image to serialize.
"""
image = Image.create(src=pil_image)
- assert str(image.src._var_name) == serialize_image(pil_image) # type: ignore
+ assert str(image.src._js_expr) == '"' + serialize_image(pil_image) + '"' # type: ignore
def test_render(pil_image: Img):
@@ -58,4 +62,4 @@ def test_render(pil_image: Img):
pil_image: The image to serialize.
"""
image = Image.create(src=pil_image)
- assert image.src._var_is_string # type: ignore
+ assert isinstance(image.src, StringVar) # type: ignore
diff --git a/tests/components/radix/test_icon_button.py b/tests/units/components/radix/test_icon_button.py
similarity index 86%
rename from tests/components/radix/test_icon_button.py
rename to tests/units/components/radix/test_icon_button.py
index 852c0c97c..8047cf7b2 100644
--- a/tests/components/radix/test_icon_button.py
+++ b/tests/units/components/radix/test_icon_button.py
@@ -3,7 +3,7 @@ import pytest
from reflex.components.lucide.icon import Icon
from reflex.components.radix.themes.components.icon_button import IconButton
from reflex.style import Style
-from reflex.vars import Var
+from reflex.vars.base import LiteralVar
def test_icon_button():
@@ -26,5 +26,5 @@ def test_icon_button_size_prop():
ib1 = IconButton.create("activity", size="2")
assert isinstance(ib1, IconButton)
- ib2 = IconButton.create("activity", size=Var.create("2"))
+ ib2 = IconButton.create("activity", size=LiteralVar.create("2"))
assert isinstance(ib2, IconButton)
diff --git a/tests/components/radix/test_layout.py b/tests/units/components/radix/test_layout.py
similarity index 100%
rename from tests/components/radix/test_layout.py
rename to tests/units/components/radix/test_layout.py
diff --git a/tests/units/components/recharts/test_cartesian.py b/tests/units/components/recharts/test_cartesian.py
new file mode 100644
index 000000000..3337427bd
--- /dev/null
+++ b/tests/units/components/recharts/test_cartesian.py
@@ -0,0 +1,50 @@
+from reflex.components.recharts import (
+ Area,
+ Bar,
+ Brush,
+ Line,
+ Scatter,
+ XAxis,
+ YAxis,
+ ZAxis,
+)
+
+
+def test_xaxis():
+ x_axis = XAxis.create("x").render()
+ assert x_axis["name"] == "RechartsXAxis"
+
+
+def test_yaxis():
+ x_axis = YAxis.create("y").render()
+ assert x_axis["name"] == "RechartsYAxis"
+
+
+def test_zaxis():
+ x_axis = ZAxis.create("z").render()
+ assert x_axis["name"] == "RechartsZAxis"
+
+
+def test_brush():
+ brush = Brush.create().render()
+ assert brush["name"] == "RechartsBrush"
+
+
+def test_area():
+ area = Area.create().render()
+ assert area["name"] == "RechartsArea"
+
+
+def test_bar():
+ bar = Bar.create().render()
+ assert bar["name"] == "RechartsBar"
+
+
+def test_line():
+ line = Line.create().render()
+ assert line["name"] == "RechartsLine"
+
+
+def test_scatter():
+ scatter = Scatter.create().render()
+ assert scatter["name"] == "RechartsScatter"
diff --git a/tests/units/components/recharts/test_polar.py b/tests/units/components/recharts/test_polar.py
new file mode 100644
index 000000000..4e4af0f49
--- /dev/null
+++ b/tests/units/components/recharts/test_polar.py
@@ -0,0 +1,38 @@
+from reflex.components.recharts import (
+ Pie,
+ PolarAngleAxis,
+ PolarGrid,
+ PolarRadiusAxis,
+ Radar,
+ RadialBar,
+)
+
+
+def test_pie():
+ pie = Pie.create().render()
+ assert pie["name"] == "RechartsPie"
+
+
+def test_radar():
+ radar = Radar.create().render()
+ assert radar["name"] == "RechartsRadar"
+
+
+def test_radialbar():
+ radialbar = RadialBar.create().render()
+ assert radialbar["name"] == "RechartsRadialBar"
+
+
+def test_polarangleaxis():
+ polarangleaxis = PolarAngleAxis.create().render()
+ assert polarangleaxis["name"] == "RechartsPolarAngleAxis"
+
+
+def test_polargrid():
+ polargrid = PolarGrid.create().render()
+ assert polargrid["name"] == "RechartsPolarGrid"
+
+
+def test_polarradiusaxis():
+ polarradiusaxis = PolarRadiusAxis.create().render()
+ assert polarradiusaxis["name"] == "RechartsPolarRadiusAxis"
diff --git a/tests/components/test_component.py b/tests/units/components/test_component.py
similarity index 78%
rename from tests/components/test_component.py
rename to tests/units/components/test_component.py
index 78c42f177..674873b69 100644
--- a/tests/components/test_component.py
+++ b/tests/units/components/test_component.py
@@ -8,20 +8,29 @@ from reflex.base import Base
from reflex.compiler.compiler import compile_components
from reflex.components.base.bare import Bare
from reflex.components.base.fragment import Fragment
-from reflex.components.chakra.layout.box import Box
from reflex.components.component import (
Component,
CustomComponent,
StatefulComponent,
custom_component,
)
+from reflex.components.radix.themes.layout.box import Box
from reflex.constants import EventTriggers
-from reflex.event import EventChain, EventHandler, parse_args_spec
+from reflex.event import (
+ EventChain,
+ EventHandler,
+ input_event,
+ no_args_event_spec,
+ parse_args_spec,
+ passthrough_event_spec,
+)
from reflex.state import BaseState
from reflex.style import Style
from reflex.utils import imports
+from reflex.utils.exceptions import EventFnArgMismatch
from reflex.utils.imports import ImportDict, ImportVar, ParsedImportDict, parse_imports
-from reflex.vars import BaseVar, Var, VarData
+from reflex.vars import VarData
+from reflex.vars.base import LiteralVar, Var
@pytest.fixture
@@ -35,6 +44,18 @@ def test_state():
def do_something_arg(self, arg):
pass
+ def do_something_with_bool(self, arg: bool):
+ pass
+
+ def do_something_with_int(self, arg: int):
+ pass
+
+ def do_something_with_list_int(self, arg: list[int]):
+ pass
+
+ def do_something_with_list_str(self, arg: list[str]):
+ pass
+
return TestState
@@ -77,6 +98,8 @@ def component2() -> Type[Component]:
# A test list prop.
arr: Var[List[str]]
+ on_prop_event: EventHandler[lambda e0: [e0]]
+
def get_event_triggers(self) -> Dict[str, Any]:
"""Test controlled triggers.
@@ -85,8 +108,10 @@ def component2() -> Type[Component]:
"""
return {
**super().get_event_triggers(),
- "on_open": lambda e0: [e0],
- "on_close": lambda e0: [e0],
+ "on_open": passthrough_event_spec(bool),
+ "on_close": passthrough_event_spec(bool),
+ "on_user_visited_count_changed": passthrough_event_spec(int),
+ "on_user_list_changed": passthrough_event_spec(List[str]),
}
def _get_imports(self) -> ParsedImportDict:
@@ -229,8 +254,8 @@ def test_set_style_attrs(component1):
component1: A test component.
"""
component = component1(color="white", text_align="center")
- assert component.style["color"] == "white"
- assert component.style["textAlign"] == "center"
+ assert str(component.style["color"]) == '"white"'
+ assert str(component.style["textAlign"]) == '"center"'
def test_custom_attrs(component1):
@@ -254,7 +279,10 @@ def test_create_component(component1):
c = component1.create(*children, **attrs)
assert isinstance(c, component1)
assert c.children == children
- assert c.style == {"color": "white", "textAlign": "center"}
+ assert (
+ str(LiteralVar.create(c.style))
+ == '({ ["color"] : "white", ["textAlign"] : "center" })'
+ )
@pytest.mark.parametrize(
@@ -262,121 +290,121 @@ def test_create_component(component1):
[
pytest.param(
"text",
- Var.create("hello"),
+ LiteralVar.create("hello"),
None,
id="text",
),
pytest.param(
"text",
- BaseVar(_var_name="hello", _var_type=Optional[str]),
+ Var(_js_expr="hello", _var_type=Optional[str]),
None,
id="text-optional",
),
pytest.param(
"text",
- BaseVar(_var_name="hello", _var_type=Union[str, None]),
+ Var(_js_expr="hello", _var_type=Union[str, None]),
None,
id="text-union-str-none",
),
pytest.param(
"text",
- BaseVar(_var_name="hello", _var_type=Union[None, str]),
+ Var(_js_expr="hello", _var_type=Union[None, str]),
None,
id="text-union-none-str",
),
pytest.param(
"text",
- Var.create(1),
+ LiteralVar.create(1),
TypeError,
id="text-int",
),
pytest.param(
"number",
- Var.create(1),
+ LiteralVar.create(1),
None,
id="number",
),
pytest.param(
"number",
- BaseVar(_var_name="1", _var_type=Optional[int]),
+ Var(_js_expr="1", _var_type=Optional[int]),
None,
id="number-optional",
),
pytest.param(
"number",
- BaseVar(_var_name="1", _var_type=Union[int, None]),
+ Var(_js_expr="1", _var_type=Union[int, None]),
None,
id="number-union-int-none",
),
pytest.param(
"number",
- BaseVar(_var_name="1", _var_type=Union[None, int]),
+ Var(_js_expr="1", _var_type=Union[None, int]),
None,
id="number-union-none-int",
),
pytest.param(
"number",
- Var.create("1"),
+ LiteralVar.create("1"),
TypeError,
id="number-str",
),
pytest.param(
"text_or_number",
- Var.create("hello"),
+ LiteralVar.create("hello"),
None,
id="text_or_number-str",
),
pytest.param(
"text_or_number",
- Var.create(1),
+ LiteralVar.create(1),
None,
id="text_or_number-int",
),
pytest.param(
"text_or_number",
- BaseVar(_var_name="hello", _var_type=Optional[str]),
+ Var(_js_expr="hello", _var_type=Optional[str]),
None,
id="text_or_number-optional-str",
),
pytest.param(
"text_or_number",
- BaseVar(_var_name="hello", _var_type=Union[str, None]),
+ Var(_js_expr="hello", _var_type=Union[str, None]),
None,
id="text_or_number-union-str-none",
),
pytest.param(
"text_or_number",
- BaseVar(_var_name="hello", _var_type=Union[None, str]),
+ Var(_js_expr="hello", _var_type=Union[None, str]),
None,
id="text_or_number-union-none-str",
),
pytest.param(
"text_or_number",
- BaseVar(_var_name="1", _var_type=Optional[int]),
+ Var(_js_expr="1", _var_type=Optional[int]),
None,
id="text_or_number-optional-int",
),
pytest.param(
"text_or_number",
- BaseVar(_var_name="1", _var_type=Union[int, None]),
+ Var(_js_expr="1", _var_type=Union[int, None]),
None,
id="text_or_number-union-int-none",
),
pytest.param(
"text_or_number",
- BaseVar(_var_name="1", _var_type=Union[None, int]),
+ Var(_js_expr="1", _var_type=Union[None, int]),
None,
id="text_or_number-union-none-int",
),
pytest.param(
"text_or_number",
- Var.create(1.0),
+ LiteralVar.create(1.0),
TypeError,
id="text_or_number-float",
),
pytest.param(
"text_or_number",
- BaseVar(_var_name="hello", _var_type=Optional[Union[str, int]]),
+ Var(_js_expr="hello", _var_type=Optional[Union[str, int]]),
None,
id="text_or_number-optional-union-str-int",
),
@@ -418,8 +446,8 @@ def test_add_style(component1, component2):
}
c1 = component1()._add_style_recursive(style) # type: ignore
c2 = component2()._add_style_recursive(style) # type: ignore
- assert c1.style["color"] == "white"
- assert c2.style["color"] == "black"
+ assert str(c1.style["color"]) == '"white"'
+ assert str(c2.style["color"]) == '"black"'
def test_add_style_create(component1, component2):
@@ -435,8 +463,8 @@ def test_add_style_create(component1, component2):
}
c1 = component1()._add_style_recursive(style) # type: ignore
c2 = component2()._add_style_recursive(style) # type: ignore
- assert c1.style["color"] == "white"
- assert c2.style["color"] == "black"
+ assert str(c1.style["color"]) == '"white"'
+ assert str(c2.style["color"]) == '"black"'
def test_get_imports(component1, component2):
@@ -491,7 +519,7 @@ def test_get_props(component1, component2):
component2: A test component.
"""
assert component1.get_props() == {"text", "number", "text_or_number"}
- assert component2.get_props() == {"arr"}
+ assert component2.get_props() == {"arr", "on_prop_event"}
@pytest.mark.parametrize(
@@ -569,7 +597,14 @@ def test_get_event_triggers(component1, component2):
assert component1().get_event_triggers().keys() == default_triggers
assert (
component2().get_event_triggers().keys()
- == {"on_open", "on_close"} | default_triggers
+ == {
+ "on_open",
+ "on_close",
+ "on_prop_event",
+ "on_user_visited_count_changed",
+ "on_user_list_changed",
+ }
+ | default_triggers
)
@@ -606,8 +641,8 @@ def test_create_filters_none_props(test_component):
assert "prop4" not in component.get_props()
# Assert that the style prop is present in the component's props
- assert component.style["color"] == "white"
- assert component.style["text-align"] == "center"
+ assert str(component.style["color"]) == '"white"'
+ assert str(component.style["text-align"]) == '"center"'
@pytest.mark.parametrize("children", [((None,),), ("foo", ("bar", (None,)))])
@@ -629,22 +664,19 @@ def test_component_create_unallowed_types(children, test_component):
"name": "Fragment",
"props": [],
"contents": "",
- "args": None,
- "special_props": set(),
+ "special_props": [],
"children": [
{
"name": "RadixThemesText",
- "props": ["as={`p`}"],
+ "props": ['as={"p"}'],
"contents": "",
- "args": None,
- "special_props": set(),
+ "special_props": [],
"children": [
{
"name": "",
"props": [],
- "contents": "{`first_text`}",
- "args": None,
- "special_props": set(),
+ "contents": '{"first_text"}',
+ "special_props": [],
"children": [],
"autofocus": False,
}
@@ -658,123 +690,111 @@ def test_component_create_unallowed_types(children, test_component):
(
(rx.text("first_text"), rx.text("second_text")),
{
- "args": None,
"autofocus": False,
"children": [
{
- "args": None,
"autofocus": False,
"children": [
{
- "args": None,
"autofocus": False,
"children": [],
- "contents": "{`first_text`}",
+ "contents": '{"first_text"}',
"name": "",
"props": [],
- "special_props": set(),
+ "special_props": [],
}
],
"contents": "",
"name": "RadixThemesText",
- "props": ["as={`p`}"],
- "special_props": set(),
+ "props": ['as={"p"}'],
+ "special_props": [],
},
{
- "args": None,
"autofocus": False,
"children": [
{
- "args": None,
"autofocus": False,
"children": [],
- "contents": "{`second_text`}",
+ "contents": '{"second_text"}',
"name": "",
"props": [],
- "special_props": set(),
+ "special_props": [],
}
],
"contents": "",
"name": "RadixThemesText",
- "props": ["as={`p`}"],
- "special_props": set(),
+ "props": ['as={"p"}'],
+ "special_props": [],
},
],
"contents": "",
"name": "Fragment",
"props": [],
- "special_props": set(),
+ "special_props": [],
},
),
(
(rx.text("first_text"), rx.box((rx.text("second_text"),))),
{
- "args": None,
"autofocus": False,
"children": [
{
- "args": None,
"autofocus": False,
"children": [
{
- "args": None,
"autofocus": False,
"children": [],
- "contents": "{`first_text`}",
+ "contents": '{"first_text"}',
"name": "",
"props": [],
- "special_props": set(),
+ "special_props": [],
}
],
"contents": "",
"name": "RadixThemesText",
- "props": ["as={`p`}"],
- "special_props": set(),
+ "props": ['as={"p"}'],
+ "special_props": [],
},
{
- "args": None,
"autofocus": False,
"children": [
{
- "args": None,
"autofocus": False,
"children": [
{
- "args": None,
"autofocus": False,
"children": [
{
- "args": None,
"autofocus": False,
"children": [],
- "contents": "{`second_text`}",
+ "contents": '{"second_text"}',
"name": "",
"props": [],
- "special_props": set(),
+ "special_props": [],
}
],
"contents": "",
"name": "RadixThemesText",
- "props": ["as={`p`}"],
- "special_props": set(),
+ "props": ['as={"p"}'],
+ "special_props": [],
}
],
"contents": "",
"name": "Fragment",
"props": [],
- "special_props": set(),
+ "special_props": [],
}
],
"contents": "",
"name": "RadixThemesBox",
"props": [],
- "special_props": set(),
+ "special_props": [],
},
],
"contents": "",
"name": "Fragment",
"props": [],
- "special_props": set(),
+ "special_props": [],
},
),
],
@@ -790,7 +810,8 @@ def test_component_create_unpack_tuple_child(test_component, element, expected):
comp = test_component.create(element)
assert len(comp.children) == 1
- assert isinstance((fragment_wrapper := comp.children[0]), Fragment)
+ fragment_wrapper = comp.children[0]
+ assert isinstance(fragment_wrapper, Fragment)
assert fragment_wrapper.render() == expected
@@ -824,9 +845,9 @@ def test_component_event_trigger_arbitrary_args():
comp = C1.create(on_foo=C1State.mock_handler)
assert comp.render()["props"][0] == (
- "onFoo={(__e,_alpha,_bravo,_charlie) => addEvents("
- f'[Event("{C1State.get_full_name()}.mock_handler", {{_e:__e.target.value,_bravo:_bravo["nested"],_charlie:((_charlie.custom) + (42))}})], '
- "[__e,_alpha,_bravo,_charlie], {})}"
+ "onFoo={((__e, _alpha, _bravo, _charlie) => (addEvents("
+ f'[(Event("{C1State.get_full_name()}.mock_handler", ({{ ["_e"] : __e["target"]["value"], ["_bravo"] : _bravo["nested"], ["_charlie"] : (_charlie["custom"] + 42) }}), ({{ }})))], '
+ "[__e, _alpha, _bravo, _charlie], ({ }))))}"
)
@@ -866,7 +887,7 @@ def test_custom_component_wrapper():
from reflex.components.radix.themes.typography.text import Text
ccomponent = my_component(
- rx.text("child"), width=Var.create(1), color=Var.create("red")
+ rx.text("child"), width=LiteralVar.create(1), color=LiteralVar.create("red")
)
assert isinstance(ccomponent, CustomComponent)
assert len(ccomponent.children) == 1
@@ -883,18 +904,104 @@ def test_invalid_event_handler_args(component2, test_state):
component2: A test component.
test_state: A test state.
"""
- # Uncontrolled event handlers should not take args.
- # This is okay.
- component2.create(on_click=test_state.do_something)
- # This is not okay.
- with pytest.raises(ValueError):
+ # EventHandler args must match
+ with pytest.raises(EventFnArgMismatch):
component2.create(on_click=test_state.do_something_arg)
- component2.create(on_open=test_state.do_something)
+
+ # Multiple EventHandler args: all must match
+ with pytest.raises(EventFnArgMismatch):
component2.create(
- on_open=[test_state.do_something_arg, test_state.do_something]
+ on_click=[test_state.do_something_arg, test_state.do_something]
)
- # However lambdas are okay.
+
+ # Enable when 0.7.0 happens
+ # # Event Handler types must match
+ # with pytest.raises(EventHandlerArgTypeMismatch):
+ # component2.create(
+ # on_user_visited_count_changed=test_state.do_something_with_bool # noqa: ERA001 RUF100
+ # ) # noqa: ERA001 RUF100
+ # with pytest.raises(EventHandlerArgTypeMismatch):
+ # component2.create(on_user_list_changed=test_state.do_something_with_int) #noqa: ERA001
+ # with pytest.raises(EventHandlerArgTypeMismatch):
+ # component2.create(on_user_list_changed=test_state.do_something_with_list_int) #noqa: ERA001
+
+ # component2.create(on_open=test_state.do_something_with_int) #noqa: ERA001
+ # component2.create(on_open=test_state.do_something_with_bool) #noqa: ERA001
+ # component2.create(on_user_visited_count_changed=test_state.do_something_with_int) #noqa: ERA001
+ # component2.create(on_user_list_changed=test_state.do_something_with_list_str) #noqa: ERA001
+
+ # lambda cannot return weird values.
+ with pytest.raises(ValueError):
+ component2.create(on_click=lambda: 1)
+ with pytest.raises(ValueError):
+ component2.create(on_click=lambda: [1])
+ with pytest.raises(ValueError):
+ component2.create(
+ on_click=lambda: (test_state.do_something_arg(1), test_state.do_something)
+ )
+
+ # lambda signature must match event trigger.
+ with pytest.raises(EventFnArgMismatch):
+ component2.create(on_click=lambda _: test_state.do_something_arg(1))
+
+ # lambda returning EventHandler must match spec
+ with pytest.raises(EventFnArgMismatch):
+ component2.create(on_click=lambda: test_state.do_something_arg)
+
+ # Mixed EventSpec and EventHandler must match spec.
+ with pytest.raises(EventFnArgMismatch):
+ component2.create(
+ on_click=lambda: [
+ test_state.do_something_arg(1),
+ test_state.do_something_arg,
+ ]
+ )
+
+
+def test_valid_event_handler_args(component2, test_state):
+ """Test that an valid event handler args do not raise exception.
+
+ Args:
+ component2: A test component.
+ test_state: A test state.
+ """
+ # Uncontrolled event handlers should not take args.
+ component2.create(on_click=test_state.do_something)
+ component2.create(on_click=test_state.do_something_arg(1))
+
+ # Does not raise because event handlers are allowed to have less args than the spec.
+ component2.create(on_open=test_state.do_something)
+ component2.create(on_prop_event=test_state.do_something)
+
+ # Controlled event handlers should take args.
+ component2.create(on_open=test_state.do_something_arg)
+ component2.create(on_prop_event=test_state.do_something_arg)
+
+ # Using a partial event spec bypasses arg validation (ignoring the args).
+ component2.create(on_open=test_state.do_something())
+ component2.create(on_prop_event=test_state.do_something())
+
+ # Multiple EventHandler args: all must match
+ component2.create(on_open=[test_state.do_something_arg, test_state.do_something])
+ component2.create(
+ on_prop_event=[test_state.do_something_arg, test_state.do_something]
+ )
+
+ # lambda returning EventHandler is okay if the spec matches.
+ component2.create(on_click=lambda: test_state.do_something)
+ component2.create(on_open=lambda _: test_state.do_something_arg)
+ component2.create(on_prop_event=lambda _: test_state.do_something_arg)
+ component2.create(on_open=lambda: test_state.do_something)
+ component2.create(on_prop_event=lambda: test_state.do_something)
+ component2.create(on_open=lambda _: test_state.do_something)
+ component2.create(on_prop_event=lambda _: test_state.do_something)
+
+ # lambda can always return an EventSpec.
component2.create(on_click=lambda: test_state.do_something_arg(1))
+ component2.create(on_open=lambda _: test_state.do_something_arg(1))
+ component2.create(on_prop_event=lambda _: test_state.do_something_arg(1))
+
+ # Return EventSpec and EventHandler (no arg).
component2.create(
on_click=lambda: [test_state.do_something_arg(1), test_state.do_something]
)
@@ -902,9 +1009,33 @@ def test_invalid_event_handler_args(component2, test_state):
on_click=lambda: [test_state.do_something_arg(1), test_state.do_something()]
)
- # Controlled event handlers should take args.
- # This is okay.
- component2.create(on_open=test_state.do_something_arg)
+ # Return 2 EventSpec.
+ component2.create(
+ on_open=lambda _: [test_state.do_something_arg(1), test_state.do_something()]
+ )
+ component2.create(
+ on_prop_event=lambda _: [
+ test_state.do_something_arg(1),
+ test_state.do_something(),
+ ]
+ )
+
+ # Return EventHandler (1 arg) and EventSpec.
+ component2.create(
+ on_open=lambda _: [test_state.do_something_arg, test_state.do_something()]
+ )
+ component2.create(
+ on_prop_event=lambda _: [test_state.do_something_arg, test_state.do_something()]
+ )
+ component2.create(
+ on_open=lambda _: [test_state.do_something_arg(1), test_state.do_something]
+ )
+ component2.create(
+ on_prop_event=lambda _: [
+ test_state.do_something_arg(1),
+ test_state.do_something,
+ ]
+ )
def test_get_hooks_nested(component1, component2, component3):
@@ -1002,10 +1133,10 @@ def test_component_with_only_valid_children(fixture, request):
@pytest.mark.parametrize(
"component,rendered",
[
- (rx.text("hi"), "\n {`hi`}\n "),
+ (rx.text("hi"), '\n\n{"hi"}\n '),
(
- rx.box(rx.chakra.heading("test", size="md")),
- "\n \n {`test`}\n \n ",
+ rx.box(rx.heading("test", size="3")),
+ '\n\n\n\n{"test"}\n \n ',
),
],
)
@@ -1060,44 +1191,43 @@ def test_stateful_banner():
assert isinstance(stateful_component, StatefulComponent)
-TEST_VAR = Var.create_safe("test")._replace(
+TEST_VAR = LiteralVar.create("test")._replace(
merge_var_data=VarData(
hooks={"useTest": None},
imports={"test": [ImportVar(tag="test")]},
state="Test",
- interpolations=[],
)
)
-FORMATTED_TEST_VAR = Var.create(f"foo{TEST_VAR}bar")
-STYLE_VAR = TEST_VAR._replace(_var_name="style", _var_is_local=False)
-EVENT_CHAIN_VAR = TEST_VAR._replace(_var_type=EventChain)
-ARG_VAR = Var.create("arg")
+FORMATTED_TEST_VAR = LiteralVar.create(f"foo{TEST_VAR}bar")
+STYLE_VAR = TEST_VAR._replace(_js_expr="style")
+EVENT_CHAIN_VAR = TEST_VAR.to(EventChain)
+ARG_VAR = Var(_js_expr="arg")
-TEST_VAR_DICT_OF_DICT = Var.create_safe({"a": {"b": "test"}})._replace(
+TEST_VAR_DICT_OF_DICT = LiteralVar.create({"a": {"b": "test"}})._replace(
merge_var_data=TEST_VAR._var_data
)
-FORMATTED_TEST_VAR_DICT_OF_DICT = Var.create_safe({"a": {"b": f"footestbar"}})._replace(
+FORMATTED_TEST_VAR_DICT_OF_DICT = LiteralVar.create(
+ {"a": {"b": "footestbar"}}
+)._replace(merge_var_data=TEST_VAR._var_data)
+
+TEST_VAR_LIST_OF_LIST = LiteralVar.create([["test"]])._replace(
+ merge_var_data=TEST_VAR._var_data
+)
+FORMATTED_TEST_VAR_LIST_OF_LIST = LiteralVar.create([["footestbar"]])._replace(
merge_var_data=TEST_VAR._var_data
)
-TEST_VAR_LIST_OF_LIST = Var.create_safe([["test"]])._replace(
- merge_var_data=TEST_VAR._var_data
-)
-FORMATTED_TEST_VAR_LIST_OF_LIST = Var.create_safe([["footestbar"]])._replace(
+TEST_VAR_LIST_OF_LIST_OF_LIST = LiteralVar.create([[["test"]]])._replace(
merge_var_data=TEST_VAR._var_data
)
+FORMATTED_TEST_VAR_LIST_OF_LIST_OF_LIST = LiteralVar.create(
+ [[["footestbar"]]]
+)._replace(merge_var_data=TEST_VAR._var_data)
-TEST_VAR_LIST_OF_LIST_OF_LIST = Var.create_safe([[["test"]]])._replace(
+TEST_VAR_LIST_OF_DICT = LiteralVar.create([{"a": "test"}])._replace(
merge_var_data=TEST_VAR._var_data
)
-FORMATTED_TEST_VAR_LIST_OF_LIST_OF_LIST = Var.create_safe([[["footestbar"]]])._replace(
- merge_var_data=TEST_VAR._var_data
-)
-
-TEST_VAR_LIST_OF_DICT = Var.create_safe([{"a": "test"}])._replace(
- merge_var_data=TEST_VAR._var_data
-)
-FORMATTED_TEST_VAR_LIST_OF_DICT = Var.create_safe([{"a": "footestbar"}])._replace(
+FORMATTED_TEST_VAR_LIST_OF_DICT = LiteralVar.create([{"a": "footestbar"}])._replace(
merge_var_data=TEST_VAR._var_data
)
@@ -1116,6 +1246,7 @@ class EventState(rx.State):
v: int = 42
+ @rx.event
def handler(self):
"""A handler that does nothing."""
@@ -1181,12 +1312,22 @@ class EventState(rx.State):
id="fstring-class_name",
),
pytest.param(
- rx.fragment(special_props={TEST_VAR}),
+ rx.fragment(class_name=f"foo{TEST_VAR}bar other-class"),
+ [LiteralVar.create(f"{FORMATTED_TEST_VAR} other-class")],
+ id="fstring-dual-class_name",
+ ),
+ pytest.param(
+ rx.fragment(class_name=[TEST_VAR, "other-class"]),
+ [LiteralVar.create([TEST_VAR, "other-class"]).join(" ")],
+ id="fstring-dual-class_name",
+ ),
+ pytest.param(
+ rx.fragment(special_props=[TEST_VAR]),
[TEST_VAR],
id="direct-special_props",
),
pytest.param(
- rx.fragment(special_props={Var.create(f"foo{TEST_VAR}bar")}),
+ rx.fragment(special_props=[LiteralVar.create(f"foo{TEST_VAR}bar")]),
[FORMATTED_TEST_VAR],
id="fstring-special_props",
),
@@ -1289,11 +1430,12 @@ class EventState(rx.State):
),
)
def test_get_vars(component, exp_vars):
- comp_vars = sorted(component._get_vars(), key=lambda v: v._var_name)
+ comp_vars = sorted(component._get_vars(), key=lambda v: v._js_expr)
assert len(comp_vars) == len(exp_vars)
+ print(comp_vars, exp_vars)
for comp_var, exp_var in zip(
comp_vars,
- sorted(exp_vars, key=lambda v: v._var_name),
+ sorted(exp_vars, key=lambda v: v._js_expr),
):
assert comp_var.equals(exp_var)
@@ -1334,9 +1476,11 @@ def test_instantiate_all_components():
continue
component = getattr(
rx,
- component_name
- if not isinstance(component_name, tuple)
- else component_name[1],
+ (
+ component_name
+ if not isinstance(component_name, tuple)
+ else component_name[1]
+ ),
)
if isinstance(component, type) and issubclass(component, Component):
component.create()
@@ -1404,7 +1548,7 @@ def test_validate_valid_children():
True,
rx.fragment(valid_component2()),
rx.fragment(
- rx.foreach(Var.create([1, 2, 3]), lambda x: valid_component2(x)) # type: ignore
+ rx.foreach(LiteralVar.create([1, 2, 3]), lambda x: valid_component2(x)) # type: ignore
),
)
)
@@ -1464,7 +1608,7 @@ def test_validate_valid_parents():
rx.fragment(valid_component3()),
rx.fragment(
rx.foreach(
- Var.create([1, 2, 3]), # type: ignore
+ LiteralVar.create([1, 2, 3]), # type: ignore
lambda x: valid_component2(valid_component3(x)),
)
),
@@ -1531,7 +1675,9 @@ def test_validate_invalid_children():
True,
rx.fragment(invalid_component()),
rx.fragment(
- rx.foreach(Var.create([1, 2, 3]), lambda x: invalid_component(x)) # type: ignore
+ rx.foreach(
+ LiteralVar.create([1, 2, 3]), lambda x: invalid_component(x)
+ ) # type: ignore
),
)
)
@@ -1594,70 +1740,14 @@ def test_rename_props():
c1 = C1.create(prop1="prop1_1", prop2="prop2_1")
rendered_c1 = c1.render()
- assert "renamed_prop1={`prop1_1`}" in rendered_c1["props"]
- assert "renamed_prop2={`prop2_1`}" in rendered_c1["props"]
+ assert 'renamed_prop1={"prop1_1"}' in rendered_c1["props"]
+ assert 'renamed_prop2={"prop2_1"}' in rendered_c1["props"]
c2 = C2.create(prop1="prop1_2", prop2="prop2_2", prop3="prop3_2")
rendered_c2 = c2.render()
- assert "renamed_prop1={`prop1_2`}" in rendered_c2["props"]
- assert "subclass_prop2={`prop2_2`}" in rendered_c2["props"]
- assert "renamed_prop3={`prop3_2`}" in rendered_c2["props"]
-
-
-def test_deprecated_props(capsys):
- """Assert that deprecated underscore suffix props are translated.
-
- Args:
- capsys: Pytest fixture for capturing stdout and stderr.
- """
-
- class C1(Component):
- tag = "C1"
-
- type: Var[str]
- min: Var[str]
- max: Var[str]
-
- # No warnings are emitted when using the new prop names.
- c1_1 = C1.create(type="type1", min="min1", max="max1")
- out_err = capsys.readouterr()
- assert not out_err.err
- assert not out_err.out
-
- c1_1_render = c1_1.render()
- assert "type={`type1`}" in c1_1_render["props"]
- assert "min={`min1`}" in c1_1_render["props"]
- assert "max={`max1`}" in c1_1_render["props"]
-
- # Deprecation warning is emitted with underscore suffix,
- # but the component still works.
- c1_2 = C1.create(type_="type2", min_="min2", max_="max2")
- out_err = capsys.readouterr()
- assert out_err.out.count("DeprecationWarning:") == 3
- assert not out_err.err
-
- c1_2_render = c1_2.render()
- assert "type={`type2`}" in c1_2_render["props"]
- assert "min={`min2`}" in c1_2_render["props"]
- assert "max={`max2`}" in c1_2_render["props"]
-
- class C2(Component):
- tag = "C2"
-
- type_: Var[str]
- min_: Var[str]
- max_: Var[str]
-
- # No warnings are emitted if the actual prop has an underscore suffix
- c2_1 = C2.create(type_="type1", min_="min1", max_="max1")
- out_err = capsys.readouterr()
- assert not out_err.err
- assert not out_err.out
-
- c2_1_render = c2_1.render()
- assert "type={`type1`}" in c2_1_render["props"]
- assert "min={`min1`}" in c2_1_render["props"]
- assert "max={`max1`}" in c2_1_render["props"]
+ assert 'renamed_prop1={"prop1_2"}' in rendered_c2["props"]
+ assert 'subclass_prop2={"prop2_2"}' in rendered_c2["props"]
+ assert 'renamed_prop3={"prop3_2"}' in rendered_c2["props"]
def test_custom_component_get_imports():
@@ -1709,7 +1799,7 @@ def test_custom_component_declare_event_handlers_in_fields():
return {
**super().get_event_triggers(),
"on_a": lambda e0: [e0],
- "on_b": lambda e0: [e0.target.value],
+ "on_b": input_event,
"on_c": lambda e0: [],
"on_d": lambda: [],
"on_e": lambda: [],
@@ -1718,9 +1808,9 @@ def test_custom_component_declare_event_handlers_in_fields():
class TestComponent(Component):
on_a: EventHandler[lambda e0: [e0]]
- on_b: EventHandler[lambda e0: [e0.target.value]]
- on_c: EventHandler[lambda e0: []]
- on_d: EventHandler[lambda: []]
+ on_b: EventHandler[input_event]
+ on_c: EventHandler[no_args_event_spec]
+ on_d: EventHandler[no_args_event_spec]
on_e: EventHandler
on_f: EventHandler[lambda a, b, c: [c, b, a]]
@@ -1969,8 +2059,8 @@ def test_component_add_hooks_var():
return [
"const hook3 = useRef(null)",
"const hook1 = 42",
- Var.create(
- "useEffect(() => () => {}, [])",
+ Var(
+ _js_expr="useEffect(() => () => {}, [])",
_var_data=VarData(
hooks={
"const hook2 = 43": None,
@@ -1979,11 +2069,9 @@ def test_component_add_hooks_var():
imports={"react": [ImportVar(tag="useEffect")]},
),
),
- Var.create(
- "const hook3 = useRef(null)",
- _var_data=VarData(
- imports={"react": [ImportVar(tag="useRef")]},
- ),
+ Var(
+ _js_expr="const hook3 = useRef(null)",
+ _var_data=VarData(imports={"react": [ImportVar(tag="useRef")]}),
),
]
@@ -2007,11 +2095,11 @@ def test_add_style_embedded_vars(test_state: BaseState):
Args:
test_state: A test state.
"""
- v0 = Var.create_safe("parent")._replace(
+ v0 = LiteralVar.create("parent")._replace(
merge_var_data=VarData(hooks={"useParent": None}), # type: ignore
)
v1 = rx.color("plum", 10)
- v2 = Var.create_safe("text")._replace(
+ v2 = LiteralVar.create("text")._replace(
merge_var_data=VarData(hooks={"useText": None}), # type: ignore
)
@@ -2044,7 +2132,7 @@ def test_add_style_embedded_vars(test_state: BaseState):
assert "useParent" in page._get_all_hooks_internal()
assert (
str(page).count(
- f'css={{{{"fakeParent": "parent", "color": "var(--plum-10)", "fake": "text", "margin": `${{{test_state.get_name()}.num}}%`}}}}'
+ f'css={{({{ ["fakeParent"] : "parent", ["color"] : "var(--plum-10)", ["fake"] : "text", ["margin"] : ({test_state.get_name()}.num+"%") }})}}'
)
== 1
)
@@ -2065,15 +2153,16 @@ def test_add_style_foreach():
assert len(page.children[0].children) == 1
# Expect the style to be added to the child of the foreach
- assert 'css={{"color": "red"}}' in str(page.children[0].children[0])
+ assert 'css={({ ["color"] : "red" })}' in str(page.children[0].children[0])
# Expect only one instance of this CSS dict in the rendered page
- assert str(page).count('css={{"color": "red"}}') == 1
+ assert str(page).count('css={({ ["color"] : "red" })}') == 1
class TriggerState(rx.State):
"""Test state with event handlers."""
+ @rx.event
def do_something(self):
"""Sample event handler."""
pass
@@ -2092,7 +2181,7 @@ class TriggerState(rx.State):
rx.text("random text", on_click=TriggerState.do_something),
rx.text(
"random text",
- on_click=BaseVar(_var_name="toggleColorMode", _var_type=EventChain),
+ on_click=Var(_js_expr="toggleColorMode").to(EventChain),
),
),
True,
@@ -2102,7 +2191,7 @@ class TriggerState(rx.State):
rx.text("random text", on_click=rx.console_log("log")),
rx.text(
"random text",
- on_click=BaseVar(_var_name="toggleColorMode", _var_type=EventChain),
+ on_click=Var(_js_expr="toggleColorMode").to(EventChain),
),
),
False,
@@ -2142,3 +2231,56 @@ class TriggerState(rx.State):
)
def test_has_state_event_triggers(component, output):
assert component._has_stateful_event_triggers() == output
+
+
+class SpecialComponent(Box):
+ """A special component with custom attributes."""
+
+ data_prop: Var[str]
+ aria_prop: Var[str]
+
+
+@pytest.mark.parametrize(
+ ("component_kwargs", "exp_custom_attrs", "exp_style"),
+ [
+ (
+ {"data_test": "test", "aria_test": "test"},
+ {"data-test": "test", "aria-test": "test"},
+ {},
+ ),
+ (
+ {"data-test": "test", "aria-test": "test"},
+ {"data-test": "test", "aria-test": "test"},
+ {},
+ ),
+ (
+ {"custom_attrs": {"data-existing": "test"}, "data_new": "test"},
+ {"data-existing": "test", "data-new": "test"},
+ {},
+ ),
+ (
+ {"data_test": "test", "data_prop": "prop"},
+ {"data-test": "test"},
+ {},
+ ),
+ (
+ {"aria_test": "test", "aria_prop": "prop"},
+ {"aria-test": "test"},
+ {},
+ ),
+ ],
+)
+def test_special_props(component_kwargs, exp_custom_attrs, exp_style):
+ """Test that data_ and aria_ special props are correctly added to the component.
+
+ Args:
+ component_kwargs: The component kwargs.
+ exp_custom_attrs: The expected custom attributes.
+ exp_style: The expected style.
+ """
+ component = SpecialComponent.create(**component_kwargs)
+ assert component.custom_attrs == exp_custom_attrs
+ assert component.style == exp_style
+ for prop in SpecialComponent.get_props():
+ if prop in component_kwargs:
+ assert getattr(component, prop)._var_value == component_kwargs[prop]
diff --git a/tests/components/test_component_future_annotations.py b/tests/units/components/test_component_future_annotations.py
similarity index 82%
rename from tests/components/test_component_future_annotations.py
rename to tests/units/components/test_component_future_annotations.py
index 37aeb813a..0867a2d37 100644
--- a/tests/components/test_component_future_annotations.py
+++ b/tests/units/components/test_component_future_annotations.py
@@ -3,7 +3,7 @@ from __future__ import annotations
from typing import Any
from reflex.components.component import Component
-from reflex.event import EventHandler
+from reflex.event import EventHandler, input_event, no_args_event_spec
# This is a repeat of its namesake in test_component.py.
@@ -25,9 +25,9 @@ def test_custom_component_declare_event_handlers_in_fields():
class TestComponent(Component):
on_a: EventHandler[lambda e0: [e0]]
- on_b: EventHandler[lambda e0: [e0.target.value]]
- on_c: EventHandler[lambda e0: []]
- on_d: EventHandler[lambda: []]
+ on_b: EventHandler[input_event]
+ on_c: EventHandler[no_args_event_spec]
+ on_d: EventHandler[no_args_event_spec]
custom_component = ReferenceComponent.create()
test_component = TestComponent.create()
diff --git a/tests/components/test_component_state.py b/tests/units/components/test_component_state.py
similarity index 66%
rename from tests/components/test_component_state.py
rename to tests/units/components/test_component_state.py
index 0dc0956e2..1b62e35c8 100644
--- a/tests/components/test_component_state.py
+++ b/tests/units/components/test_component_state.py
@@ -1,7 +1,10 @@
"""Ensure that Components returned by ComponentState.create have independent State classes."""
+import pytest
+
import reflex as rx
from reflex.components.base.bare import Bare
+from reflex.utils.exceptions import ReflexRuntimeError
def test_component_state():
@@ -35,8 +38,26 @@ def test_component_state():
assert cs1.State.increment != cs2.State.increment
assert len(cs1.children) == 1
- assert cs1.children[0].render() == Bare.create("{`a`}").render()
+ assert cs1.children[0].render() == Bare.create("a").render()
assert cs1.id == "a"
assert len(cs2.children) == 1
- assert cs2.children[0].render() == Bare.create("{`b`}").render()
+ assert cs2.children[0].render() == Bare.create("b").render()
assert cs2.id == "b"
+
+
+def test_init_component_state() -> None:
+ """Ensure that ComponentState subclasses cannot be instantiated directly."""
+
+ class CS(rx.ComponentState):
+ @classmethod
+ def get_component(cls, *children, **props):
+ return rx.el.div()
+
+ with pytest.raises(ReflexRuntimeError):
+ CS()
+
+ class SubCS(CS):
+ pass
+
+ with pytest.raises(ReflexRuntimeError):
+ SubCS()
diff --git a/tests/units/components/test_props.py b/tests/units/components/test_props.py
new file mode 100644
index 000000000..8ab07f135
--- /dev/null
+++ b/tests/units/components/test_props.py
@@ -0,0 +1,63 @@
+import pytest
+
+from reflex.components.props import NoExtrasAllowedProps
+from reflex.utils.exceptions import InvalidPropValueError
+
+try:
+ from pydantic.v1 import ValidationError
+except ModuleNotFoundError:
+ from pydantic import ValidationError
+
+
+class PropA(NoExtrasAllowedProps):
+ """Base prop class."""
+
+ foo: str
+ bar: str
+
+
+class PropB(NoExtrasAllowedProps):
+ """Prop class with nested props."""
+
+ foobar: str
+ foobaz: PropA
+
+
+@pytest.mark.parametrize(
+ "props_class, kwargs, should_raise",
+ [
+ (PropA, {"foo": "value", "bar": "another_value"}, False),
+ (PropA, {"fooz": "value", "bar": "another_value"}, True),
+ (
+ PropB,
+ {
+ "foobaz": {"foo": "value", "bar": "another_value"},
+ "foobar": "foo_bar_value",
+ },
+ False,
+ ),
+ (
+ PropB,
+ {
+ "fooba": {"foo": "value", "bar": "another_value"},
+ "foobar": "foo_bar_value",
+ },
+ True,
+ ),
+ (
+ PropB,
+ {
+ "foobaz": {"foobar": "value", "bar": "another_value"},
+ "foobar": "foo_bar_value",
+ },
+ True,
+ ),
+ ],
+)
+def test_no_extras_allowed_props(props_class, kwargs, should_raise):
+ if should_raise:
+ with pytest.raises((ValidationError, InvalidPropValueError)):
+ props_class(**kwargs)
+ else:
+ props_instance = props_class(**kwargs)
+ assert isinstance(props_instance, props_class)
diff --git a/tests/components/test_tag.py b/tests/units/components/test_tag.py
similarity index 87%
rename from tests/components/test_tag.py
rename to tests/units/components/test_tag.py
index 2fb2f4563..a69e40b8b 100644
--- a/tests/components/test_tag.py
+++ b/tests/units/components/test_tag.py
@@ -3,7 +3,7 @@ from typing import Dict, List
import pytest
from reflex.components.tags import CondTag, Tag, tagless
-from reflex.vars import BaseVar, Var
+from reflex.vars.base import LiteralVar, Var
@pytest.mark.parametrize(
@@ -12,8 +12,8 @@ from reflex.vars import BaseVar, Var
({}, []),
({"key-hypen": 1}, ["key-hypen={1}"]),
({"key": 1}, ["key={1}"]),
- ({"key": "value"}, ["key={`value`}"]),
- ({"key": True, "key2": "value2"}, ["key={true}", "key2={`value2`}"]),
+ ({"key": "value"}, ['key={"value"}']),
+ ({"key": True, "key2": "value2"}, ["key={true}", 'key2={"value2"}']),
],
)
def test_format_props(props: Dict[str, Var], test_props: List):
@@ -53,8 +53,8 @@ def test_is_valid_prop(prop: Var, valid: bool):
def test_add_props():
"""Test that the props are added."""
tag = Tag().add_props(key="value", key2=42, invalid=None, invalid2={})
- assert tag.props["key"].equals(Var.create("value"))
- assert tag.props["key2"].equals(Var.create(42))
+ assert tag.props["key"].equals(LiteralVar.create("value"))
+ assert tag.props["key2"].equals(LiteralVar.create(42))
assert "invalid" not in tag.props
assert "invalid2" not in tag.props
@@ -102,7 +102,7 @@ def test_format_tag(tag: Tag, expected: Dict):
assert tag_dict["name"] == expected["name"]
assert tag_dict["contents"] == expected["contents"]
for prop, prop_value in tag_dict["props"].items():
- assert prop_value.equals(Var.create_safe(expected["props"][prop]))
+ assert prop_value.equals(LiteralVar.create(expected["props"][prop]))
def test_format_cond_tag():
@@ -110,7 +110,7 @@ def test_format_cond_tag():
tag = CondTag(
true_value=dict(Tag(name="h1", contents="True content")),
false_value=dict(Tag(name="h2", contents="False content")),
- cond=BaseVar(_var_name="logged_in", _var_type=bool),
+ cond=Var(_js_expr="logged_in", _var_type=bool),
)
tag_dict = dict(tag)
cond, true_value, false_value = (
@@ -118,8 +118,8 @@ def test_format_cond_tag():
tag_dict["true_value"],
tag_dict["false_value"],
)
- assert cond._var_name == "logged_in"
- assert cond._var_type == bool
+ assert cond._js_expr == "logged_in"
+ assert cond._var_type is bool
assert true_value["name"] == "h1"
assert true_value["contents"] == "True content"
diff --git a/tests/components/typography/__init__.py b/tests/units/components/typography/__init__.py
similarity index 100%
rename from tests/components/typography/__init__.py
rename to tests/units/components/typography/__init__.py
diff --git a/tests/components/typography/test_markdown.py b/tests/units/components/typography/test_markdown.py
similarity index 91%
rename from tests/components/typography/test_markdown.py
rename to tests/units/components/typography/test_markdown.py
index 8033ec606..5e9abbb1f 100644
--- a/tests/components/typography/test_markdown.py
+++ b/tests/units/components/typography/test_markdown.py
@@ -36,9 +36,7 @@ def test_get_component(tag, expected):
def test_set_component_map():
"""Test setting the component map."""
component_map = {
- "h1": lambda value: rx.box(
- rx.chakra.heading(value, as_="h1", size="2xl"), padding="1em"
- ),
+ "h1": lambda value: rx.box(rx.heading(value, as_="h1"), padding="1em"),
"p": lambda value: rx.box(rx.text(value), padding="1em"),
}
md = Markdown.create("# Hello", component_map=component_map)
diff --git a/tests/conftest.py b/tests/units/conftest.py
similarity index 96%
rename from tests/conftest.py
rename to tests/units/conftest.py
index 589d35cd7..fb6229aca 100644
--- a/tests/conftest.py
+++ b/tests/units/conftest.py
@@ -1,5 +1,6 @@
"""Test fixtures."""
+import asyncio
import contextlib
import os
import platform
@@ -24,6 +25,11 @@ from .states import (
)
+def pytest_configure(config):
+ if config.getoption("asyncio_mode") == "auto":
+ asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
+
+
@pytest.fixture
def app() -> App:
"""A base app.
@@ -200,7 +206,7 @@ class chdir(contextlib.AbstractContextManager):
def __enter__(self):
"""Save current directory and perform chdir."""
- self._old_cwd.append(Path(".").resolve())
+ self._old_cwd.append(Path.cwd())
os.chdir(self.path)
def __exit__(self, *excinfo):
diff --git a/tests/middleware/__init__.py b/tests/units/middleware/__init__.py
similarity index 100%
rename from tests/middleware/__init__.py
rename to tests/units/middleware/__init__.py
diff --git a/tests/middleware/conftest.py b/tests/units/middleware/conftest.py
similarity index 100%
rename from tests/middleware/conftest.py
rename to tests/units/middleware/conftest.py
diff --git a/tests/middleware/test_hydrate_middleware.py b/tests/units/middleware/test_hydrate_middleware.py
similarity index 100%
rename from tests/middleware/test_hydrate_middleware.py
rename to tests/units/middleware/test_hydrate_middleware.py
diff --git a/tests/states/__init__.py b/tests/units/states/__init__.py
similarity index 100%
rename from tests/states/__init__.py
rename to tests/units/states/__init__.py
diff --git a/tests/states/mutation.py b/tests/units/states/mutation.py
similarity index 100%
rename from tests/states/mutation.py
rename to tests/units/states/mutation.py
diff --git a/tests/states/upload.py b/tests/units/states/upload.py
similarity index 87%
rename from tests/states/upload.py
rename to tests/units/states/upload.py
index f81e9f235..66d9479b4 100644
--- a/tests/states/upload.py
+++ b/tests/units/states/upload.py
@@ -61,17 +61,16 @@ class FileUploadState(State):
"""
for file in files:
upload_data = await file.read()
- outfile = f"{self._tmp_path}/{file.filename}"
+ assert file.filename is not None
+ outfile = self._tmp_path / file.filename
# Save the file.
- with open(outfile, "wb") as file_object:
- file_object.write(upload_data)
+ outfile.write_bytes(upload_data)
# Update the img var.
- assert file.filename is not None
self.img_list.append(file.filename)
- @rx.background
+ @rx.event(background=True)
async def bg_upload(self, files: List[rx.UploadFile]):
"""Background task cannot be upload handler.
@@ -109,17 +108,16 @@ class ChildFileUploadState(FileStateBase1):
"""
for file in files:
upload_data = await file.read()
- outfile = f"{self._tmp_path}/{file.filename}"
+ assert file.filename is not None
+ outfile = self._tmp_path / file.filename
# Save the file.
- with open(outfile, "wb") as file_object:
- file_object.write(upload_data)
+ outfile.write_bytes(upload_data)
# Update the img var.
- assert file.filename is not None
self.img_list.append(file.filename)
- @rx.background
+ @rx.event(background=True)
async def bg_upload(self, files: List[rx.UploadFile]):
"""Background task cannot be upload handler.
@@ -157,17 +155,16 @@ class GrandChildFileUploadState(FileStateBase2):
"""
for file in files:
upload_data = await file.read()
- outfile = f"{self._tmp_path}/{file.filename}"
+ assert file.filename is not None
+ outfile = self._tmp_path / file.filename
# Save the file.
- with open(outfile, "wb") as file_object:
- file_object.write(upload_data)
+ outfile.write_bytes(upload_data)
# Update the img var.
- assert file.filename is not None
self.img_list.append(file.filename)
- @rx.background
+ @rx.event(background=True)
async def bg_upload(self, files: List[rx.UploadFile]):
"""Background task cannot be upload handler.
diff --git a/tests/test_app.py b/tests/units/test_app.py
similarity index 92%
rename from tests/test_app.py
rename to tests/units/test_app.py
index 489ace511..48a4bdda1 100644
--- a/tests/test_app.py
+++ b/tests/units/test_app.py
@@ -41,6 +41,7 @@ from reflex.state import (
OnLoadInternalState,
RouterData,
State,
+ StateManagerDisk,
StateManagerMemory,
StateManagerRedis,
StateUpdate,
@@ -48,7 +49,7 @@ from reflex.state import (
)
from reflex.style import Style
from reflex.utils import exceptions, format
-from reflex.vars import computed_var
+from reflex.vars.base import computed_var
from .conftest import chdir
from .states import (
@@ -67,7 +68,7 @@ class EmptyState(BaseState):
@pytest.fixture
-def index_page():
+def index_page() -> ComponentCallable:
"""An index page.
Returns:
@@ -81,7 +82,7 @@ def index_page():
@pytest.fixture
-def about_page():
+def about_page() -> ComponentCallable:
"""An about page.
Returns:
@@ -236,9 +237,12 @@ def test_add_page_default_route(app: App, index_page, about_page):
about_page: The about page.
"""
assert app.pages == {}
+ assert app.unevaluated_pages == {}
app.add_page(index_page)
+ app._compile_page("index")
assert app.pages.keys() == {"index"}
app.add_page(about_page)
+ app._compile_page("about")
assert app.pages.keys() == {"index", "about"}
@@ -251,8 +255,9 @@ def test_add_page_set_route(app: App, index_page, windows_platform: bool):
windows_platform: Whether the system is windows.
"""
route = "test" if windows_platform else "/test"
- assert app.pages == {}
+ assert app.unevaluated_pages == {}
app.add_page(index_page, route=route)
+ app._compile_page("test")
assert app.pages.keys() == {"test"}
@@ -266,10 +271,9 @@ def test_add_page_set_route_dynamic(index_page, windows_platform: bool):
app = App(state=EmptyState)
assert app.state is not None
route = "/test/[dynamic]"
- if windows_platform:
- route.lstrip("/").replace("/", "\\")
- assert app.pages == {}
+ assert app.unevaluated_pages == {}
app.add_page(index_page, route=route)
+ app._compile_page("test/[dynamic]")
assert app.pages.keys() == {"test/[dynamic]"}
assert "dynamic" in app.state.computed_vars
assert app.state.computed_vars["dynamic"]._deps(objclass=EmptyState) == {
@@ -287,9 +291,9 @@ def test_add_page_set_route_nested(app: App, index_page, windows_platform: bool)
windows_platform: Whether the system is windows.
"""
route = "test\\nested" if windows_platform else "/test/nested"
- assert app.pages == {}
+ assert app.unevaluated_pages == {}
app.add_page(index_page, route=route)
- assert app.pages.keys() == {route.strip(os.path.sep)}
+ assert app.unevaluated_pages.keys() == {route.strip(os.path.sep)}
def test_add_page_invalid_api_route(app: App, index_page):
@@ -766,7 +770,8 @@ async def test_upload_file(tmp_path, state, delta, token: str, mocker):
)
state._tmp_path = tmp_path
# The App state must be the "root" of the state tree
- app = App(state=State)
+ app = App()
+ app._enable_state()
app.event_namespace.emit = AsyncMock() # type: ignore
current_state = await app.state_manager.get_state(_substate_key(token, state))
data = b"This is binary data"
@@ -782,11 +787,11 @@ async def test_upload_file(tmp_path, state, delta, token: str, mocker):
}
file1 = UploadFile(
- filename=f"image1.jpg",
+ filename="image1.jpg",
file=bio,
)
file2 = UploadFile(
- filename=f"image2.jpg",
+ filename="image2.jpg",
file=bio,
)
upload_fn = upload(app)
@@ -869,7 +874,7 @@ async def test_upload_file_background(state, tmp_path, token):
await fn(request_mock, [file_mock])
assert (
err.value.args[0]
- == f"@rx.background is not supported for upload handler `{state.get_full_name()}.bg_upload`."
+ == f"@rx.event(background=True) is not supported for upload handler `{state.get_full_name()}.bg_upload`."
)
if isinstance(app.state_manager, StateManagerRedis):
@@ -894,32 +899,78 @@ class DynamicState(BaseState):
loaded: int = 0
counter: int = 0
- # side_effect_counter: int = 0
-
def on_load(self):
"""Event handler for page on_load, should trigger for all navigation events."""
self.loaded = self.loaded + 1
+ @rx.event
def on_counter(self):
"""Increment the counter var."""
self.counter = self.counter + 1
- @computed_var
+ @computed_var(cache=True)
def comp_dynamic(self) -> str:
"""A computed var that depends on the dynamic var.
Returns:
same as self.dynamic
"""
- # self.side_effect_counter = self.side_effect_counter + 1
return self.dynamic
on_load_internal = OnLoadInternalState.on_load_internal.fn
+def test_dynamic_arg_shadow(
+ index_page: ComponentCallable,
+ windows_platform: bool,
+ token: str,
+ app_module_mock: unittest.mock.Mock,
+ mocker,
+):
+ """Create app with dynamic route var and try to add a page with a dynamic arg that shadows a state var.
+
+ Args:
+ index_page: The index page.
+ windows_platform: Whether the system is windows.
+ token: a Token.
+ app_module_mock: Mocked app module.
+ mocker: pytest mocker object.
+ """
+ arg_name = "counter"
+ route = f"/test/[{arg_name}]"
+ app = app_module_mock.app = App(state=DynamicState)
+ assert app.state is not None
+ with pytest.raises(NameError):
+ app.add_page(index_page, route=route, on_load=DynamicState.on_load) # type: ignore
+
+
+def test_multiple_dynamic_args(
+ index_page: ComponentCallable,
+ windows_platform: bool,
+ token: str,
+ app_module_mock: unittest.mock.Mock,
+ mocker,
+):
+ """Create app with multiple dynamic route vars with the same name.
+
+ Args:
+ index_page: The index page.
+ windows_platform: Whether the system is windows.
+ token: a Token.
+ app_module_mock: Mocked app module.
+ mocker: pytest mocker object.
+ """
+ arg_name = "my_arg"
+ route = f"/test/[{arg_name}]"
+ route2 = f"/test2/[{arg_name}]"
+ app = app_module_mock.app = App(state=EmptyState)
+ app.add_page(index_page, route=route)
+ app.add_page(index_page, route=route2)
+
+
@pytest.mark.asyncio
async def test_dynamic_route_var_route_change_completed_on_load(
- index_page,
+ index_page: ComponentCallable,
windows_platform: bool,
token: str,
app_module_mock: unittest.mock.Mock,
@@ -939,8 +990,6 @@ async def test_dynamic_route_var_route_change_completed_on_load(
"""
arg_name = "dynamic"
route = f"/test/[{arg_name}]"
- if windows_platform:
- route.lstrip("/").replace("/", "\\")
app = app_module_mock.app = App(state=DynamicState)
assert app.state is not None
assert arg_name not in app.state.vars
@@ -955,8 +1004,9 @@ async def test_dynamic_route_var_route_change_completed_on_load(
substate_token = _substate_key(token, DynamicState)
sid = "mock_sid"
client_ip = "127.0.0.1"
- state = await app.state_manager.get_state(substate_token)
- assert state.dynamic == ""
+ async with app.state_manager.modify_state(substate_token) as state:
+ state.router_data = {"simulate": "hydrated"}
+ assert state.dynamic == ""
exp_vals = ["foo", "foobar", "baz"]
def _event(name, val, **kwargs):
@@ -1006,7 +1056,6 @@ async def test_dynamic_route_var_route_change_completed_on_load(
arg_name: exp_val,
f"comp_{arg_name}": exp_val,
constants.CompileVars.IS_HYDRATED: False,
- # "side_effect_counter": exp_index,
"router": exp_router,
}
},
@@ -1047,9 +1096,6 @@ async def test_dynamic_route_var_route_change_completed_on_load(
assert on_load_update == StateUpdate(
delta={
state.get_name(): {
- # These computed vars _shouldn't_ be here, because they didn't change
- arg_name: exp_val,
- f"comp_{arg_name}": exp_val,
"loaded": exp_index + 1,
},
},
@@ -1071,9 +1117,6 @@ async def test_dynamic_route_var_route_change_completed_on_load(
assert on_set_is_hydrated_update == StateUpdate(
delta={
state.get_name(): {
- # These computed vars _shouldn't_ be here, because they didn't change
- arg_name: exp_val,
- f"comp_{arg_name}": exp_val,
"is_hydrated": True,
},
},
@@ -1095,9 +1138,6 @@ async def test_dynamic_route_var_route_change_completed_on_load(
assert update == StateUpdate(
delta={
state.get_name(): {
- # These computed vars _shouldn't_ be here, because they didn't change
- f"comp_{arg_name}": exp_val,
- arg_name: exp_val,
"counter": exp_index + 1,
}
},
@@ -1111,8 +1151,6 @@ async def test_dynamic_route_var_route_change_completed_on_load(
state = await app.state_manager.get_state(substate_token)
assert state.loaded == len(exp_vals)
assert state.counter == len(exp_vals)
- # print(f"Expected {exp_vals} rendering side effects, got {state.side_effect_counter}")
- # assert state.side_effect_counter == len(exp_vals)
if isinstance(app.state_manager, StateManagerRedis):
await app.state_manager.close()
@@ -1137,6 +1175,7 @@ async def test_process_events(mocker, token: str):
"ip": "127.0.0.1",
}
app = App(state=GenState)
+
mocker.patch.object(app, "_postprocess", AsyncMock())
event = Event(
token=token,
@@ -1144,6 +1183,8 @@ async def test_process_events(mocker, token: str):
payload={"c": 5},
router_data=router_data,
)
+ async with app.state_manager.modify_state(event.substate_token) as state:
+ state.router_data = {"simulate": "hydrated"}
async for _update in process(app, event, "mock_sid", {}, "127.0.0.1"):
pass
@@ -1168,7 +1209,7 @@ async def test_process_events(mocker, token: str):
],
)
def test_overlay_component(
- state: State | None,
+ state: Type[State] | None,
overlay_component: Component | ComponentCallable | None,
exp_page_child: Type[Component] | None,
):
@@ -1200,6 +1241,7 @@ def test_overlay_component(
app.add_page(rx.box("Index"), route="/test")
# overlay components are wrapped during compile only
+ app._compile_page("test")
app._setup_overlay_component()
page = app.pages["test"]
@@ -1251,7 +1293,7 @@ def test_app_wrap_compile_theme(compilable_app: tuple[App, Path]):
"function AppWrap({children}) {"
"return ("
""
- ""
+ ""
""
"{children}"
" "
@@ -1274,13 +1316,13 @@ def test_app_wrap_priority(compilable_app: tuple[App, Path]):
tag = "Fragment1"
def _get_app_wrap_components(self) -> dict[tuple[int, str], Component]:
- return {(99, "Box"): rx.chakra.box()}
+ return {(99, "Box"): rx.box()}
class Fragment2(Component):
tag = "Fragment2"
def _get_app_wrap_components(self) -> dict[tuple[int, str], Component]:
- return {(50, "Text"): rx.chakra.text()}
+ return {(50, "Text"): rx.text()}
class Fragment3(Component):
tag = "Fragment3"
@@ -1300,19 +1342,17 @@ def test_app_wrap_priority(compilable_app: tuple[App, Path]):
assert (
"function AppWrap({children}) {"
"return ("
- ""
- ""
- ""
- ""
+ ""
+ ''
+ ""
""
""
"{children}"
" "
" "
- " "
- " "
- " "
- " "
+ " "
+ ""
+ ""
")"
"}"
) in "".join(app_js_lines)
@@ -1329,6 +1369,7 @@ def test_app_state_determination():
# Add a page with `on_load` enables state.
a1.add_page(rx.box("About"), route="/about", on_load=rx.console_log(""))
+ a1._compile_page("about")
assert a1.state is not None
a2 = App()
@@ -1336,6 +1377,7 @@ def test_app_state_determination():
# Referencing a state Var enables state.
a2.add_page(rx.box(rx.text(GenState.value)), route="/")
+ a2._compile_page("index")
assert a2.state is not None
a3 = App()
@@ -1343,6 +1385,7 @@ def test_app_state_determination():
# Referencing router enables state.
a3.add_page(rx.box(rx.text(State.router.page.full_path)), route="/")
+ a3._compile_page("index")
assert a3.state is not None
a4 = App()
@@ -1354,16 +1397,10 @@ def test_app_state_determination():
a4.add_page(
rx.box(rx.button("Click", on_click=DynamicState.on_counter)), route="/page2"
)
+ a4._compile_page("page2")
assert a4.state is not None
-# for coverage
-def test_raise_on_connect_error():
- """Test that the connect_error function is called."""
- with pytest.raises(ValueError):
- App(connect_error_component="Foo")
-
-
def test_raise_on_state():
"""Test that the state is set."""
# state kwargs is deprecated, we just make sure the app is created anyway.
@@ -1394,7 +1431,9 @@ def test_app_state_manager():
app.state_manager
app._enable_state()
assert app.state_manager is not None
- assert isinstance(app.state_manager, (StateManagerMemory, StateManagerRedis))
+ assert isinstance(
+ app.state_manager, (StateManagerMemory, StateManagerDisk, StateManagerRedis)
+ )
def test_generate_component():
@@ -1431,18 +1470,24 @@ def test_add_page_component_returning_tuple():
app.add_page(index) # type: ignore
app.add_page(page2) # type: ignore
- assert isinstance((fragment_wrapper := app.pages["index"].children[0]), Fragment)
- assert isinstance((first_text := fragment_wrapper.children[0]), Text)
- assert str(first_text.children[0].contents) == "{`first`}" # type: ignore
- assert isinstance((second_text := fragment_wrapper.children[1]), Text)
- assert str(second_text.children[0].contents) == "{`second`}" # type: ignore
+ app._compile_page("index")
+ app._compile_page("page2")
+
+ fragment_wrapper = app.pages["index"].children[0]
+ assert isinstance(fragment_wrapper, Fragment)
+ first_text = fragment_wrapper.children[0]
+ assert isinstance(first_text, Text)
+ assert str(first_text.children[0].contents) == '"first"' # type: ignore
+ second_text = fragment_wrapper.children[1]
+ assert isinstance(second_text, Text)
+ assert str(second_text.children[0].contents) == '"second"' # type: ignore
# Test page with trailing comma.
- assert isinstance(
- (page2_fragment_wrapper := app.pages["page2"].children[0]), Fragment
- )
- assert isinstance((third_text := page2_fragment_wrapper.children[0]), Text)
- assert str(third_text.children[0].contents) == "{`third`}" # type: ignore
+ page2_fragment_wrapper = app.pages["page2"].children[0]
+ assert isinstance(page2_fragment_wrapper, Fragment)
+ third_text = page2_fragment_wrapper.children[0]
+ assert isinstance(third_text, Text)
+ assert str(third_text.children[0].contents) == '"third"' # type: ignore
@pytest.mark.parametrize("export", (True, False))
diff --git a/tests/test_attribute_access_type.py b/tests/units/test_attribute_access_type.py
similarity index 58%
rename from tests/test_attribute_access_type.py
rename to tests/units/test_attribute_access_type.py
index 0813a5e62..d08c17c8c 100644
--- a/tests/test_attribute_access_type.py
+++ b/tests/units/test_attribute_access_type.py
@@ -3,11 +3,19 @@ from __future__ import annotations
from typing import Dict, List, Optional, Type, Union
import attrs
+import pydantic.v1
import pytest
import sqlalchemy
+import sqlmodel
from sqlalchemy import JSON, TypeDecorator
from sqlalchemy.ext.hybrid import hybrid_property
-from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
+from sqlalchemy.orm import (
+ DeclarativeBase,
+ Mapped,
+ MappedAsDataclass,
+ mapped_column,
+ relationship,
+)
import reflex as rx
from reflex.utils.types import GenericType, get_attribute_access_type
@@ -53,6 +61,10 @@ class SQLALabel(SQLABase):
id: Mapped[int] = mapped_column(primary_key=True)
test_id: Mapped[int] = mapped_column(sqlalchemy.ForeignKey("test.id"))
test: Mapped[SQLAClass] = relationship(back_populates="labels")
+ test_dataclass_id: Mapped[int] = mapped_column(
+ sqlalchemy.ForeignKey("test_dataclass.id")
+ )
+ test_dataclass: Mapped[SQLAClassDataclass] = relationship(back_populates="labels")
class SQLAClass(SQLABase):
@@ -94,10 +106,74 @@ class SQLAClass(SQLABase):
"""
return self.name
+ @hybrid_property
+ def first_label(self) -> Optional[SQLALabel]:
+ """First label property.
+
+ Returns:
+ First label
+ """
+ return self.labels[0] if self.labels else None
+
+
+class SQLAClassDataclass(MappedAsDataclass, SQLABase):
+ """Test sqlalchemy model."""
+
+ id: Mapped[int] = mapped_column(primary_key=True)
+ no_default: Mapped[int] = mapped_column(nullable=True)
+ count: Mapped[int] = mapped_column()
+ name: Mapped[str] = mapped_column()
+ int_list: Mapped[List[int]] = mapped_column(
+ sqlalchemy.types.ARRAY(item_type=sqlalchemy.INTEGER)
+ )
+ str_list: Mapped[List[str]] = mapped_column(
+ sqlalchemy.types.ARRAY(item_type=sqlalchemy.String)
+ )
+ optional_int: Mapped[Optional[int]] = mapped_column(nullable=True)
+ sqla_tag_id: Mapped[int] = mapped_column(sqlalchemy.ForeignKey(SQLATag.id))
+ sqla_tag: Mapped[Optional[SQLATag]] = relationship()
+ labels: Mapped[List[SQLALabel]] = relationship(back_populates="test_dataclass")
+ # do not use lower case dict here!
+ # https://github.com/sqlalchemy/sqlalchemy/issues/9902
+ dict_str_str: Mapped[Dict[str, str]] = mapped_column()
+ default_factory: Mapped[List[int]] = mapped_column(
+ sqlalchemy.types.ARRAY(item_type=sqlalchemy.INTEGER),
+ default_factory=list,
+ )
+ __tablename__: str = "test_dataclass"
+
+ @property
+ def str_property(self) -> str:
+ """String property.
+
+ Returns:
+ Name attribute
+ """
+ return self.name
+
+ @hybrid_property
+ def str_or_int_property(self) -> Union[str, int]:
+ """String or int property.
+
+ Returns:
+ Name attribute
+ """
+ return self.name
+
+ @hybrid_property
+ def first_label(self) -> Optional[SQLALabel]:
+ """First label property.
+
+ Returns:
+ First label
+ """
+ return self.labels[0] if self.labels else None
+
class ModelClass(rx.Model):
"""Test reflex model."""
+ no_default: Optional[int] = sqlmodel.Field(nullable=True)
count: int = 0
name: str = "test"
int_list: List[int] = []
@@ -106,6 +182,7 @@ class ModelClass(rx.Model):
sqla_tag: Optional[SQLATag] = None
labels: List[SQLALabel] = []
dict_str_str: Dict[str, str] = {}
+ default_factory: List[int] = sqlmodel.Field(default_factory=list)
@property
def str_property(self) -> str:
@@ -125,10 +202,20 @@ class ModelClass(rx.Model):
"""
return self.name
+ @property
+ def first_label(self) -> Optional[SQLALabel]:
+ """First label property.
+
+ Returns:
+ First label
+ """
+ return self.labels[0] if self.labels else None
+
class BaseClass(rx.Base):
"""Test rx.Base class."""
+ no_default: Optional[int] = pydantic.v1.Field(required=False)
count: int = 0
name: str = "test"
int_list: List[int] = []
@@ -137,6 +224,7 @@ class BaseClass(rx.Base):
sqla_tag: Optional[SQLATag] = None
labels: List[SQLALabel] = []
dict_str_str: Dict[str, str] = {}
+ default_factory: List[int] = pydantic.v1.Field(default_factory=list)
@property
def str_property(self) -> str:
@@ -156,6 +244,15 @@ class BaseClass(rx.Base):
"""
return self.name
+ @property
+ def first_label(self) -> Optional[SQLALabel]:
+ """First label property.
+
+ Returns:
+ First label
+ """
+ return self.labels[0] if self.labels else None
+
class BareClass:
"""Bare python class."""
@@ -187,6 +284,15 @@ class BareClass:
"""
return self.name
+ @property
+ def first_label(self) -> Optional[SQLALabel]:
+ """First label property.
+
+ Returns:
+ First label
+ """
+ return self.labels[0] if self.labels else None
+
@attrs.define
class AttrClass:
@@ -200,6 +306,7 @@ class AttrClass:
sqla_tag: Optional[SQLATag] = None
labels: List[SQLALabel] = []
dict_str_str: Dict[str, str] = {}
+ default_factory: List[int] = attrs.field(factory=list)
@property
def str_property(self) -> str:
@@ -219,28 +326,27 @@ class AttrClass:
"""
return self.name
+ @property
+ def first_label(self) -> Optional[SQLALabel]:
+ """First label property.
-@pytest.fixture(
- params=[
+ Returns:
+ First label
+ """
+ return self.labels[0] if self.labels else None
+
+
+@pytest.mark.parametrize(
+ "cls",
+ [
SQLAClass,
+ SQLAClassDataclass,
BaseClass,
BareClass,
ModelClass,
AttrClass,
- ]
+ ],
)
-def cls(request: pytest.FixtureRequest) -> type:
- """Fixture for the class to test.
-
- Args:
- request: pytest request object.
-
- Returns:
- Class to test.
- """
- return request.param
-
-
@pytest.mark.parametrize(
"attr, expected",
[
@@ -254,6 +360,7 @@ def cls(request: pytest.FixtureRequest) -> type:
pytest.param("dict_str_str", Dict[str, str], id="Dict[str, str]"),
pytest.param("str_property", str, id="str_property"),
pytest.param("str_or_int_property", Union[str, int], id="str_or_int_property"),
+ pytest.param("first_label", Optional[SQLALabel], id="first_label"),
],
)
def test_get_attribute_access_type(cls: type, attr: str, expected: GenericType) -> None:
@@ -265,3 +372,38 @@ def test_get_attribute_access_type(cls: type, attr: str, expected: GenericType)
expected: Expected type.
"""
assert get_attribute_access_type(cls, attr) == expected
+
+
+@pytest.mark.parametrize(
+ "cls",
+ [
+ SQLAClassDataclass,
+ BaseClass,
+ ModelClass,
+ AttrClass,
+ ],
+)
+def test_get_attribute_access_type_default_factory(cls: type) -> None:
+ """Test get_attribute_access_type returns the correct type for default factory fields.
+
+ Args:
+ cls: Class to test.
+ """
+ assert get_attribute_access_type(cls, "default_factory") == List[int]
+
+
+@pytest.mark.parametrize(
+ "cls",
+ [
+ SQLAClassDataclass,
+ BaseClass,
+ ModelClass,
+ ],
+)
+def test_get_attribute_access_type_no_default(cls: type) -> None:
+ """Test get_attribute_access_type returns the correct type for fields with no default which are not required.
+
+ Args:
+ cls: Class to test.
+ """
+ assert get_attribute_access_type(cls, "no_default") == Optional[int]
diff --git a/tests/test_base.py b/tests/units/test_base.py
similarity index 100%
rename from tests/test_base.py
rename to tests/units/test_base.py
diff --git a/tests/test_config.py b/tests/units/test_config.py
similarity index 65%
rename from tests/test_config.py
rename to tests/units/test_config.py
index 31dd77649..e5d4622bd 100644
--- a/tests/test_config.py
+++ b/tests/units/test_config.py
@@ -1,11 +1,21 @@
import multiprocessing
import os
+from pathlib import Path
+from typing import Any, Dict
import pytest
import reflex as rx
import reflex.config
-from reflex.constants import Endpoint
+from reflex.config import (
+ EnvVar,
+ env_var,
+ environment,
+ interpret_boolean_env,
+ interpret_enum_env,
+ interpret_int_env,
+)
+from reflex.constants import Endpoint, Env
def test_requires_app_name():
@@ -41,7 +51,12 @@ def test_set_app_name(base_config_values):
("TELEMETRY_ENABLED", True),
],
)
-def test_update_from_env(base_config_values, monkeypatch, env_var, value):
+def test_update_from_env(
+ base_config_values: Dict[str, Any],
+ monkeypatch: pytest.MonkeyPatch,
+ env_var: str,
+ value: Any,
+):
"""Test that environment variables override config values.
Args:
@@ -56,6 +71,29 @@ def test_update_from_env(base_config_values, monkeypatch, env_var, value):
assert getattr(config, env_var.lower()) == value
+def test_update_from_env_path(
+ base_config_values: Dict[str, Any],
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path: Path,
+):
+ """Test that environment variables override config values.
+
+ Args:
+ base_config_values: Config values.
+ monkeypatch: The pytest monkeypatch object.
+ tmp_path: The pytest tmp_path fixture object.
+ """
+ monkeypatch.setenv("BUN_PATH", "/test")
+ assert os.environ.get("BUN_PATH") == "/test"
+ with pytest.raises(ValueError):
+ rx.Config(**base_config_values)
+
+ monkeypatch.setenv("BUN_PATH", str(tmp_path))
+ assert os.environ.get("BUN_PATH") == str(tmp_path)
+ config = rx.Config(**base_config_values)
+ assert config.bun_path == tmp_path
+
+
@pytest.mark.parametrize(
"kwargs, expected",
[
@@ -177,11 +215,11 @@ def test_replace_defaults(
assert getattr(c, key) == value
-def reflex_dir_constant():
- return rx.constants.Reflex.DIR
+def reflex_dir_constant() -> Path:
+ return environment.REFLEX_DIR.get()
-def test_reflex_dir_env_var(monkeypatch, tmp_path):
+def test_reflex_dir_env_var(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
"""Test that the REFLEX_DIR environment variable is used to set the Reflex.DIR constant.
Args:
@@ -191,5 +229,54 @@ def test_reflex_dir_env_var(monkeypatch, tmp_path):
monkeypatch.setenv("REFLEX_DIR", str(tmp_path))
mp_ctx = multiprocessing.get_context(method="spawn")
+ assert reflex_dir_constant() == tmp_path
with mp_ctx.Pool(processes=1) as pool:
- assert pool.apply(reflex_dir_constant) == str(tmp_path)
+ assert pool.apply(reflex_dir_constant) == tmp_path
+
+
+def test_interpret_enum_env() -> None:
+ assert interpret_enum_env(Env.PROD.value, Env, "REFLEX_ENV") == Env.PROD
+
+
+def test_interpret_int_env() -> None:
+ assert interpret_int_env("3001", "FRONTEND_PORT") == 3001
+
+
+@pytest.mark.parametrize("value, expected", [("true", True), ("false", False)])
+def test_interpret_bool_env(value: str, expected: bool) -> None:
+ assert interpret_boolean_env(value, "TELEMETRY_ENABLED") == expected
+
+
+def test_env_var():
+ class TestEnv:
+ BLUBB: EnvVar[str] = env_var("default")
+ INTERNAL: EnvVar[str] = env_var("default", internal=True)
+ BOOLEAN: EnvVar[bool] = env_var(False)
+
+ assert TestEnv.BLUBB.get() == "default"
+ assert TestEnv.BLUBB.name == "BLUBB"
+ TestEnv.BLUBB.set("new")
+ assert os.environ.get("BLUBB") == "new"
+ assert TestEnv.BLUBB.get() == "new"
+ TestEnv.BLUBB.set(None)
+ assert "BLUBB" not in os.environ
+
+ assert TestEnv.INTERNAL.get() == "default"
+ assert TestEnv.INTERNAL.name == "__INTERNAL"
+ TestEnv.INTERNAL.set("new")
+ assert os.environ.get("__INTERNAL") == "new"
+ assert TestEnv.INTERNAL.get() == "new"
+ assert TestEnv.INTERNAL.getenv() == "new"
+ TestEnv.INTERNAL.set(None)
+ assert "__INTERNAL" not in os.environ
+
+ assert TestEnv.BOOLEAN.get() is False
+ assert TestEnv.BOOLEAN.name == "BOOLEAN"
+ TestEnv.BOOLEAN.set(True)
+ assert os.environ.get("BOOLEAN") == "True"
+ assert TestEnv.BOOLEAN.get() is True
+ TestEnv.BOOLEAN.set(False)
+ assert os.environ.get("BOOLEAN") == "False"
+ assert TestEnv.BOOLEAN.get() is False
+ TestEnv.BOOLEAN.set(None)
+ assert "BOOLEAN" not in os.environ
diff --git a/tests/test_db_config.py b/tests/units/test_db_config.py
similarity index 90%
rename from tests/test_db_config.py
rename to tests/units/test_db_config.py
index b8d7c07cb..5b716e6bb 100644
--- a/tests/test_db_config.py
+++ b/tests/units/test_db_config.py
@@ -164,7 +164,7 @@ def test_constructor_postgresql(username, password, host, port, database, expect
"localhost",
5432,
"db",
- "postgresql+psycopg2://user:pass@localhost:5432/db",
+ "postgresql+psycopg://user:pass@localhost:5432/db",
),
(
"user",
@@ -172,17 +172,17 @@ def test_constructor_postgresql(username, password, host, port, database, expect
"localhost",
None,
"db",
- "postgresql+psycopg2://user@localhost/db",
+ "postgresql+psycopg://user@localhost/db",
),
- ("user", "", "", None, "db", "postgresql+psycopg2://user@/db"),
- ("", "", "localhost", 5432, "db", "postgresql+psycopg2://localhost:5432/db"),
- ("", "", "", None, "db", "postgresql+psycopg2:///db"),
+ ("user", "", "", None, "db", "postgresql+psycopg://user@/db"),
+ ("", "", "localhost", 5432, "db", "postgresql+psycopg://localhost:5432/db"),
+ ("", "", "", None, "db", "postgresql+psycopg:///db"),
],
)
-def test_constructor_postgresql_psycopg2(
+def test_constructor_postgresql_psycopg(
username, password, host, port, database, expected_url
):
- """Test DBConfig.postgresql_psycopg2 constructor creates the instance correctly.
+ """Test DBConfig.postgresql_psycopg constructor creates the instance correctly.
Args:
username: Database username.
@@ -192,10 +192,10 @@ def test_constructor_postgresql_psycopg2(
database: Database name.
expected_url: Expected database URL generated.
"""
- db_config = DBConfig.postgresql_psycopg2(
+ db_config = DBConfig.postgresql_psycopg(
username=username, password=password, host=host, port=port, database=database
)
- assert db_config.engine == "postgresql+psycopg2"
+ assert db_config.engine == "postgresql+psycopg"
assert db_config.username == username
assert db_config.password == password
assert db_config.host == host
diff --git a/tests/test_event.py b/tests/units/test_event.py
similarity index 62%
rename from tests/test_event.py
rename to tests/units/test_event.py
index 284542a43..c5198a571 100644
--- a/tests/test_event.py
+++ b/tests/units/test_event.py
@@ -1,13 +1,20 @@
-import json
-from typing import List
+from typing import Callable, List
import pytest
-from reflex import event
-from reflex.event import Event, EventHandler, EventSpec, call_event_handler, fix_events
+import reflex as rx
+from reflex.event import (
+ Event,
+ EventChain,
+ EventHandler,
+ EventSpec,
+ call_event_handler,
+ event,
+ fix_events,
+)
from reflex.state import BaseState
from reflex.utils import format
-from reflex.vars import Var
+from reflex.vars.base import Field, LiteralVar, Var, field
def make_var(value) -> Var:
@@ -19,9 +26,7 @@ def make_var(value) -> Var:
Returns:
The var.
"""
- var = Var.create(value)
- assert var is not None
- return var
+ return Var(_js_expr=value)
def test_create_event():
@@ -57,10 +62,10 @@ def test_call_event_handler():
# Test passing vars as args.
assert event_spec.handler == handler
- assert event_spec.args[0][0].equals(Var.create_safe("arg1"))
- assert event_spec.args[0][1].equals(Var.create_safe("first"))
- assert event_spec.args[1][0].equals(Var.create_safe("arg2"))
- assert event_spec.args[1][1].equals(Var.create_safe("second"))
+ assert event_spec.args[0][0].equals(Var(_js_expr="arg1"))
+ assert event_spec.args[0][1].equals(Var(_js_expr="first"))
+ assert event_spec.args[1][0].equals(Var(_js_expr="arg2"))
+ assert event_spec.args[1][1].equals(Var(_js_expr="second"))
assert (
format.format_event(event_spec)
== 'Event("test_fn_with_args", {arg1:first,arg2:second})'
@@ -70,7 +75,7 @@ def test_call_event_handler():
event_spec = handler("first", "second") # type: ignore
assert (
format.format_event(event_spec)
- == 'Event("test_fn_with_args", {arg1:`first`,arg2:`second`})'
+ == 'Event("test_fn_with_args", {arg1:"first",arg2:"second"})'
)
first, second = 123, "456"
@@ -78,14 +83,14 @@ def test_call_event_handler():
event_spec = handler(first, second) # type: ignore
assert (
format.format_event(event_spec)
- == 'Event("test_fn_with_args", {arg1:123,arg2:`456`})'
+ == 'Event("test_fn_with_args", {arg1:123,arg2:"456"})'
)
assert event_spec.handler == handler
- assert event_spec.args[0][0].equals(Var.create_safe("arg1"))
- assert event_spec.args[0][1].equals(Var.create_safe(first))
- assert event_spec.args[1][0].equals(Var.create_safe("arg2"))
- assert event_spec.args[1][1].equals(Var.create_safe(second))
+ assert event_spec.args[0][0].equals(Var(_js_expr="arg1"))
+ assert event_spec.args[0][1].equals(LiteralVar.create(first))
+ assert event_spec.args[1][0].equals(Var(_js_expr="arg2"))
+ assert event_spec.args[1][1].equals(LiteralVar.create(second))
handler = EventHandler(fn=test_fn_with_args)
with pytest.raises(TypeError):
@@ -100,29 +105,32 @@ def test_call_event_handler_partial():
test_fn_with_args.__qualname__ = "test_fn_with_args"
- def spec(a2: str) -> List[str]:
+ def spec(a2: Var[str]) -> List[Var[str]]:
return [a2]
- handler = EventHandler(fn=test_fn_with_args)
+ handler = EventHandler(fn=test_fn_with_args, state_full_name="BigState")
event_spec = handler(make_var("first"))
event_spec2 = call_event_handler(event_spec, spec)
assert event_spec.handler == handler
assert len(event_spec.args) == 1
- assert event_spec.args[0][0].equals(Var.create_safe("arg1"))
- assert event_spec.args[0][1].equals(Var.create_safe("first"))
- assert format.format_event(event_spec) == 'Event("test_fn_with_args", {arg1:first})'
+ assert event_spec.args[0][0].equals(Var(_js_expr="arg1"))
+ assert event_spec.args[0][1].equals(Var(_js_expr="first"))
+ assert (
+ format.format_event(event_spec)
+ == 'Event("BigState.test_fn_with_args", {arg1:first})'
+ )
assert event_spec2 is not event_spec
assert event_spec2.handler == handler
assert len(event_spec2.args) == 2
- assert event_spec2.args[0][0].equals(Var.create_safe("arg1"))
- assert event_spec2.args[0][1].equals(Var.create_safe("first"))
- assert event_spec2.args[1][0].equals(Var.create_safe("arg2"))
- assert event_spec2.args[1][1].equals(Var.create_safe("_a2"))
+ assert event_spec2.args[0][0].equals(Var(_js_expr="arg1"))
+ assert event_spec2.args[0][1].equals(Var(_js_expr="first"))
+ assert event_spec2.args[1][0].equals(Var(_js_expr="arg2"))
+ assert event_spec2.args[1][1].equals(Var(_js_expr="_a2", _var_type=str))
assert (
format.format_event(event_spec2)
- == 'Event("test_fn_with_args", {arg1:first,arg2:_a2})'
+ == 'Event("BigState.test_fn_with_args", {arg1:first,arg2:_a2})'
)
@@ -160,27 +168,27 @@ def test_fix_events(arg1, arg2):
[
(
("/path", None, None),
- 'Event("_redirect", {path:`/path`,external:false,replace:false})',
+ 'Event("_redirect", {path:"/path",external:false,replace:false})',
),
(
("/path", True, None),
- 'Event("_redirect", {path:`/path`,external:true,replace:false})',
+ 'Event("_redirect", {path:"/path",external:true,replace:false})',
),
(
("/path", False, None),
- 'Event("_redirect", {path:`/path`,external:false,replace:false})',
+ 'Event("_redirect", {path:"/path",external:false,replace:false})',
),
(
- (Var.create_safe("path"), None, None),
+ (Var(_js_expr="path"), None, None),
'Event("_redirect", {path:path,external:false,replace:false})',
),
(
("/path", None, True),
- 'Event("_redirect", {path:`/path`,external:false,replace:true})',
+ 'Event("_redirect", {path:"/path",external:false,replace:true})',
),
(
("/path", True, True),
- 'Event("_redirect", {path:`/path`,external:true,replace:true})',
+ 'Event("_redirect", {path:"/path",external:true,replace:true})',
),
],
)
@@ -201,10 +209,6 @@ def test_event_redirect(input, output):
assert isinstance(spec, EventSpec)
assert spec.handler.fn.__qualname__ == "_redirect"
- # this asserts need comment about what it's testing (they fail with Var as input)
- # assert spec.args[0][0].equals(Var.create_safe("path"))
- # assert spec.args[0][1].equals(Var.create_safe("/path"))
-
assert format.format_event(spec) == output
@@ -212,24 +216,40 @@ def test_event_console_log():
"""Test the event console log function."""
spec = event.console_log("message")
assert isinstance(spec, EventSpec)
- assert spec.handler.fn.__qualname__ == "_console"
- assert spec.args[0][0].equals(Var.create_safe("message"))
- assert spec.args[0][1].equals(Var.create_safe("message"))
- assert format.format_event(spec) == 'Event("_console", {message:`message`})'
- spec = event.console_log(Var.create_safe("message"))
- assert format.format_event(spec) == 'Event("_console", {message:message})'
+ assert spec.handler.fn.__qualname__ == "_call_function"
+ assert spec.args[0][0].equals(Var(_js_expr="function"))
+ assert spec.args[0][1].equals(
+ Var('(() => (console["log"]("message")))', _var_type=Callable)
+ )
+ assert (
+ format.format_event(spec)
+ == 'Event("_call_function", {function:(() => (console["log"]("message")))})'
+ )
+ spec = event.console_log(Var(_js_expr="message"))
+ assert (
+ format.format_event(spec)
+ == 'Event("_call_function", {function:(() => (console["log"](message)))})'
+ )
def test_event_window_alert():
"""Test the event window alert function."""
spec = event.window_alert("message")
assert isinstance(spec, EventSpec)
- assert spec.handler.fn.__qualname__ == "_alert"
- assert spec.args[0][0].equals(Var.create_safe("message"))
- assert spec.args[0][1].equals(Var.create_safe("message"))
- assert format.format_event(spec) == 'Event("_alert", {message:`message`})'
- spec = event.window_alert(Var.create_safe("message"))
- assert format.format_event(spec) == 'Event("_alert", {message:message})'
+ assert spec.handler.fn.__qualname__ == "_call_function"
+ assert spec.args[0][0].equals(Var(_js_expr="function"))
+ assert spec.args[0][1].equals(
+ Var('(() => (window["alert"]("message")))', _var_type=Callable)
+ )
+ assert (
+ format.format_event(spec)
+ == 'Event("_call_function", {function:(() => (window["alert"]("message")))})'
+ )
+ spec = event.window_alert(Var(_js_expr="message"))
+ assert (
+ format.format_event(spec)
+ == 'Event("_call_function", {function:(() => (window["alert"](message)))})'
+ )
def test_set_focus():
@@ -237,11 +257,11 @@ def test_set_focus():
spec = event.set_focus("input1")
assert isinstance(spec, EventSpec)
assert spec.handler.fn.__qualname__ == "_set_focus"
- assert spec.args[0][0].equals(Var.create_safe("ref"))
- assert spec.args[0][1].equals(Var.create_safe("ref_input1"))
- assert format.format_event(spec) == 'Event("_set_focus", {ref:`ref_input1`})'
+ assert spec.args[0][0].equals(Var(_js_expr="ref"))
+ assert spec.args[0][1].equals(LiteralVar.create("ref_input1"))
+ assert format.format_event(spec) == 'Event("_set_focus", {ref:"ref_input1"})'
spec = event.set_focus("input1")
- assert format.format_event(spec) == 'Event("_set_focus", {ref:`ref_input1`})'
+ assert format.format_event(spec) == 'Event("_set_focus", {ref:"ref_input1"})'
def test_set_value():
@@ -249,17 +269,17 @@ def test_set_value():
spec = event.set_value("input1", "")
assert isinstance(spec, EventSpec)
assert spec.handler.fn.__qualname__ == "_set_value"
- assert spec.args[0][0].equals(Var.create_safe("ref"))
- assert spec.args[0][1].equals(Var.create_safe("ref_input1"))
- assert spec.args[1][0].equals(Var.create_safe("value"))
- assert spec.args[1][1].equals(Var.create_safe(""))
+ assert spec.args[0][0].equals(Var(_js_expr="ref"))
+ assert spec.args[0][1].equals(LiteralVar.create("ref_input1"))
+ assert spec.args[1][0].equals(Var(_js_expr="value"))
+ assert spec.args[1][1].equals(LiteralVar.create(""))
assert (
- format.format_event(spec) == 'Event("_set_value", {ref:`ref_input1`,value:``})'
+ format.format_event(spec) == 'Event("_set_value", {ref:"ref_input1",value:""})'
)
- spec = event.set_value("input1", Var.create_safe("message"))
+ spec = event.set_value("input1", Var(_js_expr="message"))
assert (
format.format_event(spec)
- == 'Event("_set_value", {ref:`ref_input1`,value:message})'
+ == 'Event("_set_value", {ref:"ref_input1",value:message})'
)
@@ -268,13 +288,13 @@ def test_remove_cookie():
spec = event.remove_cookie("testkey")
assert isinstance(spec, EventSpec)
assert spec.handler.fn.__qualname__ == "_remove_cookie"
- assert spec.args[0][0].equals(Var.create_safe("key"))
- assert spec.args[0][1].equals(Var.create_safe("testkey"))
- assert spec.args[1][0].equals(Var.create_safe("options"))
- assert spec.args[1][1].equals(Var.create_safe({"path": "/"}))
+ assert spec.args[0][0].equals(Var(_js_expr="key"))
+ assert spec.args[0][1].equals(LiteralVar.create("testkey"))
+ assert spec.args[1][0].equals(Var(_js_expr="options"))
+ assert spec.args[1][1].equals(LiteralVar.create({"path": "/"}))
assert (
format.format_event(spec)
- == 'Event("_remove_cookie", {key:`testkey`,options:{"path": "/"}})'
+ == 'Event("_remove_cookie", {key:"testkey",options:({ ["path"] : "/" })})'
)
@@ -289,13 +309,13 @@ def test_remove_cookie_with_options():
spec = event.remove_cookie("testkey", options)
assert isinstance(spec, EventSpec)
assert spec.handler.fn.__qualname__ == "_remove_cookie"
- assert spec.args[0][0].equals(Var.create_safe("key"))
- assert spec.args[0][1].equals(Var.create_safe("testkey"))
- assert spec.args[1][0].equals(Var.create_safe("options"))
- assert spec.args[1][1].equals(Var.create_safe(options))
+ assert spec.args[0][0].equals(Var(_js_expr="key"))
+ assert spec.args[0][1].equals(LiteralVar.create("testkey"))
+ assert spec.args[1][0].equals(Var(_js_expr="options"))
+ assert spec.args[1][1].equals(LiteralVar.create(options))
assert (
format.format_event(spec)
- == f'Event("_remove_cookie", {{key:`testkey`,options:{json.dumps(options)}}})'
+ == f'Event("_remove_cookie", {{key:"testkey",options:{LiteralVar.create(options)!s}}})'
)
@@ -313,10 +333,10 @@ def test_remove_local_storage():
spec = event.remove_local_storage("testkey")
assert isinstance(spec, EventSpec)
assert spec.handler.fn.__qualname__ == "_remove_local_storage"
- assert spec.args[0][0].equals(Var.create_safe("key"))
- assert spec.args[0][1].equals(Var.create_safe("testkey"))
+ assert spec.args[0][0].equals(Var(_js_expr="key"))
+ assert spec.args[0][1].equals(LiteralVar.create("testkey"))
assert (
- format.format_event(spec) == 'Event("_remove_local_storage", {key:`testkey`})'
+ format.format_event(spec) == 'Event("_remove_local_storage", {key:"testkey"})'
)
@@ -391,3 +411,42 @@ def test_event_actions_on_state():
assert sp_handler.event_actions == {"stopPropagation": True}
# should NOT affect other references to the handler
assert not handler.event_actions
+
+
+def test_event_var_data():
+ class S(BaseState):
+ x: Field[int] = field(0)
+
+ @event
+ def s(self, value: int):
+ pass
+
+ # Handler doesn't have any _var_data because it's just a str
+ handler_var = Var.create(S.s)
+ assert handler_var._get_all_var_data() is None
+
+ # Ensure spec carries _var_data
+ spec_var = Var.create(S.s(S.x))
+ assert spec_var._get_all_var_data() == S.x._get_all_var_data()
+
+ # Needed to instantiate the EventChain
+ def _args_spec(value: Var[int]) -> tuple[Var[int]]:
+ return (value,)
+
+ # Ensure chain carries _var_data
+ chain_var = Var.create(EventChain(events=[S.s(S.x)], args_spec=_args_spec))
+ assert chain_var._get_all_var_data() == S.x._get_all_var_data()
+
+
+def test_event_bound_method() -> None:
+ class S(BaseState):
+ @event
+ def e(self, arg: str):
+ print(arg)
+
+ class Wrapper:
+ def get_handler(self, arg: str):
+ return S.e(arg)
+
+ w = Wrapper()
+ _ = rx.input(on_change=w.get_handler)
diff --git a/tests/units/test_health_endpoint.py b/tests/units/test_health_endpoint.py
new file mode 100644
index 000000000..6d12d79d6
--- /dev/null
+++ b/tests/units/test_health_endpoint.py
@@ -0,0 +1,130 @@
+import json
+from unittest.mock import MagicMock, Mock
+
+import pytest
+import sqlalchemy
+from redis.exceptions import RedisError
+
+from reflex.app import health
+from reflex.model import get_db_status
+from reflex.utils.prerequisites import get_redis_status
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize(
+ "mock_redis_client, expected_status",
+ [
+ # Case 1: Redis client is available and responds to ping
+ (Mock(ping=lambda: None), {"redis": True}),
+ # Case 2: Redis client raises RedisError
+ (Mock(ping=lambda: (_ for _ in ()).throw(RedisError)), {"redis": False}),
+ # Case 3: Redis client is not used
+ (None, {"redis": None}),
+ ],
+)
+async def test_get_redis_status(mock_redis_client, expected_status, mocker):
+ # Mock the `get_redis_sync` function to return the mock Redis client
+ mock_get_redis_sync = mocker.patch(
+ "reflex.utils.prerequisites.get_redis_sync", return_value=mock_redis_client
+ )
+
+ # Call the function
+ status = await get_redis_status()
+
+ # Verify the result
+ assert status == expected_status
+ mock_get_redis_sync.assert_called_once()
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize(
+ "mock_engine, execute_side_effect, expected_status",
+ [
+ # Case 1: Database is accessible
+ (MagicMock(), None, {"db": True}),
+ # Case 2: Database connection error (OperationalError)
+ (
+ MagicMock(),
+ sqlalchemy.exc.OperationalError("error", "error", "error"),
+ {"db": False},
+ ),
+ ],
+)
+async def test_get_db_status(mock_engine, execute_side_effect, expected_status, mocker):
+ # Mock get_engine to return the mock_engine
+ mock_get_engine = mocker.patch("reflex.model.get_engine", return_value=mock_engine)
+
+ # Mock the connection and its execute method
+ if mock_engine:
+ mock_connection = mock_engine.connect.return_value.__enter__.return_value
+ if execute_side_effect:
+ # Simulate execute method raising an exception
+ mock_connection.execute.side_effect = execute_side_effect
+ else:
+ # Simulate successful execute call
+ mock_connection.execute.return_value = None
+
+ # Call the function
+ status = await get_db_status()
+
+ # Verify the result
+ assert status == expected_status
+ mock_get_engine.assert_called_once()
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize(
+ "db_enabled, redis_enabled, db_status, redis_status, expected_status, expected_code",
+ [
+ # Case 1: Both services are connected
+ (True, True, True, True, {"status": True, "db": True, "redis": True}, 200),
+ # Case 2: Database not connected, Redis connected
+ (True, True, False, True, {"status": False, "db": False, "redis": True}, 503),
+ # Case 3: Database connected, Redis not connected
+ (True, True, True, False, {"status": False, "db": True, "redis": False}, 503),
+ # Case 4: Both services not connected
+ (True, True, False, False, {"status": False, "db": False, "redis": False}, 503),
+ # Case 5: Database Connected, Redis not used
+ (True, False, True, None, {"status": True, "db": True}, 200),
+ # Case 6: Database not used, Redis Connected
+ (False, True, None, True, {"status": True, "redis": True}, 200),
+ # Case 7: Both services not used
+ (False, False, None, None, {"status": True}, 200),
+ ],
+)
+async def test_health(
+ db_enabled,
+ redis_enabled,
+ db_status,
+ redis_status,
+ expected_status,
+ expected_code,
+ mocker,
+):
+ # Mock get_db_status and get_redis_status
+ mocker.patch(
+ "reflex.utils.prerequisites.check_db_used",
+ return_value=db_enabled,
+ )
+ mocker.patch(
+ "reflex.utils.prerequisites.check_redis_used",
+ return_value=redis_enabled,
+ )
+ mocker.patch(
+ "reflex.app.get_db_status",
+ return_value={"db": db_status},
+ )
+ mocker.patch(
+ "reflex.utils.prerequisites.get_redis_status",
+ return_value={"redis": redis_status},
+ )
+
+ # Call the async health function
+ response = await health()
+
+ print(json.loads(response.body))
+ print(expected_status)
+
+ # Verify the response content and status code
+ assert response.status_code == expected_code
+ assert json.loads(response.body) == expected_status
diff --git a/tests/test_model.py b/tests/units/test_model.py
similarity index 97%
rename from tests/test_model.py
rename to tests/units/test_model.py
index ac8187e03..0a83f39ec 100644
--- a/tests/test_model.py
+++ b/tests/units/test_model.py
@@ -46,7 +46,7 @@ def test_default_primary_key(model_default_primary: Model):
Args:
model_default_primary: Fixture.
"""
- assert "id" in model_default_primary.__class__.__fields__
+ assert "id" in type(model_default_primary).__fields__
def test_custom_primary_key(model_custom_primary: Model):
@@ -55,7 +55,7 @@ def test_custom_primary_key(model_custom_primary: Model):
Args:
model_custom_primary: Fixture.
"""
- assert "id" not in model_custom_primary.__class__.__fields__
+ assert "id" not in type(model_custom_primary).__fields__
@pytest.mark.filterwarnings(
diff --git a/tests/units/test_page.py b/tests/units/test_page.py
new file mode 100644
index 000000000..e1dd70905
--- /dev/null
+++ b/tests/units/test_page.py
@@ -0,0 +1,79 @@
+from reflex import text
+from reflex.config import get_config
+from reflex.page import DECORATED_PAGES, get_decorated_pages, page
+
+
+def test_page_decorator():
+ def foo_():
+ return text("foo")
+
+ assert len(DECORATED_PAGES) == 0
+ decorated_foo_ = page()(foo_)
+ assert decorated_foo_ == foo_
+ assert len(DECORATED_PAGES) == 1
+ page_data = DECORATED_PAGES.get(get_config().app_name, [])[0][1]
+ assert page_data == {}
+ DECORATED_PAGES.clear()
+
+
+def test_page_decorator_with_kwargs():
+ def foo_():
+ return text("foo")
+
+ def load_foo():
+ return []
+
+ DECORATED_PAGES.clear()
+ assert len(DECORATED_PAGES) == 0
+ decorated_foo_ = page(
+ route="foo",
+ title="Foo",
+ image="foo.png",
+ description="Foo description",
+ meta=["foo-meta"],
+ script_tags=["foo-script"],
+ on_load=load_foo,
+ )(foo_)
+ assert decorated_foo_ == foo_
+ assert len(DECORATED_PAGES) == 1
+ page_data = DECORATED_PAGES.get(get_config().app_name, [])[0][1]
+ assert page_data == {
+ "description": "Foo description",
+ "image": "foo.png",
+ "meta": ["foo-meta"],
+ "on_load": load_foo,
+ "route": "foo",
+ "script_tags": ["foo-script"],
+ "title": "Foo",
+ }
+
+ DECORATED_PAGES.clear()
+
+
+def test_get_decorated_pages():
+ assert get_decorated_pages() == []
+
+ def foo_():
+ return text("foo")
+
+ page()(foo_)
+
+ assert get_decorated_pages() == []
+ assert get_decorated_pages(omit_implicit_routes=False) == [{}]
+
+ page(route="foo2")(foo_)
+
+ assert get_decorated_pages() == [{"route": "foo2"}]
+ assert get_decorated_pages(omit_implicit_routes=False) == [{}, {"route": "foo2"}]
+
+ page(route="foo3", title="Foo3")(foo_)
+
+ assert get_decorated_pages() == [
+ {"route": "foo2"},
+ {"route": "foo3", "title": "Foo3"},
+ ]
+ assert get_decorated_pages(omit_implicit_routes=False) == [
+ {},
+ {"route": "foo2"},
+ {"route": "foo3", "title": "Foo3"},
+ ]
diff --git a/tests/test_prerequisites.py b/tests/units/test_prerequisites.py
similarity index 86%
rename from tests/test_prerequisites.py
rename to tests/units/test_prerequisites.py
index c4f57a998..90afe0963 100644
--- a/tests/test_prerequisites.py
+++ b/tests/units/test_prerequisites.py
@@ -24,7 +24,15 @@ from reflex.utils.prerequisites import (
app_name="test",
),
False,
- 'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true};',
+ 'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60};',
+ ),
+ (
+ Config(
+ app_name="test",
+ static_page_generation_timeout=30,
+ ),
+ False,
+ 'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 30};',
),
(
Config(
@@ -32,7 +40,7 @@ from reflex.utils.prerequisites import (
next_compression=False,
),
False,
- 'module.exports = {basePath: "", compress: false, reactStrictMode: true, trailingSlash: true};',
+ 'module.exports = {basePath: "", compress: false, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60};',
),
(
Config(
@@ -40,7 +48,7 @@ from reflex.utils.prerequisites import (
frontend_path="/test",
),
False,
- 'module.exports = {basePath: "/test", compress: true, reactStrictMode: true, trailingSlash: true};',
+ 'module.exports = {basePath: "/test", compress: true, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60};',
),
(
Config(
@@ -49,14 +57,14 @@ from reflex.utils.prerequisites import (
next_compression=False,
),
False,
- 'module.exports = {basePath: "/test", compress: false, reactStrictMode: true, trailingSlash: true};',
+ 'module.exports = {basePath: "/test", compress: false, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60};',
),
(
Config(
app_name="test",
),
True,
- 'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true, output: "export", distDir: "_static"};',
+ 'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60, output: "export", distDir: "_static"};',
),
],
)
@@ -97,8 +105,8 @@ def test_initialize_requirements_txt_no_op(mocker):
return_value=Mock(best=lambda: Mock(encoding="utf-8")),
)
mock_fp_touch = mocker.patch("pathlib.Path.touch")
- open_mock = mock_open(read_data="reflex==0.2.9")
- mocker.patch("builtins.open", open_mock)
+ open_mock = mock_open(read_data="reflex==0.6.7")
+ mocker.patch("pathlib.Path.open", open_mock)
initialize_requirements_txt()
assert open_mock.call_count == 1
assert open_mock.call_args.kwargs["encoding"] == "utf-8"
@@ -114,7 +122,7 @@ def test_initialize_requirements_txt_missing_reflex(mocker):
return_value=Mock(best=lambda: Mock(encoding="utf-8")),
)
open_mock = mock_open(read_data="random-package=1.2.3")
- mocker.patch("builtins.open", open_mock)
+ mocker.patch("pathlib.Path.open", open_mock)
initialize_requirements_txt()
# Currently open for read, then open for append
assert open_mock.call_count == 2
@@ -130,7 +138,7 @@ def test_initialize_requirements_txt_not_exist(mocker):
# File does not exist, create file with reflex
mocker.patch("pathlib.Path.exists", return_value=False)
open_mock = mock_open()
- mocker.patch("builtins.open", open_mock)
+ mocker.patch("pathlib.Path.open", open_mock)
initialize_requirements_txt()
assert open_mock.call_count == 2
# By default, use utf-8 encoding
@@ -162,7 +170,7 @@ def test_requirements_txt_other_encoding(mocker):
)
initialize_requirements_txt()
open_mock = mock_open(read_data="random-package=1.2.3")
- mocker.patch("builtins.open", open_mock)
+ mocker.patch("pathlib.Path.open", open_mock)
initialize_requirements_txt()
# Currently open for read, then open for append
assert open_mock.call_count == 2
diff --git a/tests/test_route.py b/tests/units/test_route.py
similarity index 100%
rename from tests/test_route.py
rename to tests/units/test_route.py
diff --git a/tests/test_sqlalchemy.py b/tests/units/test_sqlalchemy.py
similarity index 97%
rename from tests/test_sqlalchemy.py
rename to tests/units/test_sqlalchemy.py
index b18799e0c..23e315785 100644
--- a/tests/test_sqlalchemy.py
+++ b/tests/units/test_sqlalchemy.py
@@ -127,8 +127,8 @@ def test_automigration(
assert result[0].b == 4.2
# No-op
- # assert Model.migrate(autogenerate=True)
- # assert len(list(versions.glob("*.py"))) == 4
+ # assert Model.migrate(autogenerate=True) #noqa: ERA001
+ # assert len(list(versions.glob("*.py"))) == 4 #noqa: ERA001
# drop table (AlembicSecond)
model_registry.get_metadata().clear()
diff --git a/tests/test_state.py b/tests/units/test_state.py
similarity index 79%
rename from tests/test_state.py
rename to tests/units/test_state.py
index 1a014739d..39484752c 100644
--- a/tests/test_state.py
+++ b/tests/units/test_state.py
@@ -2,17 +2,32 @@ from __future__ import annotations
import asyncio
import copy
+import dataclasses
import datetime
import functools
import json
import os
import sys
+import threading
from textwrap import dedent
-from typing import Any, Callable, Dict, Generator, List, Optional, Union
+from typing import (
+ Any,
+ AsyncGenerator,
+ Callable,
+ Dict,
+ List,
+ Optional,
+ Set,
+ Tuple,
+ Union,
+)
from unittest.mock import AsyncMock, Mock
import pytest
+import pytest_asyncio
from plotly.graph_objects import Figure
+from pydantic import BaseModel as BaseModelV2
+from pydantic.v1 import BaseModel as BaseModelV1
import reflex as rx
import reflex.config
@@ -31,6 +46,7 @@ from reflex.state import (
RouterData,
State,
StateManager,
+ StateManagerDisk,
StateManagerMemory,
StateManagerRedis,
StateProxy,
@@ -39,14 +55,22 @@ from reflex.state import (
)
from reflex.testing import chdir
from reflex.utils import format, prerequisites, types
+from reflex.utils.exceptions import (
+ InvalidLockWarningThresholdError,
+ ReflexRuntimeError,
+ SetUndefinedStateVarError,
+ StateSerializationError,
+)
from reflex.utils.format import json_dumps
-from reflex.vars import BaseVar, ComputedVar
-from tests.states.mutation import MutableSQLAModel, MutableTestState
+from reflex.vars.base import Var, computed_var
+from tests.units.states.mutation import MutableSQLAModel, MutableTestState
from .states import GenState
CI = bool(os.environ.get("CI", False))
-LOCK_EXPIRATION = 2000 if CI else 300
+LOCK_EXPIRATION = 2500 if CI else 300
+LOCK_WARNING_THRESHOLD = 1000 if CI else 100
+LOCK_WARN_SLEEP = 1.5 if CI else 0.15
LOCK_EXPIRE_SLEEP = 2.5 if CI else 0.4
@@ -57,6 +81,7 @@ formatted_router = {
"origin": "",
"upgrade": "",
"connection": "",
+ "cookie": "",
"pragma": "",
"cache_control": "",
"user_agent": "",
@@ -100,8 +125,10 @@ class TestState(BaseState):
complex: Dict[int, Object] = {1: Object(), 2: Object()}
fig: Figure = Figure()
dt: datetime.datetime = datetime.datetime.fromisoformat("1989-11-09T18:53:00+01:00")
+ _backend: int = 0
+ asynctest: int = 0
- @ComputedVar
+ @computed_var
def sum(self) -> float:
"""Dynamically sum the numbers.
@@ -110,7 +137,7 @@ class TestState(BaseState):
"""
return self.num1 + self.num2
- @ComputedVar
+ @computed_var
def upper(self) -> str:
"""Uppercase the key.
@@ -123,6 +150,14 @@ class TestState(BaseState):
"""Do something."""
pass
+ async def set_asynctest(self, value: int):
+ """Set the asynctest value. Intentionally overwrite the default setter with an async one.
+
+ Args:
+ value: The new value.
+ """
+ self.asynctest = value
+
class ChildState(TestState):
"""A child state fixture."""
@@ -266,12 +301,12 @@ def test_base_class_vars(test_state):
if field in test_state.get_skip_vars():
continue
prop = getattr(cls, field)
- assert isinstance(prop, BaseVar)
- assert prop._var_name == field
+ assert isinstance(prop, Var)
+ assert prop._js_expr.split(".")[-1] == field
- assert cls.num1._var_type == int
- assert cls.num2._var_type == float
- assert cls.key._var_type == str
+ assert cls.num1._var_type is int
+ assert cls.num2._var_type is float
+ assert cls.key._var_type is str
def test_computed_class_var(test_state):
@@ -281,7 +316,7 @@ def test_computed_class_var(test_state):
test_state: A state.
"""
cls = type(test_state)
- vars = [(prop._var_name, prop._var_type) for prop in cls.computed_vars.values()]
+ vars = [(prop._js_expr, prop._var_type) for prop in cls.computed_vars.values()]
assert ("sum", float) in vars
assert ("upper", str) in vars
@@ -307,6 +342,7 @@ def test_class_vars(test_state):
"upper",
"fig",
"dt",
+ "asynctest",
}
@@ -395,30 +431,27 @@ def test_default_setters(test_state):
def test_class_indexing_with_vars():
"""Test that we can index into a state var with another var."""
prop = TestState.array[TestState.num1]
- assert (
- str(prop) == f"{{{TestState.get_name()}.array.at({TestState.get_name()}.num1)}}"
- )
+ assert str(prop) == f"{TestState.get_name()}.array.at({TestState.get_name()}.num1)"
prop = TestState.mapping["a"][TestState.num1]
assert (
str(prop)
- == f'{{{TestState.get_name()}.mapping["a"].at({TestState.get_name()}.num1)}}'
+ == f'{TestState.get_name()}.mapping["a"].at({TestState.get_name()}.num1)'
)
prop = TestState.mapping[TestState.map_key]
assert (
- str(prop)
- == f"{{{TestState.get_name()}.mapping[{TestState.get_name()}.map_key]}}"
+ str(prop) == f"{TestState.get_name()}.mapping[{TestState.get_name()}.map_key]"
)
def test_class_attributes():
"""Test that we can get class attributes."""
prop = TestState.obj.prop1
- assert str(prop) == f"{{{TestState.get_name()}.obj.prop1}}"
+ assert str(prop) == f'{TestState.get_name()}.obj["prop1"]'
prop = TestState.complex[1].prop1
- assert str(prop) == f"{{{TestState.get_name()}.complex[1].prop1}}"
+ assert str(prop) == f'{TestState.get_name()}.complex[1]["prop1"]'
def test_get_parent_state():
@@ -440,26 +473,28 @@ def test_get_substates():
def test_get_name():
"""Test getting the name of a state."""
- assert TestState.get_name() == "tests___test_state____test_state"
- assert ChildState.get_name() == "tests___test_state____child_state"
- assert ChildState2.get_name() == "tests___test_state____child_state2"
- assert GrandchildState.get_name() == "tests___test_state____grandchild_state"
+ assert TestState.get_name() == "tests___units___test_state____test_state"
+ assert ChildState.get_name() == "tests___units___test_state____child_state"
+ assert ChildState2.get_name() == "tests___units___test_state____child_state2"
+ assert (
+ GrandchildState.get_name() == "tests___units___test_state____grandchild_state"
+ )
def test_get_full_name():
"""Test getting the full name."""
- assert TestState.get_full_name() == "tests___test_state____test_state"
+ assert TestState.get_full_name() == "tests___units___test_state____test_state"
assert (
ChildState.get_full_name()
- == "tests___test_state____test_state.tests___test_state____child_state"
+ == "tests___units___test_state____test_state.tests___units___test_state____child_state"
)
assert (
ChildState2.get_full_name()
- == "tests___test_state____test_state.tests___test_state____child_state2"
+ == "tests___units___test_state____test_state.tests___units___test_state____child_state2"
)
assert (
GrandchildState.get_full_name()
- == "tests___test_state____test_state.tests___test_state____child_state.tests___test_state____grandchild_state"
+ == "tests___units___test_state____test_state.tests___units___test_state____child_state.tests___units___test_state____grandchild_state"
)
@@ -519,12 +554,10 @@ def test_set_class_var():
"""Test setting the var of a class."""
with pytest.raises(AttributeError):
TestState.num3 # type: ignore
- TestState._set_var(
- BaseVar(_var_name="num3", _var_type=int)._var_set_state(TestState)
- )
+ TestState._set_var(Var(_js_expr="num3", _var_type=int)._var_set_state(TestState))
var = TestState.num3 # type: ignore
- assert var._var_name == "num3"
- assert var._var_type == int
+ assert var._js_expr == TestState.get_full_name() + ".num3"
+ assert var._var_type is int
assert var._var_state == TestState.get_full_name()
@@ -651,7 +684,12 @@ def test_set_dirty_var(test_state):
assert test_state.dirty_vars == set()
-def test_set_dirty_substate(test_state, child_state, child_state2, grandchild_state):
+def test_set_dirty_substate(
+ test_state: TestState,
+ child_state: ChildState,
+ child_state2: ChildState2,
+ grandchild_state: GrandchildState,
+):
"""Test changing substate vars marks the value as dirty.
Args:
@@ -699,6 +737,7 @@ def test_reset(test_state, child_state):
# Set some values.
test_state.num1 = 1
test_state.num2 = 2
+ test_state._backend = 3
child_state.value = "test"
# Reset the state.
@@ -707,6 +746,7 @@ def test_reset(test_state, child_state):
# The values should be reset.
assert test_state.num1 == 0
assert test_state.num2 == 3.14
+ assert test_state._backend == 0
assert child_state.value == ""
expected_dirty_vars = {
@@ -722,6 +762,8 @@ def test_reset(test_state, child_state):
"map_key",
"mapping",
"dt",
+ "_backend",
+ "asynctest",
}
# The dirty vars should be reset.
@@ -752,7 +794,6 @@ async def test_process_event_simple(test_state):
assert test_state.num1 == 69
# The delta should contain the changes, including computed vars.
- # assert update.delta == {"test_state": {"num1": 69, "sum": 72.14}}
assert update.delta == {
TestState.get_full_name(): {"num1": 69, "sum": 72.14, "upper": ""},
GrandchildState3.get_full_name(): {"computed": ""},
@@ -862,8 +903,10 @@ def test_get_headers(test_state, router_data, router_data_headers):
router_data: The router data fixture.
router_data_headers: The expected headers.
"""
+ print(router_data_headers)
test_state.router = RouterData(router_data)
- assert test_state.router.headers.dict() == {
+ print(test_state.router.headers)
+ assert dataclasses.asdict(test_state.router.headers) == {
format.to_snake_case(k): v for k, v in router_data_headers.items()
}
@@ -933,7 +976,7 @@ class InterdependentState(BaseState):
"""A state with 3 vars and 3 computed vars.
x: a variable that no computed var depends on
- v1: a varable that one computed var directly depeneds on
+ v1: a variable that one computed var directly depends on
_v2: a backend variable that one computed var directly depends on
v1x2: a computed var that depends on v1
@@ -1064,7 +1107,8 @@ def test_dirty_computed_var_from_backend_var(
Args:
interdependent_state: A state with varying Var dependencies.
"""
- assert InterdependentState._v3._backend is True
+ # Accessing ._v3 returns the immutable var it represents instead of the actual computed var
+ # assert InterdependentState._v3._backend is True
interdependent_state._v2 = 2
assert interdependent_state.get_delta() == {
interdependent_state.get_full_name(): {"v2x2": 4, "v3x2": 4},
@@ -1098,7 +1142,7 @@ def test_child_state():
v: int = 2
class ChildState(MainState):
- @ComputedVar
+ @computed_var
def rendered_var(self):
return self.v
@@ -1117,7 +1161,7 @@ def test_conditional_computed_vars():
t1: str = "a"
t2: str = "b"
- @ComputedVar
+ @computed_var
def rendered_var(self) -> str:
if self.flag:
return self.t1
@@ -1276,19 +1320,19 @@ def test_computed_var_depends_on_parent_non_cached():
assert ps.dirty_vars == set()
assert cs.dirty_vars == set()
- dict1 = ps.dict()
+ dict1 = json.loads(json_dumps(ps.dict()))
assert dict1[ps.get_full_name()] == {
"no_cache_v": 1,
"router": formatted_router,
}
assert dict1[cs.get_full_name()] == {"dep_v": 2}
- dict2 = ps.dict()
+ dict2 = json.loads(json_dumps(ps.dict()))
assert dict2[ps.get_full_name()] == {
"no_cache_v": 3,
"router": formatted_router,
}
assert dict2[cs.get_full_name()] == {"dep_v": 4}
- dict3 = ps.dict()
+ dict3 = json.loads(json_dumps(ps.dict()))
assert dict3[ps.get_full_name()] == {
"no_cache_v": 5,
"router": formatted_router,
@@ -1532,7 +1576,7 @@ def test_error_on_state_method_shadow():
assert (
err.value.args[0]
- == f"The event handler name `reset` shadows a builtin State method; use a different name instead"
+ == "The event handler name `reset` shadows a builtin State method; use a different name instead"
)
@@ -1588,8 +1632,10 @@ async def test_state_with_invalid_yield(capsys, mock_app):
assert "must only return/yield: None, Events or other EventHandlers" in captured.out
-@pytest.fixture(scope="function", params=["in_process", "redis"])
-def state_manager(request) -> Generator[StateManager, None, None]:
+@pytest_asyncio.fixture(
+ loop_scope="function", scope="function", params=["in_process", "disk", "redis"]
+)
+async def state_manager(request) -> AsyncGenerator[StateManager, None]:
"""Instance of state manager parametrized for redis and in-process.
Args:
@@ -1602,15 +1648,18 @@ def state_manager(request) -> Generator[StateManager, None, None]:
if request.param == "redis":
if not isinstance(state_manager, StateManagerRedis):
pytest.skip("Test requires redis")
- else:
+ elif request.param == "disk":
# explicitly NOT using redis
+ state_manager = StateManagerDisk(state=TestState)
+ assert not state_manager._states_locks
+ else:
state_manager = StateManagerMemory(state=TestState)
assert not state_manager._states_locks
yield state_manager
if isinstance(state_manager, StateManagerRedis):
- asyncio.get_event_loop().run_until_complete(state_manager.close())
+ await state_manager.close()
@pytest.fixture()
@@ -1641,7 +1690,7 @@ async def test_state_manager_modify_state(
async with state_manager.modify_state(substate_token) as state:
if isinstance(state_manager, StateManagerRedis):
assert await state_manager.redis.get(f"{token}_lock")
- elif isinstance(state_manager, StateManagerMemory):
+ elif isinstance(state_manager, (StateManagerMemory, StateManagerDisk)):
assert token in state_manager._states_locks
assert state_manager._states_locks[token].locked()
# Should be able to write proxy objects inside mutables
@@ -1651,11 +1700,11 @@ async def test_state_manager_modify_state(
# lock should be dropped after exiting the context
if isinstance(state_manager, StateManagerRedis):
assert (await state_manager.redis.get(f"{token}_lock")) is None
- elif isinstance(state_manager, StateManagerMemory):
+ elif isinstance(state_manager, (StateManagerMemory, StateManagerDisk)):
assert not state_manager._states_locks[token].locked()
# separate instances should NOT share locks
- sm2 = StateManagerMemory(state=TestState)
+ sm2 = type(state_manager)(state=TestState)
assert sm2._state_manager_lock is state_manager._state_manager_lock
assert not sm2._states_locks
if state_manager._states_locks:
@@ -1693,13 +1742,13 @@ async def test_state_manager_contend(
if isinstance(state_manager, StateManagerRedis):
assert (await state_manager.redis.get(f"{token}_lock")) is None
- elif isinstance(state_manager, StateManagerMemory):
+ elif isinstance(state_manager, (StateManagerMemory, StateManagerDisk)):
assert token in state_manager._states_locks
assert not state_manager._states_locks[token].locked()
-@pytest.fixture(scope="function")
-def state_manager_redis() -> Generator[StateManager, None, None]:
+@pytest_asyncio.fixture(loop_scope="function", scope="function")
+async def state_manager_redis() -> AsyncGenerator[StateManager, None]:
"""Instance of state manager for redis only.
Yields:
@@ -1712,7 +1761,7 @@ def state_manager_redis() -> Generator[StateManager, None, None]:
yield state_manager
- asyncio.get_event_loop().run_until_complete(state_manager.close())
+ await state_manager.close()
@pytest.fixture()
@@ -1741,6 +1790,7 @@ async def test_state_manager_lock_expire(
substate_token_redis: A token + substate name for looking up in state manager.
"""
state_manager_redis.lock_expiration = LOCK_EXPIRATION
+ state_manager_redis.lock_warning_threshold = LOCK_WARNING_THRESHOLD
async with state_manager_redis.modify_state(substate_token_redis):
await asyncio.sleep(0.01)
@@ -1765,6 +1815,7 @@ async def test_state_manager_lock_expire_contend(
unexp_num1 = 666
state_manager_redis.lock_expiration = LOCK_EXPIRATION
+ state_manager_redis.lock_warning_threshold = LOCK_WARNING_THRESHOLD
order = []
@@ -1794,13 +1845,63 @@ async def test_state_manager_lock_expire_contend(
assert (await state_manager_redis.get_state(substate_token_redis)).num1 == exp_num1
+@pytest.mark.asyncio
+async def test_state_manager_lock_warning_threshold_contend(
+ state_manager_redis: StateManager, token: str, substate_token_redis: str, mocker
+):
+ """Test that the state manager triggers a warning when lock contention exceeds the warning threshold.
+
+ Args:
+ state_manager_redis: A state manager instance.
+ token: A token.
+ substate_token_redis: A token + substate name for looking up in state manager.
+ mocker: Pytest mocker object.
+ """
+ console_warn = mocker.patch("reflex.utils.console.warn")
+
+ state_manager_redis.lock_expiration = LOCK_EXPIRATION
+ state_manager_redis.lock_warning_threshold = LOCK_WARNING_THRESHOLD
+
+ order = []
+
+ async def _coro_blocker():
+ async with state_manager_redis.modify_state(substate_token_redis):
+ order.append("blocker")
+ await asyncio.sleep(LOCK_WARN_SLEEP)
+
+ tasks = [
+ asyncio.create_task(_coro_blocker()),
+ ]
+
+ await tasks[0]
+ console_warn.assert_called()
+ assert console_warn.call_count == 7
+
+
+class CopyingAsyncMock(AsyncMock):
+ """An AsyncMock, but deepcopy the args and kwargs first."""
+
+ def __call__(self, *args, **kwargs):
+ """Call the mock.
+
+ Args:
+ args: the arguments passed to the mock
+ kwargs: the keyword arguments passed to the mock
+
+ Returns:
+ The result of the mock call
+ """
+ args = copy.deepcopy(args)
+ kwargs = copy.deepcopy(kwargs)
+ return super().__call__(*args, **kwargs)
+
+
@pytest.fixture(scope="function")
-def mock_app(monkeypatch, state_manager: StateManager) -> rx.App:
- """Mock app fixture.
+def mock_app_simple(monkeypatch) -> rx.App:
+ """Simple Mock app fixture.
Args:
monkeypatch: Pytest monkeypatch object.
- state_manager: A state manager.
Returns:
The app, after mocking out prerequisites.get_app()
@@ -1811,8 +1912,7 @@ def mock_app(monkeypatch, state_manager: StateManager) -> rx.App:
setattr(app_module, CompileVars.APP, app)
app.state = TestState
- app._state_manager = state_manager
- app.event_namespace.emit = AsyncMock() # type: ignore
+ app.event_namespace.emit = CopyingAsyncMock() # type: ignore
def _mock_get_app(*args, **kwargs):
return app_module
@@ -1821,6 +1921,21 @@ def mock_app(monkeypatch, state_manager: StateManager) -> rx.App:
return app
+@pytest.fixture(scope="function")
+def mock_app(mock_app_simple: rx.App, state_manager: StateManager) -> rx.App:
+ """Mock app fixture.
+
+ Args:
+ mock_app_simple: A simple mock app.
+ state_manager: A state manager.
+
+ Returns:
+ The app, after mocking out prerequisites.get_app()
+ """
+ mock_app_simple._state_manager = state_manager
+ return mock_app_simple
+
+
@pytest.mark.asyncio
async def test_state_proxy(grandchild_state: GrandchildState, mock_app: rx.App):
"""Test that the state proxy works.
@@ -1833,7 +1948,7 @@ async def test_state_proxy(grandchild_state: GrandchildState, mock_app: rx.App):
assert child_state is not None
parent_state = child_state.parent_state
assert parent_state is not None
- if isinstance(mock_app.state_manager, StateManagerMemory):
+ if isinstance(mock_app.state_manager, (StateManagerMemory, StateManagerDisk)):
mock_app.state_manager.states[parent_state.router.session.client_token] = (
parent_state
)
@@ -1872,7 +1987,7 @@ async def test_state_proxy(grandchild_state: GrandchildState, mock_app: rx.App):
async with sp:
assert sp._self_actx is not None
assert sp._self_mutable # proxy is mutable inside context
- if isinstance(mock_app.state_manager, StateManagerMemory):
+ if isinstance(mock_app.state_manager, (StateManagerMemory, StateManagerDisk)):
# For in-process store, only one instance of the state exists
assert sp.__wrapped__ is grandchild_state
else:
@@ -1887,7 +2002,7 @@ async def test_state_proxy(grandchild_state: GrandchildState, mock_app: rx.App):
gotten_state = await mock_app.state_manager.get_state(
_substate_key(grandchild_state.router.session.client_token, grandchild_state)
)
- if isinstance(mock_app.state_manager, StateManagerMemory):
+ if isinstance(mock_app.state_manager, (StateManagerMemory, StateManagerDisk)):
# For in-process store, only one instance of the state exists
assert gotten_state is parent_state
else:
@@ -1901,7 +2016,7 @@ async def test_state_proxy(grandchild_state: GrandchildState, mock_app: rx.App):
mock_app.event_namespace.emit.assert_called_once()
mcall = mock_app.event_namespace.emit.mock_calls[0]
assert mcall.args[0] == str(SocketEvent.EVENT)
- assert json.loads(mcall.args[1]) == StateUpdate(
+ assert mcall.args[1] == StateUpdate(
delta={
parent_state.get_full_name(): {
"upper": "",
@@ -1924,6 +2039,10 @@ class BackgroundTaskState(BaseState):
order: List[str] = []
dict_list: Dict[str, List[int]] = {"foo": [1, 2, 3]}
+ def __init__(self, **kwargs): # noqa: D107
+ super().__init__(**kwargs)
+ self.router_data = {"simulate": "hydrate"}
+
@rx.var
def computed_order(self) -> List[str]:
"""Get the order as a computed var.
@@ -1933,7 +2052,7 @@ class BackgroundTaskState(BaseState):
"""
return self.order
- @rx.background
+ @rx.event(background=True)
async def background_task(self):
"""A background task that updates the state."""
async with self:
@@ -1970,7 +2089,7 @@ class BackgroundTaskState(BaseState):
self.other() # direct calling event handlers works in context
self._private_method()
- @rx.background
+ @rx.event(background=True)
async def background_task_reset(self):
"""A background task that resets the state."""
with pytest.raises(ImmutableStateError):
@@ -1984,7 +2103,7 @@ class BackgroundTaskState(BaseState):
async with self:
self.order.append("reset")
- @rx.background
+ @rx.event(background=True)
async def background_task_generator(self):
"""A background task generator that does nothing.
@@ -2091,51 +2210,51 @@ async def test_background_task_no_block(mock_app: rx.App, token: str):
assert mock_app.event_namespace is not None
emit_mock = mock_app.event_namespace.emit
- first_ws_message = json.loads(emit_mock.mock_calls[0].args[1])
+ first_ws_message = emit_mock.mock_calls[0].args[1]
assert (
- first_ws_message["delta"][BackgroundTaskState.get_full_name()].pop("router")
+ first_ws_message.delta[BackgroundTaskState.get_full_name()].pop("router")
is not None
)
- assert first_ws_message == {
- "delta": {
+ assert first_ws_message == StateUpdate(
+ delta={
BackgroundTaskState.get_full_name(): {
"order": ["background_task:start"],
"computed_order": ["background_task:start"],
}
},
- "events": [],
- "final": True,
- }
+ events=[],
+ final=True,
+ )
for call in emit_mock.mock_calls[1:5]:
- assert json.loads(call.args[1]) == {
- "delta": {
+ assert call.args[1] == StateUpdate(
+ delta={
BackgroundTaskState.get_full_name(): {
"computed_order": ["background_task:start"],
}
},
- "events": [],
- "final": True,
- }
- assert json.loads(emit_mock.mock_calls[-2].args[1]) == {
- "delta": {
+ events=[],
+ final=True,
+ )
+ assert emit_mock.mock_calls[-2].args[1] == StateUpdate(
+ delta={
BackgroundTaskState.get_full_name(): {
"order": exp_order,
"computed_order": exp_order,
"dict_list": {},
}
},
- "events": [],
- "final": True,
- }
- assert json.loads(emit_mock.mock_calls[-1].args[1]) == {
- "delta": {
+ events=[],
+ final=True,
+ )
+ assert emit_mock.mock_calls[-1].args[1] == StateUpdate(
+ delta={
BackgroundTaskState.get_full_name(): {
"computed_order": exp_order,
},
},
- "events": [],
- "final": True,
- }
+ events=[],
+ final=True,
+ )
@pytest.mark.asyncio
@@ -2481,13 +2600,16 @@ def test_mutable_copy_vars(mutable_state: MutableTestState, copy_func: Callable)
def test_duplicate_substate_class(mocker):
+ # Neuter pytest escape hatch, because we want to test duplicate detection.
mocker.patch("reflex.state.is_testing_env", lambda: False)
+ # Neuter state handling since these _are_ defined inside a function.
+ mocker.patch("reflex.state.BaseState._handle_local_def", lambda: None)
with pytest.raises(ValueError):
class TestState(BaseState):
pass
- class ChildTestState(TestState): # type: ignore # noqa
+ class ChildTestState(TestState): # type: ignore
pass
class ChildTestState(TestState): # type: ignore # noqa
@@ -2509,7 +2631,7 @@ def test_json_dumps_with_mutables():
items: List[Foo] = [Foo()]
dict_val = MutableContainsBase().dict()
- assert isinstance(dict_val[MutableContainsBase.get_full_name()]["items"][0], dict)
+ assert isinstance(dict_val[MutableContainsBase.get_full_name()]["items"][0], Foo)
val = json_dumps(dict_val)
f_items = '[{"tags": ["123", "456"]}]'
f_formatted_router = str(formatted_router).replace("'", '"')
@@ -2563,7 +2685,7 @@ class Custom1(Base):
self.foo = val
def double_foo(self) -> str:
- """Concantenate foo with foo.
+ """Concatenate foo with foo.
Returns:
foo + foo
@@ -2604,15 +2726,23 @@ def test_state_union_optional():
c3r: Custom3 = Custom3(c2r=Custom2(c1r=Custom1(foo="")))
custom_union: Union[Custom1, Custom2, Custom3] = Custom1(foo="")
- assert UnionState.c3.c2._var_name == "c3?.c2" # type: ignore
- assert UnionState.c3.c2.c1._var_name == "c3?.c2?.c1" # type: ignore
- assert UnionState.c3.c2.c1.foo._var_name == "c3?.c2?.c1?.foo" # type: ignore
- assert UnionState.c3.c2.c1r.foo._var_name == "c3?.c2?.c1r.foo" # type: ignore
- assert UnionState.c3.c2r.c1._var_name == "c3?.c2r.c1" # type: ignore
- assert UnionState.c3.c2r.c1.foo._var_name == "c3?.c2r.c1?.foo" # type: ignore
- assert UnionState.c3.c2r.c1r.foo._var_name == "c3?.c2r.c1r.foo" # type: ignore
- assert UnionState.c3i.c2._var_name == "c3i.c2" # type: ignore
- assert UnionState.c3r.c2._var_name == "c3r.c2" # type: ignore
+ assert str(UnionState.c3.c2) == f'{UnionState.c3!s}?.["c2"]' # type: ignore
+ assert str(UnionState.c3.c2.c1) == f'{UnionState.c3!s}?.["c2"]?.["c1"]' # type: ignore
+ assert (
+ str(UnionState.c3.c2.c1.foo) == f'{UnionState.c3!s}?.["c2"]?.["c1"]?.["foo"]' # type: ignore
+ )
+ assert (
+ str(UnionState.c3.c2.c1r.foo) == f'{UnionState.c3!s}?.["c2"]?.["c1r"]["foo"]' # type: ignore
+ )
+ assert str(UnionState.c3.c2r.c1) == f'{UnionState.c3!s}?.["c2r"]["c1"]' # type: ignore
+ assert (
+ str(UnionState.c3.c2r.c1.foo) == f'{UnionState.c3!s}?.["c2r"]["c1"]?.["foo"]' # type: ignore
+ )
+ assert (
+ str(UnionState.c3.c2r.c1r.foo) == f'{UnionState.c3!s}?.["c2r"]["c1r"]["foo"]' # type: ignore
+ )
+ assert str(UnionState.c3i.c2) == f'{UnionState.c3i!s}["c2"]' # type: ignore
+ assert str(UnionState.c3r.c2) == f'{UnionState.c3r!s}["c2"]' # type: ignore
assert UnionState.custom_union.foo is not None # type: ignore
assert UnionState.custom_union.c1 is not None # type: ignore
assert UnionState.custom_union.c1r is not None # type: ignore
@@ -2663,7 +2793,7 @@ def test_set_base_field_via_setter():
assert "c2" in bfss.dirty_vars
-def exp_is_hydrated(state: State, is_hydrated: bool = True) -> Dict[str, Any]:
+def exp_is_hydrated(state: BaseState, is_hydrated: bool = True) -> Dict[str, Any]:
"""Expected IS_HYDRATED delta that would be emitted by HydrateMiddleware.
Args:
@@ -2681,6 +2811,7 @@ class OnLoadState(State):
num: int = 0
+ @rx.event
def test_handler(self):
"""Test handler."""
self.num += 1
@@ -2741,7 +2872,8 @@ async def test_preprocess(app_module_mock, token, test_state, expected, mocker):
app = app_module_mock.app = App(
state=State, load_events={"index": [test_state.test_handler]}
)
- state = State()
+ async with app.state_manager.modify_state(_substate_key(token, State)) as state:
+ state.router_data = {"simulate": "hydrate"}
updates = []
async for update in rx.app.process(
@@ -2768,6 +2900,9 @@ async def test_preprocess(app_module_mock, token, test_state, expected, mocker):
}
assert (await state._process(events[1]).__anext__()).delta == exp_is_hydrated(state)
+ if isinstance(app.state_manager, StateManagerRedis):
+ await app.state_manager.close()
+
@pytest.mark.asyncio
async def test_preprocess_multiple_load_events(app_module_mock, token, mocker):
@@ -2785,7 +2920,8 @@ async def test_preprocess_multiple_load_events(app_module_mock, token, mocker):
state=State,
load_events={"index": [OnLoadState.test_handler, OnLoadState.test_handler]},
)
- state = State()
+ async with app.state_manager.modify_state(_substate_key(token, State)) as state:
+ state.router_data = {"simulate": "hydrate"}
updates = []
async for update in rx.app.process(
@@ -2815,6 +2951,9 @@ async def test_preprocess_multiple_load_events(app_module_mock, token, mocker):
}
assert (await state._process(events[2]).__anext__()).delta == exp_is_hydrated(state)
+ if isinstance(app.state_manager, StateManagerRedis):
+ await app.state_manager.close()
+
@pytest.mark.asyncio
async def test_get_state(mock_app: rx.App, token: str):
@@ -2831,7 +2970,7 @@ async def test_get_state(mock_app: rx.App, token: str):
_substate_key(token, ChildState2)
)
assert isinstance(test_state, TestState)
- if isinstance(mock_app.state_manager, StateManagerMemory):
+ if isinstance(mock_app.state_manager, (StateManagerMemory, StateManagerDisk)):
# All substates are available
assert tuple(sorted(test_state.substates)) == (
ChildState.get_name(),
@@ -2900,7 +3039,7 @@ async def test_get_state(mock_app: rx.App, token: str):
_substate_key(token, ChildState2)
)
assert isinstance(new_test_state, TestState)
- if isinstance(mock_app.state_manager, StateManagerMemory):
+ if isinstance(mock_app.state_manager, (StateManagerMemory, StateManagerDisk)):
# In memory, it's the same instance
assert new_test_state is test_state
test_state._clean()
@@ -3044,12 +3183,12 @@ def test_potentially_dirty_substates():
"""
class State(RxState):
- @ComputedVar
+ @computed_var
def foo(self) -> str:
return ""
class C1(State):
- @ComputedVar
+ @computed_var
def bar(self) -> str:
return ""
@@ -3058,6 +3197,51 @@ def test_potentially_dirty_substates():
assert C1._potentially_dirty_substates() == set()
+def test_router_var_dep() -> None:
+ """Test that router var dependencies are correctly tracked."""
+
+ class RouterVarParentState(State):
+ """A parent state for testing router var dependency."""
+
+ pass
+
+ class RouterVarDepState(RouterVarParentState):
+ """A state with a router var dependency."""
+
+ @rx.var(cache=True)
+ def foo(self) -> str:
+ return self.router.page.params.get("foo", "")
+
+ foo = RouterVarDepState.computed_vars["foo"]
+ State._init_var_dependency_dicts()
+
+ assert foo._deps(objclass=RouterVarDepState) == {"router"}
+ assert RouterVarParentState._potentially_dirty_substates() == {RouterVarDepState}
+ assert RouterVarParentState._substate_var_dependencies == {
+ "router": {RouterVarDepState.get_name()}
+ }
+ assert RouterVarDepState._computed_var_dependencies == {
+ "router": {"foo"},
+ }
+
+ rx_state = State()
+ parent_state = RouterVarParentState()
+ state = RouterVarDepState()
+
+ # link states
+ rx_state.substates = {RouterVarParentState.get_name(): parent_state}
+ parent_state.parent_state = rx_state
+ state.parent_state = parent_state
+ parent_state.substates = {RouterVarDepState.get_name(): state}
+
+ assert state.dirty_vars == set()
+
+ # Reassign router var
+ state.router = state.router
+ assert state.dirty_vars == {"foo", "router"}
+ assert parent_state.dirty_substates == {RouterVarDepState.get_name()}
+
+
@pytest.mark.asyncio
async def test_setvar(mock_app: rx.App, token: str):
"""Test that setvar works correctly.
@@ -3083,9 +3267,9 @@ async def test_setvar(mock_app: rx.App, token: str):
print(update)
assert state.array == [43]
- # Cannot setvar for non-existant var
+ # Cannot setvar for non-existent var
with pytest.raises(AttributeError):
- TestState.setvar("non_existant_var")
+ TestState.setvar("non_existent_var")
# Cannot setvar for computed vars
with pytest.raises(AttributeError):
@@ -3096,16 +3280,53 @@ async def test_setvar(mock_app: rx.App, token: str):
TestState.setvar(42, 42)
+@pytest.mark.asyncio
+async def test_setvar_async_setter():
+ """Test that overridden async setters raise Exception when used with setvar."""
+ with pytest.raises(NotImplementedError):
+ TestState.setvar("asynctest", 42)
+
+
@pytest.mark.skipif("REDIS_URL" not in os.environ, reason="Test requires redis")
@pytest.mark.parametrize(
"expiration_kwargs, expected_values",
[
- ({"redis_lock_expiration": 20000}, (20000, constants.Expiration.TOKEN)),
+ (
+ {"redis_lock_expiration": 20000},
+ (
+ 20000,
+ constants.Expiration.TOKEN,
+ constants.Expiration.LOCK_WARNING_THRESHOLD,
+ ),
+ ),
(
{"redis_lock_expiration": 50000, "redis_token_expiration": 5600},
- (50000, 5600),
+ (50000, 5600, constants.Expiration.LOCK_WARNING_THRESHOLD),
+ ),
+ (
+ {"redis_token_expiration": 7600},
+ (
+ constants.Expiration.LOCK,
+ 7600,
+ constants.Expiration.LOCK_WARNING_THRESHOLD,
+ ),
+ ),
+ (
+ {"redis_lock_expiration": 50000, "redis_lock_warning_threshold": 1500},
+ (50000, constants.Expiration.TOKEN, 1500),
+ ),
+ (
+ {"redis_token_expiration": 5600, "redis_lock_warning_threshold": 3000},
+ (constants.Expiration.LOCK, 5600, 3000),
+ ),
+ (
+ {
+ "redis_lock_expiration": 50000,
+ "redis_token_expiration": 5600,
+ "redis_lock_warning_threshold": 2000,
+ },
+ (50000, 5600, 2000),
),
- ({"redis_token_expiration": 7600}, (constants.Expiration.LOCK, 7600)),
],
)
def test_redis_state_manager_config_knobs(tmp_path, expiration_kwargs, expected_values):
@@ -3121,6 +3342,7 @@ import reflex as rx
config = rx.Config(
app_name="project1",
redis_url="redis://localhost:6379",
+ state_manager_mode="redis",
{config_items}
)
"""
@@ -3134,6 +3356,44 @@ config = rx.Config(
state_manager = StateManager.create(state=State)
assert state_manager.lock_expiration == expected_values[0] # type: ignore
assert state_manager.token_expiration == expected_values[1] # type: ignore
+ assert state_manager.lock_warning_threshold == expected_values[2] # type: ignore
+
+
+@pytest.mark.skipif("REDIS_URL" not in os.environ, reason="Test requires redis")
+@pytest.mark.parametrize(
+ "redis_lock_expiration, redis_lock_warning_threshold",
+ [
+ (10000, 10000),
+ (20000, 30000),
+ ],
+)
+def test_redis_state_manager_config_knobs_invalid_lock_warning_threshold(
+ tmp_path, redis_lock_expiration, redis_lock_warning_threshold
+):
+ proj_root = tmp_path / "project1"
+ proj_root.mkdir()
+
+ config_string = f"""
+import reflex as rx
+config = rx.Config(
+ app_name="project1",
+ redis_url="redis://localhost:6379",
+ state_manager_mode="redis",
+ redis_lock_expiration = {redis_lock_expiration},
+ redis_lock_warning_threshold = {redis_lock_warning_threshold},
+)
+ """
+
+ (proj_root / "rxconfig.py").write_text(dedent(config_string))
+
+ with chdir(proj_root):
+ # reload config for each parameter to avoid stale values
+ reflex.config.get_config(reload=True)
+ from reflex.state import State, StateManager
+
+ with pytest.raises(InvalidLockWarningThresholdError):
+ StateManager.create(state=State)
+ del sys.modules[constants.Config.MODULE]
class MixinState(State, mixin=True):
@@ -3141,6 +3401,16 @@ class MixinState(State, mixin=True):
num: int = 0
_backend: int = 0
+ _backend_no_default: dict
+
+ @rx.var(cache=True)
+ def computed(self) -> str:
+ """A computed var on mixin state.
+
+ Returns:
+ A computed value.
+ """
+ return ""
class UsesMixinState(MixinState, State):
@@ -3149,8 +3419,348 @@ class UsesMixinState(MixinState, State):
pass
+class ChildUsesMixinState(UsesMixinState):
+ """A child state that uses the mixin state."""
+
+ pass
+
+
def test_mixin_state() -> None:
"""Test that a mixin state works correctly."""
assert "num" in UsesMixinState.base_vars
assert "num" in UsesMixinState.vars
- assert UsesMixinState.backend_vars == {"_backend": 0}
+ assert UsesMixinState.backend_vars == {"_backend": 0, "_backend_no_default": {}}
+
+ assert "computed" in UsesMixinState.computed_vars
+ assert "computed" in UsesMixinState.vars
+
+ assert (
+ UsesMixinState(_reflex_internal_init=True)._backend_no_default # type: ignore
+ is not UsesMixinState.backend_vars["_backend_no_default"]
+ )
+
+
+def test_child_mixin_state() -> None:
+ """Test that mixin vars are only applied to the highest state in the hierarchy."""
+ assert "num" in ChildUsesMixinState.inherited_vars
+ assert "num" not in ChildUsesMixinState.base_vars
+
+ assert "computed" in ChildUsesMixinState.inherited_vars
+ assert "computed" not in ChildUsesMixinState.computed_vars
+
+
+def test_assignment_to_undeclared_vars():
+ """Test that an attribute error is thrown when undeclared vars are set."""
+
+ class State(BaseState):
+ val: str
+ _val: str
+ __val: str # type: ignore
+
+ def handle_supported_regular_vars(self):
+ self.val = "no underscore"
+ self._val = "single leading underscore"
+ self.__val = "double leading undercore"
+
+ def handle_regular_var(self):
+ self.num = 5
+
+ def handle_backend_var(self):
+ self._num = 5
+
+ def handle_non_var(self):
+ self.__num = 5
+
+ class Substate(State):
+ def handle_var(self):
+ self.value = 20
+
+ state = State() # type: ignore
+ sub_state = Substate() # type: ignore
+
+ with pytest.raises(SetUndefinedStateVarError):
+ state.handle_regular_var()
+
+ with pytest.raises(SetUndefinedStateVarError):
+ sub_state.handle_var()
+
+ with pytest.raises(SetUndefinedStateVarError):
+ state.handle_backend_var()
+
+ state.handle_supported_regular_vars()
+ state.handle_non_var()
+
+
+@pytest.mark.asyncio
+async def test_deserialize_gc_state_disk(token):
+ """Test that a state can be deserialized from disk with a grandchild state.
+
+ Args:
+ token: A token.
+ """
+
+ class Root(BaseState):
+ pass
+
+ class State(Root):
+ num: int = 42
+
+ class Child(State):
+ foo: str = "bar"
+
+ dsm = StateManagerDisk(state=Root)
+ async with dsm.modify_state(token) as root:
+ s = await root.get_state(State)
+ s.num += 1
+ c = await root.get_state(Child)
+ assert s._get_was_touched()
+ assert not c._get_was_touched()
+
+ dsm2 = StateManagerDisk(state=Root)
+ root = await dsm2.get_state(token)
+ s = await root.get_state(State)
+ assert s.num == 43
+ c = await root.get_state(Child)
+ assert c.foo == "bar"
+
+
+class Obj(Base):
+ """A object containing a callable for testing fallback pickle."""
+
+ _f: Callable
+
+
+def test_fallback_pickle():
+ """Test that state serialization will fall back to dill."""
+
+ class DillState(BaseState):
+ _o: Optional[Obj] = None
+ _f: Optional[Callable] = None
+ _g: Any = None
+
+ state = DillState(_reflex_internal_init=True) # type: ignore
+ state._o = Obj(_f=lambda: 42)
+ state._f = lambda: 420
+
+ pk = state._serialize()
+
+ unpickled_state = BaseState._deserialize(pk)
+ assert unpickled_state._f() == 420
+ assert unpickled_state._o._f() == 42
+
+ # Threading locks are unpicklable normally, and raise TypeError instead of PicklingError.
+ state2 = DillState(_reflex_internal_init=True) # type: ignore
+ state2._g = threading.Lock()
+ pk2 = state2._serialize()
+ unpickled_state2 = BaseState._deserialize(pk2)
+ assert isinstance(unpickled_state2._g, type(threading.Lock()))
+
+ # Some object, like generator, are still unpicklable with dill.
+ state3 = DillState(_reflex_internal_init=True) # type: ignore
+ state3._g = (i for i in range(10))
+
+ with pytest.raises(StateSerializationError):
+ _ = state3._serialize()
+
+
+def test_typed_state() -> None:
+ class TypedState(rx.State):
+ field: rx.Field[str] = rx.field("")
+
+ _ = TypedState(field="str")
+
+
+class ModelV1(BaseModelV1):
+ """A pydantic BaseModel v1."""
+
+ foo: str = "bar"
+
+
+class ModelV2(BaseModelV2):
+ """A pydantic BaseModel v2."""
+
+ foo: str = "bar"
+
+
+@dataclasses.dataclass
+class ModelDC:
+ """A dataclass."""
+
+ foo: str = "bar"
+
+
+class PydanticState(rx.State):
+ """A state with pydantic BaseModel vars."""
+
+ v1: ModelV1 = ModelV1()
+ v2: ModelV2 = ModelV2()
+ dc: ModelDC = ModelDC()
+
+
+def test_mutable_models():
+ """Test that dataclass and pydantic BaseModel v1 and v2 use dep tracking."""
+ state = PydanticState()
+ assert isinstance(state.v1, MutableProxy)
+ state.v1.foo = "baz"
+ assert state.dirty_vars == {"v1"}
+ state.dirty_vars.clear()
+
+ assert isinstance(state.v2, MutableProxy)
+ state.v2.foo = "baz"
+ assert state.dirty_vars == {"v2"}
+ state.dirty_vars.clear()
+
+ # Not yet supported ENG-4083
+ # assert isinstance(state.dc, MutableProxy) #noqa: ERA001
+ # state.dc.foo = "baz" #noqa: ERA001
+ # assert state.dirty_vars == {"dc"} #noqa: ERA001
+ # state.dirty_vars.clear() #noqa: ERA001
+
+
+def test_get_value():
+ class GetValueState(rx.State):
+ foo: str = "FOO"
+ bar: str = "BAR"
+
+ state = GetValueState()
+
+ assert state.dict() == {
+ state.get_full_name(): {
+ "foo": "FOO",
+ "bar": "BAR",
+ }
+ }
+ assert state.get_delta() == {}
+
+ state.bar = "foo"
+
+ assert state.dict() == {
+ state.get_full_name(): {
+ "foo": "FOO",
+ "bar": "foo",
+ }
+ }
+ assert state.get_delta() == {
+ state.get_full_name(): {
+ "bar": "foo",
+ }
+ }
+
+
+def test_init_mixin() -> None:
+ """Ensure that State mixins can not be instantiated directly."""
+
+ class Mixin(BaseState, mixin=True):
+ pass
+
+ with pytest.raises(ReflexRuntimeError):
+ Mixin()
+
+ class SubMixin(Mixin, mixin=True):
+ pass
+
+ with pytest.raises(ReflexRuntimeError):
+ SubMixin()
+
+
+class ReflexModel(rx.Model):
+ """A model for testing."""
+
+ foo: str
+
+
+class UpcastState(rx.State):
+ """A state for testing upcasting."""
+
+ passed: bool = False
+
+ def rx_model(self, m: ReflexModel): # noqa: D102
+ assert isinstance(m, ReflexModel)
+ self.passed = True
+
+ def rx_base(self, o: Object): # noqa: D102
+ assert isinstance(o, Object)
+ self.passed = True
+
+ def rx_base_or_none(self, o: Optional[Object]): # noqa: D102
+ if o is not None:
+ assert isinstance(o, Object)
+ self.passed = True
+
+ def rx_basemodelv1(self, m: ModelV1): # noqa: D102
+ assert isinstance(m, ModelV1)
+ self.passed = True
+
+ def rx_basemodelv2(self, m: ModelV2): # noqa: D102
+ assert isinstance(m, ModelV2)
+ self.passed = True
+
+ def rx_dataclass(self, dc: ModelDC): # noqa: D102
+ assert isinstance(dc, ModelDC)
+ self.passed = True
+
+ def py_set(self, s: set): # noqa: D102
+ assert isinstance(s, set)
+ self.passed = True
+
+ def py_Set(self, s: Set): # noqa: D102
+ assert isinstance(s, Set)
+ self.passed = True
+
+ def py_tuple(self, t: tuple): # noqa: D102
+ assert isinstance(t, tuple)
+ self.passed = True
+
+ def py_Tuple(self, t: Tuple): # noqa: D102
+ assert isinstance(t, tuple)
+ self.passed = True
+
+ def py_dict(self, d: dict[str, str]): # noqa: D102
+ assert isinstance(d, dict)
+ self.passed = True
+
+ def py_list(self, ls: list[str]): # noqa: D102
+ assert isinstance(ls, list)
+ self.passed = True
+
+ def py_Any(self, a: Any): # noqa: D102
+ assert isinstance(a, list)
+ self.passed = True
+
+ def py_unresolvable(self, u: "Unresolvable"): # noqa: D102, F821 # type: ignore
+ assert isinstance(u, list)
+ self.passed = True
+
+
+@pytest.mark.asyncio
+@pytest.mark.usefixtures("mock_app_simple")
+@pytest.mark.parametrize(
+ ("handler", "payload"),
+ [
+ (UpcastState.rx_model, {"m": {"foo": "bar"}}),
+ (UpcastState.rx_base, {"o": {"foo": "bar"}}),
+ (UpcastState.rx_base_or_none, {"o": {"foo": "bar"}}),
+ (UpcastState.rx_base_or_none, {"o": None}),
+ (UpcastState.rx_basemodelv1, {"m": {"foo": "bar"}}),
+ (UpcastState.rx_basemodelv2, {"m": {"foo": "bar"}}),
+ (UpcastState.rx_dataclass, {"dc": {"foo": "bar"}}),
+ (UpcastState.py_set, {"s": ["foo", "foo"]}),
+ (UpcastState.py_Set, {"s": ["foo", "foo"]}),
+ (UpcastState.py_tuple, {"t": ["foo", "foo"]}),
+ (UpcastState.py_Tuple, {"t": ["foo", "foo"]}),
+ (UpcastState.py_dict, {"d": {"foo": "bar"}}),
+ (UpcastState.py_list, {"ls": ["foo", "foo"]}),
+ (UpcastState.py_Any, {"a": ["foo"]}),
+ (UpcastState.py_unresolvable, {"u": ["foo"]}),
+ ],
+)
+async def test_upcast_event_handler_arg(handler, payload):
+ """Test that upcast event handler args work correctly.
+
+ Args:
+ handler: The handler to test.
+ payload: The payload to test.
+ """
+ state = UpcastState()
+ async for update in state._process_event(handler, state, payload):
+ assert update.delta == {UpcastState.get_full_name(): {"passed": True}}
diff --git a/tests/test_state_tree.py b/tests/units/test_state_tree.py
similarity index 97%
rename from tests/test_state_tree.py
rename to tests/units/test_state_tree.py
index 7c1e13a91..ebdd877de 100644
--- a/tests/test_state_tree.py
+++ b/tests/units/test_state_tree.py
@@ -1,9 +1,9 @@
"""Specialized test for a larger state tree."""
-import asyncio
-from typing import Generator
+from typing import AsyncGenerator
import pytest
+import pytest_asyncio
import reflex as rx
from reflex.state import BaseState, StateManager, StateManagerRedis, _substate_key
@@ -210,8 +210,10 @@ ALWAYS_COMPUTED_DICT_KEYS = [
]
-@pytest.fixture(scope="function")
-def state_manager_redis(app_module_mock) -> Generator[StateManager, None, None]:
+@pytest_asyncio.fixture(loop_scope="function", scope="function")
+async def state_manager_redis(
+ app_module_mock,
+) -> AsyncGenerator[StateManager, None]:
"""Instance of state manager for redis only.
Args:
@@ -228,7 +230,7 @@ def state_manager_redis(app_module_mock) -> Generator[StateManager, None, None]:
yield state_manager
- asyncio.get_event_loop().run_until_complete(state_manager.close())
+ await state_manager.close()
@pytest.mark.asyncio
diff --git a/tests/test_style.py b/tests/units/test_style.py
similarity index 87%
rename from tests/test_style.py
rename to tests/units/test_style.py
index 825d72a9d..e1d652798 100644
--- a/tests/test_style.py
+++ b/tests/units/test_style.py
@@ -1,6 +1,6 @@
from __future__ import annotations
-from typing import Any
+from typing import Any, Dict
import pytest
@@ -8,21 +8,22 @@ import reflex as rx
from reflex import style
from reflex.components.component import evaluate_style_namespaces
from reflex.style import Style
-from reflex.vars import Var, VarData
+from reflex.vars import VarData
+from reflex.vars.base import LiteralVar, Var
test_style = [
({"a": 1}, {"a": 1}),
- ({"a": Var.create("abc")}, {"a": "abc"}),
+ ({"a": LiteralVar.create("abc")}, {"a": "abc"}),
({"test_case": 1}, {"testCase": 1}),
- ({"test_case": {"a": 1}}, {"testCase": {"a": 1}}),
- ({":test_case": {"a": 1}}, {":testCase": {"a": 1}}),
- ({"::test_case": {"a": 1}}, {"::testCase": {"a": 1}}),
+ ({"test_case": {"a": 1}}, {"test_case": {"a": 1}}),
+ ({":test_case": {"a": 1}}, {":test_case": {"a": 1}}),
+ ({"::test_case": {"a": 1}}, {"::test_case": {"a": 1}}),
(
{"::-webkit-scrollbar": {"display": "none"}},
{"::-webkit-scrollbar": {"display": "none"}},
),
- ({"margin_y": "2rem"}, {"marginBottom": "2rem", "marginTop": "2rem"}),
- ({"marginY": "2rem"}, {"marginBottom": "2rem", "marginTop": "2rem"}),
+ ({"margin_y": "2rem"}, {"marginTop": "2rem", "marginBottom": "2rem"}),
+ ({"marginY": "2rem"}, {"marginTop": "2rem", "marginBottom": "2rem"}),
(
{"::-webkit-scrollbar": {"bgColor": "red"}},
{"::-webkit-scrollbar": {"backgroundColor": "red"}},
@@ -49,7 +50,7 @@ def test_convert(style_dict, expected):
expected: The expected formatted style.
"""
converted_dict, _var_data = style.convert(style_dict)
- assert converted_dict == expected
+ assert LiteralVar.create(converted_dict).equals(LiteralVar.create(expected))
@pytest.mark.parametrize(
@@ -63,7 +64,9 @@ def test_create_style(style_dict, expected):
style_dict: The style to check.
expected: The expected formatted style.
"""
- assert style.Style(style_dict) == expected
+ assert LiteralVar.create(style.Style(style_dict)).equals(
+ LiteralVar.create(expected)
+ )
def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]):
@@ -87,39 +90,47 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]):
@pytest.mark.parametrize(
("kwargs", "style_dict", "expected_get_style"),
[
- ({}, {}, {"css": None}),
- ({"color": "hotpink"}, {}, {"css": Var.create(Style({"color": "hotpink"}))}),
- ({}, {"color": "red"}, {"css": Var.create(Style({"color": "red"}))}),
+ ({}, {}, {}),
+ (
+ {"color": "hotpink"},
+ {},
+ {"css": LiteralVar.create(Style({"color": "hotpink"}))},
+ ),
+ ({}, {"color": "red"}, {"css": LiteralVar.create(Style({"color": "red"}))}),
(
{"color": "hotpink"},
{"color": "red"},
- {"css": Var.create(Style({"color": "hotpink"}))},
+ {"css": LiteralVar.create(Style({"color": "hotpink"}))},
),
(
{"_hover": {"color": "hotpink"}},
{},
- {"css": Var.create(Style({"&:hover": {"color": "hotpink"}}))},
+ {"css": LiteralVar.create(Style({"&:hover": {"color": "hotpink"}}))},
),
(
{},
{"_hover": {"color": "red"}},
- {"css": Var.create(Style({"&:hover": {"color": "red"}}))},
+ {"css": LiteralVar.create(Style({"&:hover": {"color": "red"}}))},
),
(
{},
{":hover": {"color": "red"}},
- {"css": Var.create(Style({"&:hover": {"color": "red"}}))},
+ {"css": LiteralVar.create(Style({"&:hover": {"color": "red"}}))},
),
(
{},
{"::-webkit-scrollbar": {"display": "none"}},
- {"css": Var.create(Style({"&::-webkit-scrollbar": {"display": "none"}}))},
+ {
+ "css": LiteralVar.create(
+ Style({"&::-webkit-scrollbar": {"display": "none"}})
+ )
+ },
),
(
{},
{"::-moz-progress-bar": {"background_color": "red"}},
{
- "css": Var.create(
+ "css": LiteralVar.create(
Style({"&::-moz-progress-bar": {"backgroundColor": "red"}})
)
},
@@ -128,7 +139,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]):
{"color": ["#111", "#222", "#333", "#444", "#555"]},
{},
{
- "css": Var.create(
+ "css": LiteralVar.create(
Style(
{
"@media screen and (min-width: 0)": {"color": "#111"},
@@ -148,7 +159,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]):
},
{},
{
- "css": Var.create(
+ "css": LiteralVar.create(
Style(
{
"@media screen and (min-width: 0)": {"color": "#111"},
@@ -169,7 +180,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]):
},
{},
{
- "css": Var.create(
+ "css": LiteralVar.create(
Style(
{
"@media screen and (min-width: 0)": {
@@ -209,7 +220,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]):
},
{},
{
- "css": Var.create(
+ "css": LiteralVar.create(
Style(
{
"&:hover": {
@@ -236,7 +247,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]):
{"_hover": {"color": ["#111", "#222", "#333", "#444", "#555"]}},
{},
{
- "css": Var.create(
+ "css": LiteralVar.create(
Style(
{
"&:hover": {
@@ -268,7 +279,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]):
},
{},
{
- "css": Var.create(
+ "css": LiteralVar.create(
Style(
{
"&:hover": {
@@ -307,7 +318,7 @@ def compare_dict_of_var(d1: dict[str, Any], d2: dict[str, Any]):
},
{},
{
- "css": Var.create(
+ "css": LiteralVar.create(
Style(
{
"&:hover": {
@@ -361,20 +372,20 @@ class StyleState(rx.State):
[
(
{"color": StyleState.color},
- {"css": Var.create(Style({"color": StyleState.color}))},
+ {"css": LiteralVar.create(Style({"color": StyleState.color}))},
),
(
{"color": f"dark{StyleState.color}"},
{
- "css": Var.create_safe(f'{{"color": `dark{StyleState.color}`}}').to(
- Style
- )
+ "css": Var(
+ _js_expr=f'({{ ["color"] : ("dark"+{StyleState.color}) }})'
+ ).to(Dict[str, str])
},
),
(
{"color": StyleState.color, "_hover": {"color": StyleState.color2}},
{
- "css": Var.create(
+ "css": LiteralVar.create(
Style(
{
"color": StyleState.color,
@@ -387,7 +398,7 @@ class StyleState(rx.State):
(
{"color": [StyleState.color, "gray", StyleState.color2, "yellow", "blue"]},
{
- "css": Var.create(
+ "css": LiteralVar.create(
Style(
{
"@media screen and (min-width: 0)": {
@@ -415,7 +426,7 @@ class StyleState(rx.State):
]
},
{
- "css": Var.create(
+ "css": LiteralVar.create(
Style(
{
"&:hover": {
@@ -453,7 +464,7 @@ class StyleState(rx.State):
}
},
{
- "css": Var.create(
+ "css": LiteralVar.create(
Style(
{
"&:hover": {
@@ -492,7 +503,10 @@ def test_style_via_component_with_state(
"""
comp = rx.el.div(**kwargs)
- assert comp.style._var_data == expected_get_style["css"]._var_data
+ assert (
+ VarData.merge(comp.style._var_data)
+ == expected_get_style["css"]._get_all_var_data()
+ )
# Assert that style values are equal.
compare_dict_of_var(comp._get_style(), expected_get_style)
@@ -507,10 +521,10 @@ def test_evaluate_style_namespaces():
def test_style_update_with_var_data():
"""Test that .update with a Style containing VarData works."""
- red_var = Var.create_safe("red")._replace(
+ red_var = LiteralVar.create("red")._replace(
merge_var_data=VarData(hooks={"const red = true": None}), # type: ignore
)
- blue_var = Var.create_safe("blue", _var_is_local=False)._replace(
+ blue_var = LiteralVar.create("blue")._replace(
merge_var_data=VarData(hooks={"const blue = true": None}), # type: ignore
)
@@ -521,7 +535,9 @@ def test_style_update_with_var_data():
)
s2 = Style()
s2.update(s1, background_color=f"{blue_var}ish")
- assert s2 == {"color": "red", "backgroundColor": "`${blue}ish`"}
+ assert str(LiteralVar.create(s2)) == str(
+ LiteralVar.create({"color": "red", "backgroundColor": "blueish"})
+ )
assert s2._var_data is not None
assert "const red = true" in s2._var_data.hooks
assert "const blue = true" in s2._var_data.hooks
diff --git a/tests/test_telemetry.py b/tests/units/test_telemetry.py
similarity index 87%
rename from tests/test_telemetry.py
rename to tests/units/test_telemetry.py
index a434779d4..d8a77dfd6 100644
--- a/tests/test_telemetry.py
+++ b/tests/units/test_telemetry.py
@@ -34,12 +34,6 @@ def test_disable():
@pytest.mark.parametrize("event", ["init", "reinit", "run-dev", "run-prod", "export"])
def test_send(mocker, event):
httpx_post_mock = mocker.patch("httpx.post")
- # mocker.patch(
- # "builtins.open",
- # mocker.mock_open(
- # read_data='{"project_hash": "78285505863498957834586115958872998605"}'
- # ),
- # )
# Mock the read_text method of Path
pathlib_path_read_text_mock = mocker.patch(
@@ -52,4 +46,4 @@ def test_send(mocker, event):
telemetry._send(event, telemetry_enabled=True)
httpx_post_mock.assert_called_once()
- pathlib_path_read_text_mock.assert_called_once()
+ assert pathlib_path_read_text_mock.call_count == 2
diff --git a/tests/test_testing.py b/tests/units/test_testing.py
similarity index 95%
rename from tests/test_testing.py
rename to tests/units/test_testing.py
index b01709202..83a03ad83 100644
--- a/tests/test_testing.py
+++ b/tests/units/test_testing.py
@@ -29,7 +29,7 @@ def test_app_harness(tmp_path):
with AppHarness.create(
root=tmp_path,
- app_source=BasicApp, # type: ignore
+ app_source=BasicApp,
) as harness:
assert harness.app_instance is not None
assert harness.backend is not None
diff --git a/tests/test_var.py b/tests/units/test_var.py
similarity index 52%
rename from tests/test_var.py
rename to tests/units/test_var.py
index 5c67d9924..bfa8aa35a 100644
--- a/tests/test_var.py
+++ b/tests/units/test_var.py
@@ -1,50 +1,47 @@
import json
import math
+import sys
import typing
-from typing import Dict, List, Set, Tuple, Union
+from typing import Dict, List, Optional, Set, Tuple, Union, cast
import pytest
from pandas import DataFrame
+import reflex as rx
from reflex.base import Base
from reflex.constants.base import REFLEX_VAR_CLOSING_TAG, REFLEX_VAR_OPENING_TAG
-from reflex.experimental.vars.base import (
- ImmutableVar,
+from reflex.state import BaseState
+from reflex.utils.exceptions import PrimitiveUnserializableToJSON
+from reflex.utils.imports import ImportVar
+from reflex.vars import VarData
+from reflex.vars.base import (
+ ComputedVar,
LiteralVar,
+ Var,
+ computed_var,
var_operation,
+ var_operation_return,
)
-from reflex.experimental.vars.function import ArgsFunctionOperation, FunctionStringVar
-from reflex.experimental.vars.number import (
- LiteralBooleanVar,
- LiteralNumberVar,
- NumberVar,
+from reflex.vars.function import (
+ ArgsFunctionOperation,
+ DestructuredArg,
+ FunctionStringVar,
)
-from reflex.experimental.vars.object import LiteralObjectVar
-from reflex.experimental.vars.sequence import (
+from reflex.vars.number import LiteralBooleanVar, LiteralNumberVar, NumberVar
+from reflex.vars.object import LiteralObjectVar, ObjectVar
+from reflex.vars.sequence import (
ArrayVar,
ConcatVarOperation,
LiteralArrayVar,
LiteralStringVar,
)
-from reflex.state import BaseState
-from reflex.utils.imports import ImportVar
-from reflex.vars import (
- BaseVar,
- ComputedVar,
- ImmutableVarData,
- Var,
- VarData,
- computed_var,
-)
test_vars = [
- BaseVar(_var_name="prop1", _var_type=int),
- BaseVar(_var_name="key", _var_type=str),
- BaseVar(_var_name="value", _var_type=str)._var_set_state("state"),
- BaseVar(_var_name="local", _var_type=str, _var_is_local=True)._var_set_state(
- "state"
- ),
- BaseVar(_var_name="local2", _var_type=str, _var_is_local=True),
+ Var(_js_expr="prop1", _var_type=int),
+ Var(_js_expr="key", _var_type=str),
+ Var(_js_expr="value", _var_type=str)._var_set_state("state"),
+ Var(_js_expr="local", _var_type=str)._var_set_state("state"),
+ Var(_js_expr="local2", _var_type=str),
]
@@ -82,6 +79,11 @@ def ChildState(ParentState, TestObj):
class ChildState(ParentState):
@computed_var
def var_without_annotation(self):
+ """This shadows ParentState.var_without_annotation.
+
+ Returns:
+ TestObj: Test object.
+ """
return TestObj
return ChildState
@@ -92,6 +94,11 @@ def GrandChildState(ChildState, TestObj):
class GrandChildState(ChildState):
@computed_var
def var_without_annotation(self):
+ """This shadows ChildState.var_without_annotation.
+
+ Returns:
+ TestObj: Test object.
+ """
return TestObj
return GrandChildState
@@ -187,14 +194,14 @@ def test_full_name(prop, expected):
prop: The var to test.
expected: The expected full name.
"""
- assert prop._var_full_name == expected
+ assert str(prop) == expected
@pytest.mark.parametrize(
"prop,expected",
zip(
test_vars,
- ["{prop1}", "{key}", "{state.value}", "state.local", "local2"],
+ ["prop1", "key", "state.value", "state.local", "local2"],
),
)
def test_str(prop, expected):
@@ -208,26 +215,26 @@ def test_str(prop, expected):
@pytest.mark.parametrize(
- "prop,expected",
+ ("prop", "expected"),
[
- (BaseVar(_var_name="p", _var_type=int), 0),
- (BaseVar(_var_name="p", _var_type=float), 0.0),
- (BaseVar(_var_name="p", _var_type=str), ""),
- (BaseVar(_var_name="p", _var_type=bool), False),
- (BaseVar(_var_name="p", _var_type=list), []),
- (BaseVar(_var_name="p", _var_type=dict), {}),
- (BaseVar(_var_name="p", _var_type=tuple), ()),
- (BaseVar(_var_name="p", _var_type=set), set()),
+ (Var(_js_expr="p", _var_type=int), 0),
+ (Var(_js_expr="p", _var_type=float), 0.0),
+ (Var(_js_expr="p", _var_type=str), ""),
+ (Var(_js_expr="p", _var_type=bool), False),
+ (Var(_js_expr="p", _var_type=list), []),
+ (Var(_js_expr="p", _var_type=dict), {}),
+ (Var(_js_expr="p", _var_type=tuple), ()),
+ (Var(_js_expr="p", _var_type=set), set()),
],
)
-def test_default_value(prop, expected):
+def test_default_value(prop: Var, expected):
"""Test that the default value of a var is correct.
Args:
prop: The var to test.
expected: The expected default value.
"""
- assert prop.get_default_value() == expected
+ assert prop._get_default_value() == expected
@pytest.mark.parametrize(
@@ -243,27 +250,27 @@ def test_default_value(prop, expected):
],
),
)
-def test_get_setter(prop, expected):
+def test_get_setter(prop: Var, expected):
"""Test that the name of the setter function of a var is correct.
Args:
prop: The var to test.
expected: The expected name of the setter function.
"""
- assert prop.get_setter_name() == expected
+ assert prop._get_setter_name() == expected
@pytest.mark.parametrize(
"value,expected",
[
- (None, None),
- (1, BaseVar(_var_name="1", _var_type=int, _var_is_local=True)),
- ("key", BaseVar(_var_name="key", _var_type=str, _var_is_local=True)),
- (3.14, BaseVar(_var_name="3.14", _var_type=float, _var_is_local=True)),
- ([1, 2, 3], BaseVar(_var_name="[1, 2, 3]", _var_type=list, _var_is_local=True)),
+ (None, Var(_js_expr="null", _var_type=None)),
+ (1, Var(_js_expr="1", _var_type=int)),
+ ("key", Var(_js_expr='"key"', _var_type=str)),
+ (3.14, Var(_js_expr="3.14", _var_type=float)),
+ ([1, 2, 3], Var(_js_expr="[1, 2, 3]", _var_type=List[int])),
(
{"a": 1, "b": 2},
- BaseVar(_var_name='{"a": 1, "b": 2}', _var_type=dict, _var_is_local=True),
+ Var(_js_expr='({ ["a"] : 1, ["b"] : 2 })', _var_type=Dict[str, int]),
),
],
)
@@ -274,11 +281,8 @@ def test_create(value, expected):
value: The value to create a var from.
expected: The expected name of the setter function.
"""
- prop = Var.create(value)
- if value is None:
- assert prop == expected
- else:
- assert prop.equals(expected) # type: ignore
+ prop = LiteralVar.create(value)
+ assert prop.equals(expected) # type: ignore
def test_create_type_error():
@@ -290,17 +294,11 @@ def test_create_type_error():
value = ErrorType()
with pytest.raises(TypeError):
- Var.create(value)
+ LiteralVar.create(value)
def v(value) -> Var:
- val = (
- Var.create(json.dumps(value), _var_is_string=True, _var_is_local=False)
- if isinstance(value, str)
- else Var.create(value, _var_is_local=False)
- )
- assert val is not None
- return val
+ return LiteralVar.create(value)
def test_basic_operations(TestObj):
@@ -309,208 +307,184 @@ def test_basic_operations(TestObj):
Args:
TestObj: The test object.
"""
- assert str(v(1) == v(2)) == "{((1) === (2))}"
- assert str(v(1) != v(2)) == "{((1) !== (2))}"
- assert str(v(1) < v(2)) == "{((1) < (2))}"
- assert str(v(1) <= v(2)) == "{((1) <= (2))}"
- assert str(v(1) > v(2)) == "{((1) > (2))}"
- assert str(v(1) >= v(2)) == "{((1) >= (2))}"
- assert str(v(1) + v(2)) == "{((1) + (2))}"
- assert str(v(1) - v(2)) == "{((1) - (2))}"
- assert str(v(1) * v(2)) == "{((1) * (2))}"
- assert str(v(1) / v(2)) == "{((1) / (2))}"
- assert str(v(1) // v(2)) == "{Math.floor((1) / (2))}"
- assert str(v(1) % v(2)) == "{((1) % (2))}"
- assert str(v(1) ** v(2)) == "{Math.pow((1) , (2))}"
- assert str(v(1) & v(2)) == "{((1) && (2))}"
- assert str(v(1) | v(2)) == "{((1) || (2))}"
- assert str(v([1, 2, 3])[v(0)]) == "{[1, 2, 3].at(0)}"
- assert str(v({"a": 1, "b": 2})["a"]) == '{{"a": 1, "b": 2}["a"]}'
- assert str(v("foo") == v("bar")) == '{(("foo") === ("bar"))}'
+ assert str(v(1) == v(2)) == "(1 === 2)"
+ assert str(v(1) != v(2)) == "(1 !== 2)"
+ assert str(LiteralNumberVar.create(1) < 2) == "(1 < 2)"
+ assert str(LiteralNumberVar.create(1) <= 2) == "(1 <= 2)"
+ assert str(LiteralNumberVar.create(1) > 2) == "(1 > 2)"
+ assert str(LiteralNumberVar.create(1) >= 2) == "(1 >= 2)"
+ assert str(LiteralNumberVar.create(1) + 2) == "(1 + 2)"
+ assert str(LiteralNumberVar.create(1) - 2) == "(1 - 2)"
+ assert str(LiteralNumberVar.create(1) * 2) == "(1 * 2)"
+ assert str(LiteralNumberVar.create(1) / 2) == "(1 / 2)"
+ assert str(LiteralNumberVar.create(1) // 2) == "Math.floor(1 / 2)"
+ assert str(LiteralNumberVar.create(1) % 2) == "(1 % 2)"
+ assert str(LiteralNumberVar.create(1) ** 2) == "(1 ** 2)"
+ assert str(LiteralNumberVar.create(1) & v(2)) == "(1 && 2)"
+ assert str(LiteralNumberVar.create(1) | v(2)) == "(1 || 2)"
+ assert str(LiteralArrayVar.create([1, 2, 3])[0]) == "[1, 2, 3].at(0)"
+ assert (
+ str(LiteralObjectVar.create({"a": 1, "b": 2})["a"])
+ == '({ ["a"] : 1, ["b"] : 2 })["a"]'
+ )
+ assert str(v("foo") == v("bar")) == '("foo" === "bar")'
+ assert str(Var(_js_expr="foo") == Var(_js_expr="bar")) == "(foo === bar)"
+ assert (
+ str(LiteralVar.create("foo") == LiteralVar.create("bar")) == '("foo" === "bar")'
+ )
+ print(Var(_js_expr="foo").to(ObjectVar, TestObj)._var_set_state("state"))
assert (
str(
- Var.create("foo", _var_is_local=False)
- == Var.create("bar", _var_is_local=False)
+ Var(_js_expr="foo").to(ObjectVar, TestObj)._var_set_state("state").bar
+ == LiteralVar.create("bar")
)
- == "{((foo) === (bar))}"
+ == '(state.foo["bar"] === "bar")'
)
assert (
- str(
- BaseVar(
- _var_name="foo", _var_type=str, _var_is_string=True, _var_is_local=True
- )
- == BaseVar(
- _var_name="bar", _var_type=str, _var_is_string=True, _var_is_local=True
- )
- )
- == "((`foo`) === (`bar`))"
+ str(Var(_js_expr="foo").to(ObjectVar, TestObj)._var_set_state("state").bar)
+ == 'state.foo["bar"]'
)
+ assert str(abs(LiteralNumberVar.create(1))) == "Math.abs(1)"
+ assert str(LiteralArrayVar.create([1, 2, 3]).length()) == "[1, 2, 3].length"
assert (
- str(
- BaseVar(
- _var_name="foo",
- _var_type=TestObj,
- _var_is_string=True,
- _var_is_local=False,
- )
- ._var_set_state("state")
- .bar
- == BaseVar(
- _var_name="bar", _var_type=str, _var_is_string=True, _var_is_local=True
- )
- )
- == "{((state.foo.bar) === (`bar`))}"
+ str(LiteralArrayVar.create([1, 2]) + LiteralArrayVar.create([3, 4]))
+ == "[...[1, 2], ...[3, 4]]"
)
- assert (
- str(BaseVar(_var_name="foo", _var_type=TestObj)._var_set_state("state").bar)
- == "{state.foo.bar}"
- )
- assert str(abs(v(1))) == "{Math.abs(1)}"
- assert str(v([1, 2, 3]).length()) == "{[1, 2, 3].length}"
- assert str(v([1, 2]) + v([3, 4])) == "{spreadArraysOrObjects(([1, 2]) , ([3, 4]))}"
# Tests for reverse operation
- assert str(v([1, 2, 3]).reverse()) == "{[...[1, 2, 3]].reverse()}"
- assert str(v(["1", "2", "3"]).reverse()) == '{[...["1", "2", "3"]].reverse()}'
assert (
- str(BaseVar(_var_name="foo", _var_type=list)._var_set_state("state").reverse())
- == "{[...state.foo].reverse()}"
+ str(LiteralArrayVar.create([1, 2, 3]).reverse())
+ == "[1, 2, 3].slice().reverse()"
)
assert (
- str(BaseVar(_var_name="foo", _var_type=list).reverse())
- == "{[...foo].reverse()}"
- )
- assert str(BaseVar(_var_name="foo", _var_type=str)._type()) == "{typeof foo}" # type: ignore
- assert (
- str(BaseVar(_var_name="foo", _var_type=str)._type() == str) # type: ignore
- == "{((typeof foo) === (`string`))}"
+ str(LiteralArrayVar.create(["1", "2", "3"]).reverse())
+ == '["1", "2", "3"].slice().reverse()'
)
assert (
- str(BaseVar(_var_name="foo", _var_type=str)._type() == str) # type: ignore
- == "{((typeof foo) === (`string`))}"
- )
- assert (
- str(BaseVar(_var_name="foo", _var_type=str)._type() == int) # type: ignore
- == "{((typeof foo) === (`number`))}"
- )
- assert (
- str(BaseVar(_var_name="foo", _var_type=str)._type() == list) # type: ignore
- == "{((typeof foo) === (`Array`))}"
- )
- assert (
- str(BaseVar(_var_name="foo", _var_type=str)._type() == float) # type: ignore
- == "{((typeof foo) === (`number`))}"
- )
- assert (
- str(BaseVar(_var_name="foo", _var_type=str)._type() == tuple) # type: ignore
- == "{((typeof foo) === (`Array`))}"
- )
- assert (
- str(BaseVar(_var_name="foo", _var_type=str)._type() == dict) # type: ignore
- == "{((typeof foo) === (`Object`))}"
- )
- assert (
- str(BaseVar(_var_name="foo", _var_type=str)._type() != str) # type: ignore
- == "{((typeof foo) !== (`string`))}"
- )
- assert (
- str(BaseVar(_var_name="foo", _var_type=str)._type() != int) # type: ignore
- == "{((typeof foo) !== (`number`))}"
- )
- assert (
- str(BaseVar(_var_name="foo", _var_type=str)._type() != list) # type: ignore
- == "{((typeof foo) !== (`Array`))}"
- )
- assert (
- str(BaseVar(_var_name="foo", _var_type=str)._type() != float) # type: ignore
- == "{((typeof foo) !== (`number`))}"
- )
- assert (
- str(BaseVar(_var_name="foo", _var_type=str)._type() != tuple) # type: ignore
- == "{((typeof foo) !== (`Array`))}"
- )
- assert (
- str(BaseVar(_var_name="foo", _var_type=str)._type() != dict) # type: ignore
- == "{((typeof foo) !== (`Object`))}"
+ str(Var(_js_expr="foo")._var_set_state("state").to(list).reverse())
+ == "state.foo.slice().reverse()"
)
+ assert str(Var(_js_expr="foo").to(list).reverse()) == "foo.slice().reverse()"
+ assert str(Var(_js_expr="foo", _var_type=str).js_type()) == "(typeof(foo))"
@pytest.mark.parametrize(
"var, expected",
[
(v([1, 2, 3]), "[1, 2, 3]"),
- (v(set([1, 2, 3])), "[1, 2, 3]"),
+ (v({1, 2, 3}), "[1, 2, 3]"),
(v(["1", "2", "3"]), '["1", "2", "3"]'),
- (BaseVar(_var_name="foo", _var_type=list)._var_set_state("state"), "state.foo"),
- (BaseVar(_var_name="foo", _var_type=list), "foo"),
+ (
+ Var(_js_expr="foo")._var_set_state("state").to(list),
+ "state.foo",
+ ),
+ (Var(_js_expr="foo").to(list), "foo"),
(v((1, 2, 3)), "[1, 2, 3]"),
(v(("1", "2", "3")), '["1", "2", "3"]'),
(
- BaseVar(_var_name="foo", _var_type=tuple)._var_set_state("state"),
+ Var(_js_expr="foo")._var_set_state("state").to(tuple),
"state.foo",
),
- (BaseVar(_var_name="foo", _var_type=tuple), "foo"),
+ (Var(_js_expr="foo").to(tuple), "foo"),
],
)
def test_list_tuple_contains(var, expected):
- assert str(var.contains(1)) == f"{{{expected}.includes(1)}}"
- assert str(var.contains("1")) == f'{{{expected}.includes("1")}}'
- assert str(var.contains(v(1))) == f"{{{expected}.includes(1)}}"
- assert str(var.contains(v("1"))) == f'{{{expected}.includes("1")}}'
- other_state_var = BaseVar(_var_name="other", _var_type=str)._var_set_state("state")
- other_var = BaseVar(_var_name="other", _var_type=str)
- assert str(var.contains(other_state_var)) == f"{{{expected}.includes(state.other)}}"
- assert str(var.contains(other_var)) == f"{{{expected}.includes(other)}}"
+ assert str(var.contains(1)) == f"{expected}.includes(1)"
+ assert str(var.contains("1")) == f'{expected}.includes("1")'
+ assert str(var.contains(v(1))) == f"{expected}.includes(1)"
+ assert str(var.contains(v("1"))) == f'{expected}.includes("1")'
+ other_state_var = Var(_js_expr="other", _var_type=str)._var_set_state("state")
+ other_var = Var(_js_expr="other", _var_type=str)
+ assert str(var.contains(other_state_var)) == f"{expected}.includes(state.other)"
+ assert str(var.contains(other_var)) == f"{expected}.includes(other)"
+
+
+class Foo(rx.Base):
+ """Foo class."""
+
+ bar: int
+ baz: str
+
+
+class Bar(rx.Base):
+ """Bar class."""
+
+ bar: str
+ baz: str
+ foo: int
+
+
+@pytest.mark.parametrize(
+ ("var", "var_type"),
+ (
+ [
+ (Var(_js_expr="", _var_type=Foo | Bar).guess_type(), Foo | Bar),
+ (Var(_js_expr="", _var_type=Foo | Bar).guess_type().bar, Union[int, str]),
+ ]
+ if sys.version_info >= (3, 10)
+ else []
+ )
+ + [
+ (Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type(), Union[Foo, Bar]),
+ (Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type().baz, str),
+ (
+ Var(_js_expr="", _var_type=Union[Foo, Bar]).guess_type().foo,
+ Union[int, None],
+ ),
+ ],
+)
+def test_var_types(var, var_type):
+ assert var._var_type == var_type
@pytest.mark.parametrize(
"var, expected",
[
(v("123"), json.dumps("123")),
- (BaseVar(_var_name="foo", _var_type=str)._var_set_state("state"), "state.foo"),
- (BaseVar(_var_name="foo", _var_type=str), "foo"),
+ (Var(_js_expr="foo")._var_set_state("state").to(str), "state.foo"),
+ (Var(_js_expr="foo").to(str), "foo"),
],
)
def test_str_contains(var, expected):
- assert str(var.contains("1")) == f'{{{expected}.includes("1")}}'
- assert str(var.contains(v("1"))) == f'{{{expected}.includes("1")}}'
- other_state_var = BaseVar(_var_name="other", _var_type=str)._var_set_state("state")
- other_var = BaseVar(_var_name="other", _var_type=str)
- assert str(var.contains(other_state_var)) == f"{{{expected}.includes(state.other)}}"
- assert str(var.contains(other_var)) == f"{{{expected}.includes(other)}}"
+ assert str(var.contains("1")) == f'{expected}.includes("1")'
+ assert str(var.contains(v("1"))) == f'{expected}.includes("1")'
+ other_state_var = Var(_js_expr="other")._var_set_state("state").to(str)
+ other_var = Var(_js_expr="other").to(str)
+ assert str(var.contains(other_state_var)) == f"{expected}.includes(state.other)"
+ assert str(var.contains(other_var)) == f"{expected}.includes(other)"
assert (
- str(var.contains("1", "hello")) == f'{{{expected}.some(e=>e[`hello`]==="1")}}'
+ str(var.contains("1", "hello"))
+ == f'{expected}.some(obj => obj["hello"] === "1")'
)
@pytest.mark.parametrize(
"var, expected",
[
- (v({"a": 1, "b": 2}), '{"a": 1, "b": 2}'),
- (BaseVar(_var_name="foo", _var_type=dict)._var_set_state("state"), "state.foo"),
- (BaseVar(_var_name="foo", _var_type=dict), "foo"),
+ (v({"a": 1, "b": 2}), '({ ["a"] : 1, ["b"] : 2 })'),
+ (Var(_js_expr="foo")._var_set_state("state").to(dict), "state.foo"),
+ (Var(_js_expr="foo").to(dict), "foo"),
],
)
def test_dict_contains(var, expected):
- assert str(var.contains(1)) == f"{{{expected}.hasOwnProperty(1)}}"
- assert str(var.contains("1")) == f'{{{expected}.hasOwnProperty("1")}}'
- assert str(var.contains(v(1))) == f"{{{expected}.hasOwnProperty(1)}}"
- assert str(var.contains(v("1"))) == f'{{{expected}.hasOwnProperty("1")}}'
- other_state_var = BaseVar(_var_name="other", _var_type=str)._var_set_state("state")
- other_var = BaseVar(_var_name="other", _var_type=str)
+ assert str(var.contains(1)) == f"{expected}.hasOwnProperty(1)"
+ assert str(var.contains("1")) == f'{expected}.hasOwnProperty("1")'
+ assert str(var.contains(v(1))) == f"{expected}.hasOwnProperty(1)"
+ assert str(var.contains(v("1"))) == f'{expected}.hasOwnProperty("1")'
+ other_state_var = Var(_js_expr="other")._var_set_state("state").to(str)
+ other_var = Var(_js_expr="other").to(str)
assert (
- str(var.contains(other_state_var))
- == f"{{{expected}.hasOwnProperty(state.other)}}"
+ str(var.contains(other_state_var)) == f"{expected}.hasOwnProperty(state.other)"
)
- assert str(var.contains(other_var)) == f"{{{expected}.hasOwnProperty(other)}}"
+ assert str(var.contains(other_var)) == f"{expected}.hasOwnProperty(other)"
@pytest.mark.parametrize(
"var",
[
- BaseVar(_var_name="list", _var_type=List[int]),
- BaseVar(_var_name="tuple", _var_type=Tuple[int, int]),
- BaseVar(_var_name="str", _var_type=str),
+ Var(_js_expr="list", _var_type=List[int]).guess_type(),
+ Var(_js_expr="tuple", _var_type=Tuple[int, int]).guess_type(),
+ Var(_js_expr="str", _var_type=str).guess_type(),
],
)
def test_var_indexing_lists(var):
@@ -520,59 +494,62 @@ def test_var_indexing_lists(var):
var : The str, list or tuple base var.
"""
# Test basic indexing.
- assert str(var[0]) == f"{{{var._var_name}.at(0)}}"
- assert str(var[1]) == f"{{{var._var_name}.at(1)}}"
+ assert str(var[0]) == f"{var._js_expr}.at(0)"
+ assert str(var[1]) == f"{var._js_expr}.at(1)"
# Test negative indexing.
- assert str(var[-1]) == f"{{{var._var_name}.at(-1)}}"
+ assert str(var[-1]) == f"{var._js_expr}.at(-1)"
@pytest.mark.parametrize(
"var, type_",
[
- (BaseVar(_var_name="list", _var_type=List[int]), [int, int]),
- (BaseVar(_var_name="tuple", _var_type=Tuple[int, str]), [int, str]),
+ (Var(_js_expr="list", _var_type=List[int]).guess_type(), [int, int]),
+ (
+ Var(_js_expr="tuple", _var_type=Tuple[int, str]).guess_type(),
+ [int, str],
+ ),
],
)
def test_var_indexing_types(var, type_):
"""Test that indexing returns valid types.
Args:
- var : The list, typle base var.
+ var : The list, tuple base var.
type_ : The type on indexed object.
"""
- assert var[2]._var_type == type_[0]
- assert var[3]._var_type == type_[1]
+ assert var[0]._var_type == type_[0]
+ assert var[1]._var_type == type_[1]
def test_var_indexing_str():
"""Test that we can index into str vars."""
- str_var = BaseVar(_var_name="str", _var_type=str)
+ str_var = Var(_js_expr="str").to(str)
# Test that indexing gives a type of Var[str].
assert isinstance(str_var[0], Var)
- assert str_var[0]._var_type == str
+ assert str_var[0]._var_type is str
# Test basic indexing.
- assert str(str_var[0]) == "{str.at(0)}"
- assert str(str_var[1]) == "{str.at(1)}"
+ assert str(str_var[0]) == "str.at(0)"
+ assert str(str_var[1]) == "str.at(1)"
# Test negative indexing.
- assert str(str_var[-1]) == "{str.at(-1)}"
+ assert str(str_var[-1]) == "str.at(-1)"
@pytest.mark.parametrize(
"var",
[
- (BaseVar(_var_name="foo", _var_type=int)),
- (BaseVar(_var_name="bar", _var_type=float)),
+ (Var(_js_expr="foo", _var_type=int).guess_type()),
+ (Var(_js_expr="bar", _var_type=float).guess_type()),
],
)
def test_var_replace_with_invalid_kwargs(var):
with pytest.raises(TypeError) as excinfo:
var._replace(_this_should_fail=True)
- assert "Unexpected keyword arguments" in str(excinfo.value)
+ assert "unexpected keyword argument" in str(excinfo.value)
def test_computed_var_replace_with_invalid_kwargs():
@@ -582,65 +559,71 @@ def test_computed_var_replace_with_invalid_kwargs():
with pytest.raises(TypeError) as excinfo:
test_var._replace(_random_kwarg=True)
- assert "Unexpected keyword arguments" in str(excinfo.value)
+ assert "Unexpected keyword argument" in str(excinfo.value)
@pytest.mark.parametrize(
"var, index",
[
- (BaseVar(_var_name="lst", _var_type=List[int]), [1, 2]),
- (BaseVar(_var_name="lst", _var_type=List[int]), {"name": "dict"}),
- (BaseVar(_var_name="lst", _var_type=List[int]), {"set"}),
+ (Var(_js_expr="lst", _var_type=List[int]).guess_type(), [1, 2]),
(
- BaseVar(_var_name="lst", _var_type=List[int]),
+ Var(_js_expr="lst", _var_type=List[int]).guess_type(),
+ {"name": "dict"},
+ ),
+ (Var(_js_expr="lst", _var_type=List[int]).guess_type(), {"set"}),
+ (
+ Var(_js_expr="lst", _var_type=List[int]).guess_type(),
(
1,
2,
),
),
- (BaseVar(_var_name="lst", _var_type=List[int]), 1.5),
- (BaseVar(_var_name="lst", _var_type=List[int]), "str"),
+ (Var(_js_expr="lst", _var_type=List[int]).guess_type(), 1.5),
+ (Var(_js_expr="lst", _var_type=List[int]).guess_type(), "str"),
(
- BaseVar(_var_name="lst", _var_type=List[int]),
- BaseVar(_var_name="string_var", _var_type=str),
+ Var(_js_expr="lst", _var_type=List[int]).guess_type(),
+ Var(_js_expr="string_var", _var_type=str).guess_type(),
),
(
- BaseVar(_var_name="lst", _var_type=List[int]),
- BaseVar(_var_name="float_var", _var_type=float),
+ Var(_js_expr="lst", _var_type=List[int]).guess_type(),
+ Var(_js_expr="float_var", _var_type=float).guess_type(),
),
(
- BaseVar(_var_name="lst", _var_type=List[int]),
- BaseVar(_var_name="list_var", _var_type=List[int]),
+ Var(_js_expr="lst", _var_type=List[int]).guess_type(),
+ Var(_js_expr="list_var", _var_type=List[int]).guess_type(),
),
(
- BaseVar(_var_name="lst", _var_type=List[int]),
- BaseVar(_var_name="set_var", _var_type=Set[str]),
+ Var(_js_expr="lst", _var_type=List[int]).guess_type(),
+ Var(_js_expr="set_var", _var_type=Set[str]).guess_type(),
),
(
- BaseVar(_var_name="lst", _var_type=List[int]),
- BaseVar(_var_name="dict_var", _var_type=Dict[str, str]),
+ Var(_js_expr="lst", _var_type=List[int]).guess_type(),
+ Var(_js_expr="dict_var", _var_type=Dict[str, str]).guess_type(),
),
- (BaseVar(_var_name="str", _var_type=str), [1, 2]),
- (BaseVar(_var_name="lst", _var_type=str), {"name": "dict"}),
- (BaseVar(_var_name="lst", _var_type=str), {"set"}),
+ (Var(_js_expr="str", _var_type=str).guess_type(), [1, 2]),
+ (Var(_js_expr="lst", _var_type=str).guess_type(), {"name": "dict"}),
+ (Var(_js_expr="lst", _var_type=str).guess_type(), {"set"}),
(
- BaseVar(_var_name="lst", _var_type=str),
- BaseVar(_var_name="string_var", _var_type=str),
+ Var(_js_expr="lst", _var_type=str).guess_type(),
+ Var(_js_expr="string_var", _var_type=str).guess_type(),
),
(
- BaseVar(_var_name="lst", _var_type=str),
- BaseVar(_var_name="float_var", _var_type=float),
+ Var(_js_expr="lst", _var_type=str).guess_type(),
+ Var(_js_expr="float_var", _var_type=float).guess_type(),
),
- (BaseVar(_var_name="str", _var_type=Tuple[str]), [1, 2]),
- (BaseVar(_var_name="lst", _var_type=Tuple[str]), {"name": "dict"}),
- (BaseVar(_var_name="lst", _var_type=Tuple[str]), {"set"}),
+ (Var(_js_expr="str", _var_type=Tuple[str]).guess_type(), [1, 2]),
(
- BaseVar(_var_name="lst", _var_type=Tuple[str]),
- BaseVar(_var_name="string_var", _var_type=str),
+ Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(),
+ {"name": "dict"},
+ ),
+ (Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(), {"set"}),
+ (
+ Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(),
+ Var(_js_expr="string_var", _var_type=str).guess_type(),
),
(
- BaseVar(_var_name="lst", _var_type=Tuple[str]),
- BaseVar(_var_name="float_var", _var_type=float),
+ Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(),
+ Var(_js_expr="float_var", _var_type=float).guess_type(),
),
],
)
@@ -658,9 +641,8 @@ def test_var_unsupported_indexing_lists(var, index):
@pytest.mark.parametrize(
"var",
[
- BaseVar(_var_name="lst", _var_type=List[int]),
- BaseVar(_var_name="tuple", _var_type=Tuple[int, int]),
- BaseVar(_var_name="str", _var_type=str),
+ Var(_js_expr="lst", _var_type=List[int]).guess_type(),
+ Var(_js_expr="tuple", _var_type=Tuple[int, int]).guess_type(),
],
)
def test_var_list_slicing(var):
@@ -669,84 +651,105 @@ def test_var_list_slicing(var):
Args:
var : The str, list or tuple base var.
"""
- assert str(var[:1]) == f"{{{var._var_name}.slice(0, 1)}}"
- assert str(var[:1]) == f"{{{var._var_name}.slice(0, 1)}}"
- assert str(var[:]) == f"{{{var._var_name}.slice(0, undefined)}}"
+ assert str(var[:1]) == f"{var._js_expr}.slice(undefined, 1)"
+ assert str(var[1:]) == f"{var._js_expr}.slice(1, undefined)"
+ assert str(var[:]) == f"{var._js_expr}.slice(undefined, undefined)"
+
+
+def test_str_var_slicing():
+ """Test that we can slice into str vars."""
+ str_var = Var(_js_expr="str").to(str)
+
+ # Test that slicing gives a type of Var[str].
+ assert isinstance(str_var[:1], Var)
+ assert str_var[:1]._var_type is str
+
+ # Test basic slicing.
+ assert str(str_var[:1]) == 'str.split("").slice(undefined, 1).join("")'
+ assert str(str_var[1:]) == 'str.split("").slice(1, undefined).join("")'
+ assert str(str_var[:]) == 'str.split("").slice(undefined, undefined).join("")'
+ assert str(str_var[1:2]) == 'str.split("").slice(1, 2).join("")'
+
+ # Test negative slicing.
+ assert str(str_var[:-1]) == 'str.split("").slice(undefined, -1).join("")'
+ assert str(str_var[-1:]) == 'str.split("").slice(-1, undefined).join("")'
+ assert str(str_var[:-2]) == 'str.split("").slice(undefined, -2).join("")'
+ assert str(str_var[-2:]) == 'str.split("").slice(-2, undefined).join("")'
def test_dict_indexing():
"""Test that we can index into dict vars."""
- dct = BaseVar(_var_name="dct", _var_type=Dict[str, int])
+ dct = Var(_js_expr="dct").to(ObjectVar, Dict[str, str])
# Check correct indexing.
- assert str(dct["a"]) == '{dct["a"]}'
- assert str(dct["asdf"]) == '{dct["asdf"]}'
+ assert str(dct["a"]) == 'dct["a"]'
+ assert str(dct["asdf"]) == 'dct["asdf"]'
@pytest.mark.parametrize(
"var, index",
[
(
- BaseVar(_var_name="dict", _var_type=Dict[str, str]),
+ Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(),
[1, 2],
),
(
- BaseVar(_var_name="dict", _var_type=Dict[str, str]),
+ Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(),
{"name": "dict"},
),
(
- BaseVar(_var_name="dict", _var_type=Dict[str, str]),
+ Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(),
{"set"},
),
(
- BaseVar(_var_name="dict", _var_type=Dict[str, str]),
+ Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(),
(
1,
2,
),
),
(
- BaseVar(_var_name="lst", _var_type=Dict[str, str]),
- BaseVar(_var_name="list_var", _var_type=List[int]),
+ Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(),
+ Var(_js_expr="list_var", _var_type=List[int]).guess_type(),
),
(
- BaseVar(_var_name="lst", _var_type=Dict[str, str]),
- BaseVar(_var_name="set_var", _var_type=Set[str]),
+ Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(),
+ Var(_js_expr="set_var", _var_type=Set[str]).guess_type(),
),
(
- BaseVar(_var_name="lst", _var_type=Dict[str, str]),
- BaseVar(_var_name="dict_var", _var_type=Dict[str, str]),
+ Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(),
+ Var(_js_expr="dict_var", _var_type=Dict[str, str]).guess_type(),
),
(
- BaseVar(_var_name="df", _var_type=DataFrame),
+ Var(_js_expr="df", _var_type=DataFrame).guess_type(),
[1, 2],
),
(
- BaseVar(_var_name="df", _var_type=DataFrame),
+ Var(_js_expr="df", _var_type=DataFrame).guess_type(),
{"name": "dict"},
),
(
- BaseVar(_var_name="df", _var_type=DataFrame),
+ Var(_js_expr="df", _var_type=DataFrame).guess_type(),
{"set"},
),
(
- BaseVar(_var_name="df", _var_type=DataFrame),
+ Var(_js_expr="df", _var_type=DataFrame).guess_type(),
(
1,
2,
),
),
(
- BaseVar(_var_name="df", _var_type=DataFrame),
- BaseVar(_var_name="list_var", _var_type=List[int]),
+ Var(_js_expr="df", _var_type=DataFrame).guess_type(),
+ Var(_js_expr="list_var", _var_type=List[int]).guess_type(),
),
(
- BaseVar(_var_name="df", _var_type=DataFrame),
- BaseVar(_var_name="set_var", _var_type=Set[str]),
+ Var(_js_expr="df", _var_type=DataFrame).guess_type(),
+ Var(_js_expr="set_var", _var_type=Set[str]).guess_type(),
),
(
- BaseVar(_var_name="df", _var_type=DataFrame),
- BaseVar(_var_name="dict_var", _var_type=Dict[str, str]),
+ Var(_js_expr="df", _var_type=DataFrame).guess_type(),
+ Var(_js_expr="dict_var", _var_type=Dict[str, str]).guess_type(),
),
],
)
@@ -765,8 +768,6 @@ def test_var_unsupported_indexing_dicts(var, index):
"fixture",
[
"ParentState",
- "ChildState",
- "GrandChildState",
"StateWithAnyVar",
],
)
@@ -788,6 +789,26 @@ def test_computed_var_without_annotation_error(request, fixture):
)
+@pytest.mark.parametrize(
+ "fixture",
+ [
+ "ChildState",
+ "GrandChildState",
+ ],
+)
+def test_shadow_computed_var_error(request: pytest.FixtureRequest, fixture: str):
+ """Test that a name error is thrown when an attribute of a computed var is
+ shadowed by another attribute.
+
+ Args:
+ request: Fixture Request.
+ fixture: The state fixture.
+ """
+ with pytest.raises(NameError):
+ state = request.getfixturevalue(fixture)
+ state.var_without_annotation.foo
+
+
@pytest.mark.parametrize(
"fixture",
[
@@ -882,7 +903,7 @@ def test_literal_var():
True,
False,
None,
- set([1, 2, 3]),
+ {1, 2, 3},
]
)
assert (
@@ -892,47 +913,63 @@ def test_literal_var():
def test_function_var():
- addition_func = FunctionStringVar("((a, b) => a + b)")
+ addition_func = FunctionStringVar.create("((a, b) => a + b)")
assert str(addition_func.call(1, 2)) == "(((a, b) => a + b)(1, 2))"
- manual_addition_func = ArgsFunctionOperation(
+ manual_addition_func = ArgsFunctionOperation.create(
("a", "b"),
{
- "args": [ImmutableVar.create_safe("a"), ImmutableVar.create_safe("b")],
- "result": ImmutableVar.create_safe("a + b"),
+ "args": [Var(_js_expr="a"), Var(_js_expr="b")],
+ "result": Var(_js_expr="a + b"),
},
)
assert (
str(manual_addition_func.call(1, 2))
- == '(((a, b) => (({ ["args"] : [a, b], ["result"] : a + b })))(1, 2))'
+ == '(((a, b) => ({ ["args"] : [a, b], ["result"] : a + b }))(1, 2))'
)
- increment_func = addition_func(1)
+ increment_func = addition_func.partial(1)
assert (
str(increment_func.call(2))
- == "(((...args) => ((((a, b) => a + b)(1, ...args))))(2))"
+ == "(((...args) => (((a, b) => a + b)(1, ...args)))(2))"
)
- create_hello_statement = ArgsFunctionOperation(
- ("name",), f"Hello, {ImmutableVar.create_safe('name')}!"
+ create_hello_statement = ArgsFunctionOperation.create(
+ ("name",), f"Hello, {Var(_js_expr='name')}!"
)
- first_name = LiteralStringVar("Steven")
- last_name = LiteralStringVar("Universe")
+ first_name = LiteralStringVar.create("Steven")
+ last_name = LiteralStringVar.create("Universe")
assert (
str(create_hello_statement.call(f"{first_name} {last_name}"))
- == '(((name) => (("Hello, "+name+"!")))(("Steven"+" "+"Universe")))'
+ == '(((name) => ("Hello, "+name+"!"))("Steven Universe"))'
)
+ # Test with destructured arguments
+ destructured_func = ArgsFunctionOperation.create(
+ (DestructuredArg(fields=("a", "b")),),
+ Var(_js_expr="a + b"),
+ )
+ assert (
+ str(destructured_func.call({"a": 1, "b": 2}))
+ == '((({a, b}) => a + b)(({ ["a"] : 1, ["b"] : 2 })))'
+ )
+
+ # Test with explicit return
+ explicit_return_func = ArgsFunctionOperation.create(
+ ("a", "b"), Var(_js_expr="return a + b"), explicit_return=True
+ )
+ assert str(explicit_return_func.call(1, 2)) == "(((a, b) => {return a + b})(1, 2))"
+
def test_var_operation():
- @var_operation(output=NumberVar)
- def add(a: Union[NumberVar, int], b: Union[NumberVar, int]) -> str:
- return f"({a} + {b})"
+ @var_operation
+ def add(a: Union[NumberVar, int], b: Union[NumberVar, int]):
+ return var_operation_return(js_expression=f"({a} + {b})", var_type=int)
assert str(add(1, 2)) == "(1 + 2)"
assert str(add(a=4, b=-9)) == "(4 + -9)"
- five = LiteralNumberVar(5)
+ five = LiteralNumberVar.create(5)
seven = add(2, five)
assert isinstance(seven, NumberVar)
@@ -952,7 +989,7 @@ def test_string_operations():
def test_all_number_operations():
- starting_number = LiteralNumberVar(-5.4)
+ starting_number = LiteralNumberVar.create(-5.4)
complicated_number = (((-(starting_number + 1)) * 2 / 3) // 2 % 3) ** 2
@@ -967,19 +1004,34 @@ def test_all_number_operations():
assert (
str(even_more_complicated_number)
- == "!(((Math.abs(Math.floor(((Math.floor(((-((-5.4 + 1)) * 2) / 3) / 2) % 3) ** 2))) != 0) || (true && (Math.round(((Math.floor(((-((-5.4 + 1)) * 2) / 3) / 2) % 3) ** 2)) != 0))))"
+ == "!(((Math.abs(Math.floor(((Math.floor(((-((-5.4 + 1)) * 2) / 3) / 2) % 3) ** 2))) || (2 && Math.round(((Math.floor(((-((-5.4 + 1)) * 2) / 3) / 2) % 3) ** 2)))) !== 0))"
)
- assert str(LiteralNumberVar(5) > False) == "(5 > 0)"
- assert str(LiteralBooleanVar(False) < 5) == "((false ? 1 : 0) < 5)"
+ assert str(LiteralNumberVar.create(5) > False) == "(5 > 0)"
+ assert str(LiteralBooleanVar.create(False) < 5) == "(Number(false) < 5)"
assert (
- str(LiteralBooleanVar(False) < LiteralBooleanVar(True))
- == "((false ? 1 : 0) < (true ? 1 : 0))"
+ str(LiteralBooleanVar.create(False) < LiteralBooleanVar.create(True))
+ == "(Number(false) < Number(true))"
)
+@pytest.mark.parametrize(
+ ("var", "expected"),
+ [
+ (Var.create(False), "false"),
+ (Var.create(True), "true"),
+ (Var.create("false"), 'isTrue("false")'),
+ (Var.create([1, 2, 3]), "isTrue([1, 2, 3])"),
+ (Var.create({"a": 1, "b": 2}), 'isTrue(({ ["a"] : 1, ["b"] : 2 }))'),
+ (Var("mysterious_var"), "isTrue(mysterious_var)"),
+ ],
+)
+def test_boolify_operations(var, expected):
+ assert str(var.bool()) == expected
+
+
def test_index_operation():
- array_var = LiteralArrayVar([1, 2, 3, 4, 5])
+ array_var = LiteralArrayVar.create([1, 2, 3, 4, 5])
assert str(array_var[0]) == "[1, 2, 3, 4, 5].at(0)"
assert str(array_var[1:2]) == "[1, 2, 3, 4, 5].slice(1, 2)"
assert (
@@ -988,18 +1040,34 @@ def test_index_operation():
)
assert (
str(array_var[::-1])
- == "[1, 2, 3, 4, 5].slice(0, [1, 2, 3, 4, 5].length).reverse().slice(undefined, undefined).filter((_, i) => i % 1 === 0)"
+ == "[1, 2, 3, 4, 5].slice(0, [1, 2, 3, 4, 5].length).slice().reverse().slice(undefined, undefined).filter((_, i) => i % 1 === 0)"
)
- assert str(array_var.reverse()) == "[1, 2, 3, 4, 5].reverse()"
+ assert str(array_var.reverse()) == "[1, 2, 3, 4, 5].slice().reverse()"
assert str(array_var[0].to(NumberVar) + 9) == "([1, 2, 3, 4, 5].at(0) + 9)"
+@pytest.mark.parametrize(
+ "var, expected_js",
+ [
+ (Var.create(float("inf")), "Infinity"),
+ (Var.create(-float("inf")), "-Infinity"),
+ (Var.create(float("nan")), "NaN"),
+ ],
+)
+def test_inf_and_nan(var, expected_js):
+ assert str(var) == expected_js
+ assert isinstance(var, NumberVar)
+ assert isinstance(var, LiteralVar)
+ with pytest.raises(PrimitiveUnserializableToJSON):
+ var.json()
+
+
def test_array_operations():
array_var = LiteralArrayVar.create([1, 2, 3, 4, 5])
assert str(array_var.length()) == "[1, 2, 3, 4, 5].length"
assert str(array_var.contains(3)) == "[1, 2, 3, 4, 5].includes(3)"
- assert str(array_var.reverse()) == "[1, 2, 3, 4, 5].reverse()"
+ assert str(array_var.reverse()) == "[1, 2, 3, 4, 5].slice().reverse()"
assert (
str(ArrayVar.range(10))
== "Array.from({ length: (10 - 0) / 1 }, (_, i) => 0 + i * 1)"
@@ -1019,7 +1087,7 @@ def test_array_operations():
def test_object_operations():
- object_var = LiteralObjectVar({"a": 1, "b": 2, "c": 3})
+ object_var = LiteralObjectVar.create({"a": 1, "b": 2, "c": 3})
assert (
str(object_var.keys()) == 'Object.keys(({ ["a"] : 1, ["b"] : 2, ["c"] : 3 }))'
@@ -1035,13 +1103,36 @@ def test_object_operations():
assert str(object_var.a) == '({ ["a"] : 1, ["b"] : 2, ["c"] : 3 })["a"]'
assert str(object_var["a"]) == '({ ["a"] : 1, ["b"] : 2, ["c"] : 3 })["a"]'
assert (
- str(object_var.merge(LiteralObjectVar({"c": 4, "d": 5})))
- == 'Object.assign(({ ["a"] : 1, ["b"] : 2, ["c"] : 3 }), ({ ["c"] : 4, ["d"] : 5 }))'
+ str(object_var.merge(LiteralObjectVar.create({"c": 4, "d": 5})))
+ == '({...({ ["a"] : 1, ["b"] : 2, ["c"] : 3 }), ...({ ["c"] : 4, ["d"] : 5 })})'
)
+def test_var_component():
+ class ComponentVarState(rx.State):
+ field_var: rx.Component = rx.text("I am a field var")
+
+ @rx.var
+ def computed_var(self) -> rx.Component:
+ return rx.text("I am a computed var")
+
+ def has_eval_react_component(var: Var):
+ var_data = var._get_all_var_data()
+ assert var_data is not None
+ assert any(
+ any(
+ imported_object.name == "evalReactComponent"
+ for imported_object in imported_objects
+ )
+ for _, imported_objects in var_data.imports
+ )
+
+ has_eval_react_component(ComponentVarState.field_var) # type: ignore
+ has_eval_react_component(ComponentVarState.computed_var)
+
+
def test_type_chains():
- object_var = LiteralObjectVar({"a": 1, "b": 2, "c": 3})
+ object_var = LiteralObjectVar.create({"a": 1, "b": 2, "c": 3})
assert (object_var._key_type(), object_var._value_type()) == (str, int)
assert (object_var.keys()._var_type, object_var.values()._var_type) == (
List[str],
@@ -1062,7 +1153,7 @@ def test_type_chains():
def test_nested_dict():
- arr = LiteralArrayVar([{"bar": ["foo", "bar"]}], List[Dict[str, List[str]]])
+ arr = LiteralArrayVar.create([{"bar": ["foo", "bar"]}], List[Dict[str, List[str]]])
assert (
str(arr[0]["bar"][0]) == '[({ ["bar"] : ["foo", "bar"] })].at(0)["bar"].at(0)'
@@ -1078,7 +1169,9 @@ def nested_base():
bar: Boo
baz: int
- parent_obj = LiteralVar.create(Foo(bar=Boo(foo="bar", bar=5), baz=5))
+ parent_obj = LiteralObjectVar.create(
+ Foo(bar=Boo(foo="bar", bar=5), baz=5).dict(), Foo
+ )
assert (
str(parent_obj.bar.foo)
@@ -1087,7 +1180,7 @@ def nested_base():
def test_retrival():
- var_without_data = ImmutableVar.create("test")
+ var_without_data = Var(_js_expr="test")
assert var_without_data is not None
original_var_data = VarData(
@@ -1103,8 +1196,8 @@ def test_retrival():
assert REFLEX_VAR_OPENING_TAG in f_string
assert REFLEX_VAR_CLOSING_TAG in f_string
- result_var_data = Var.create_safe(f_string)._var_data
- result_immutable_var_data = ImmutableVar.create_safe(f_string)._var_data
+ result_var_data = LiteralVar.create(f_string)._get_all_var_data()
+ result_immutable_var_data = Var(_js_expr=f_string)._var_data
assert result_var_data is not None and result_immutable_var_data is not None
assert (
result_var_data.state
@@ -1113,35 +1206,23 @@ def test_retrival():
)
assert (
result_var_data.imports
- == (
- result_immutable_var_data.imports
- if isinstance(result_immutable_var_data.imports, dict)
- else {
- k: list(v)
- for k, v in result_immutable_var_data.imports
- if k in original_var_data.imports
- }
- )
+ == result_immutable_var_data.imports
== original_var_data.imports
)
assert (
- list(result_var_data.hooks.keys())
- == (
- list(result_immutable_var_data.hooks.keys())
- if isinstance(result_immutable_var_data.hooks, dict)
- else list(result_immutable_var_data.hooks)
- )
- == list(original_var_data.hooks.keys())
+ tuple(result_var_data.hooks)
+ == tuple(result_immutable_var_data.hooks)
+ == tuple(original_var_data.hooks)
)
def test_fstring_concat():
- original_var_with_data = Var.create_safe(
+ original_var_with_data = LiteralVar.create(
"imagination", _var_data=VarData(state="fear")
)
- immutable_var_with_data = ImmutableVar.create_safe(
- "consequences",
+ immutable_var_with_data = Var(
+ _js_expr="consequences",
_var_data=VarData(
imports={
"react": [ImportVar(tag="useRef")],
@@ -1159,9 +1240,9 @@ def test_fstring_concat():
),
)
- assert str(string_concat) == '("foo"+imagination+"bar"+consequences+"baz")'
+ assert str(string_concat) == '("fooimaginationbar"+consequences+"baz")'
assert isinstance(string_concat, ConcatVarOperation)
- assert string_concat._get_all_var_data() == ImmutableVarData(
+ assert string_concat._get_all_var_data() == VarData(
state="fear",
imports={
"react": [ImportVar(tag="useRef")],
@@ -1171,17 +1252,22 @@ def test_fstring_concat():
)
+var = Var(_js_expr="var", _var_type=str)
+myvar = Var(_js_expr="myvar", _var_type=int)._var_set_state("state")
+x = Var(_js_expr="x", _var_type=str)
+
+
@pytest.mark.parametrize(
"out, expected",
[
- (f"{BaseVar(_var_name='var', _var_type=str)}", "${var}"),
+ (f"{var}", f"{hash(var)} var"),
(
- f"testing f-string with {BaseVar(_var_name='myvar', _var_type=int)._var_set_state('state')}",
- 'testing f-string with ${"state": "state", "interpolations": [], "imports": {"/utils/context": [{"tag": "StateContexts", "is_default": false, "alias": null, "install": true, "render": true, "transpile": false}], "react": [{"tag": "useContext", "is_default": false, "alias": null, "install": true, "render": true, "transpile": false}]}, "hooks": {"const state = useContext(StateContexts.state)": null}, "string_length": 13} {state.myvar}',
+ f"testing f-string with {myvar}",
+ f"testing f-string with {hash(myvar)} state.myvar",
),
(
- f"testing local f-string {BaseVar(_var_name='x', _var_is_local=True, _var_type=str)}",
- "testing local f-string x",
+ f"testing local f-string {x}",
+ f"testing local f-string {hash(x)} x",
),
],
)
@@ -1194,8 +1280,8 @@ def test_fstrings(out, expected):
[
([1], ""),
({"a": 1}, ""),
- ([Var.create_safe(1)._var_set_state("foo")], "foo"),
- ({"a": Var.create_safe(1)._var_set_state("foo")}, "foo"),
+ ([LiteralVar.create(1)._var_set_state("foo")], "foo"),
+ ({"a": LiteralVar.create(1)._var_set_state("foo")}, "foo"),
],
)
def test_extract_state_from_container(value, expect_state):
@@ -1205,7 +1291,9 @@ def test_extract_state_from_container(value, expect_state):
value: The value to create a var from.
expect_state: The expected state.
"""
- assert Var.create_safe(value)._var_state == expect_state
+ var_data = LiteralVar.create(value)._get_all_var_data()
+ var_state = var_data.state if var_data else ""
+ assert var_state == expect_state
@pytest.mark.parametrize(
@@ -1221,25 +1309,20 @@ def test_fstring_roundtrip(value):
Args:
value: The value to create a Var from.
"""
- var = BaseVar.create_safe(value)._var_set_state("state")
- rt_var = Var.create_safe(f"{var}")
+ var = Var(_js_expr=value)._var_set_state("state")
+ rt_var = LiteralVar.create(f"{var}")
assert var._var_state == rt_var._var_state
- assert var._var_full_name_needs_state_prefix
- assert not rt_var._var_full_name_needs_state_prefix
- assert rt_var._var_name == var._var_full_name
+ assert str(rt_var) == str(var)
@pytest.mark.parametrize(
"var",
[
- BaseVar(_var_name="var", _var_type=int),
- BaseVar(_var_name="var", _var_type=float),
- BaseVar(_var_name="var", _var_type=str),
- BaseVar(_var_name="var", _var_type=bool),
- BaseVar(_var_name="var", _var_type=dict),
- BaseVar(_var_name="var", _var_type=tuple),
- BaseVar(_var_name="var", _var_type=set),
- BaseVar(_var_name="var", _var_type=None),
+ Var(_js_expr="var", _var_type=int).guess_type(),
+ Var(_js_expr="var", _var_type=float).guess_type(),
+ Var(_js_expr="var", _var_type=str).guess_type(),
+ Var(_js_expr="var", _var_type=bool).guess_type(),
+ Var(_js_expr="var", _var_type=None).guess_type(),
],
)
def test_unsupported_types_for_reverse(var):
@@ -1250,19 +1333,19 @@ def test_unsupported_types_for_reverse(var):
"""
with pytest.raises(TypeError) as err:
var.reverse()
- assert err.value.args[0] == f"Cannot reverse non-list var var."
+ assert err.value.args[0] == "Cannot reverse non-list var."
@pytest.mark.parametrize(
"var",
[
- BaseVar(_var_name="var", _var_type=int),
- BaseVar(_var_name="var", _var_type=float),
- BaseVar(_var_name="var", _var_type=bool),
- BaseVar(_var_name="var", _var_type=None),
+ Var(_js_expr="var", _var_type=int).guess_type(),
+ Var(_js_expr="var", _var_type=float).guess_type(),
+ Var(_js_expr="var", _var_type=bool).guess_type(),
+ Var(_js_expr="var", _var_type=type(None)).guess_type(),
],
)
-def test_unsupported_types_for_contains(var):
+def test_unsupported_types_for_contains(var: Var):
"""Test that unsupported types for contains throw a type error.
Args:
@@ -1272,34 +1355,34 @@ def test_unsupported_types_for_contains(var):
assert var.contains(1)
assert (
err.value.args[0]
- == f"Var var of type {var._var_type} does not support contains check."
+ == f"Var of type {var._var_type} does not support contains check."
)
@pytest.mark.parametrize(
"other",
[
- BaseVar(_var_name="other", _var_type=int),
- BaseVar(_var_name="other", _var_type=float),
- BaseVar(_var_name="other", _var_type=bool),
- BaseVar(_var_name="other", _var_type=list),
- BaseVar(_var_name="other", _var_type=dict),
- BaseVar(_var_name="other", _var_type=tuple),
- BaseVar(_var_name="other", _var_type=set),
+ Var(_js_expr="other", _var_type=int).guess_type(),
+ Var(_js_expr="other", _var_type=float).guess_type(),
+ Var(_js_expr="other", _var_type=bool).guess_type(),
+ Var(_js_expr="other", _var_type=list).guess_type(),
+ Var(_js_expr="other", _var_type=dict).guess_type(),
+ Var(_js_expr="other", _var_type=tuple).guess_type(),
+ Var(_js_expr="other", _var_type=set).guess_type(),
],
)
def test_unsupported_types_for_string_contains(other):
with pytest.raises(TypeError) as err:
- assert BaseVar(_var_name="var", _var_type=str).contains(other)
+ assert Var(_js_expr="var").to(str).contains(other)
assert (
err.value.args[0]
- == f"'in ' requires string as left operand, not {other._var_type}"
+ == f"Unsupported Operand type(s) for contains: ToStringOperation, {type(other).__name__}"
)
def test_unsupported_default_contains():
with pytest.raises(TypeError) as err:
- assert 1 in BaseVar(_var_name="var", _var_type=str)
+ assert 1 in Var(_js_expr="var", _var_type=str).guess_type()
assert (
err.value.args[0]
== "'in' operator not supported for Var types, use Var.contains() instead."
@@ -1310,8 +1393,8 @@ def test_unsupported_default_contains():
"operand1_var,operand2_var,operators",
[
(
- Var.create(10),
- Var.create(5),
+ LiteralVar.create(10),
+ LiteralVar.create(5),
[
"+",
"-",
@@ -1329,13 +1412,13 @@ def test_unsupported_default_contains():
],
),
(
- Var.create(10.5),
- Var.create(5),
+ LiteralVar.create(10.5),
+ LiteralVar.create(5),
["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="],
),
(
- Var.create(5),
- Var.create(True),
+ LiteralVar.create(5),
+ LiteralVar.create(True),
[
"+",
"-",
@@ -1353,22 +1436,26 @@ def test_unsupported_default_contains():
],
),
(
- Var.create(10.5),
- Var.create(5.5),
+ LiteralVar.create(10.5),
+ LiteralVar.create(5.5),
["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="],
),
(
- Var.create(10.5),
- Var.create(True),
+ LiteralVar.create(10.5),
+ LiteralVar.create(True),
["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="],
),
- (Var.create("10"), Var.create("5"), ["+", ">", "<", "<=", ">="]),
- (Var.create([10, 20]), Var.create([5, 6]), ["+", ">", "<", "<=", ">="]),
- (Var.create([10, 20]), Var.create(5), ["*"]),
- (Var.create([10, 20]), Var.create(True), ["*"]),
+ (LiteralVar.create("10"), LiteralVar.create("5"), ["+", ">", "<", "<=", ">="]),
(
- Var.create(True),
- Var.create(True),
+ LiteralVar.create([10, 20]),
+ LiteralVar.create([5, 6]),
+ ["+", ">", "<", "<=", ">="],
+ ),
+ (LiteralVar.create([10, 20]), LiteralVar.create(5), ["*"]),
+ (LiteralVar.create([10, 20]), LiteralVar.create(True), ["*"]),
+ (
+ LiteralVar.create(True),
+ LiteralVar.create(True),
[
"+",
"-",
@@ -1396,16 +1483,26 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
operators: list of supported operators.
"""
for operator in operators:
- operand1_var.operation(op=operator, other=operand2_var)
- operand1_var.operation(op=operator, other=operand2_var, flip=True)
+ print(
+ "testing",
+ operator,
+ "on",
+ operand1_var,
+ operand2_var,
+ " of types",
+ type(operand1_var),
+ type(operand2_var),
+ )
+ eval(f"operand1_var {operator} operand2_var")
+ eval(f"operand2_var {operator} operand1_var")
@pytest.mark.parametrize(
"operand1_var,operand2_var,operators",
[
(
- Var.create(10),
- Var.create(5),
+ LiteralVar.create(10),
+ LiteralVar.create(5),
[
"^",
"<<",
@@ -1413,41 +1510,35 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
],
),
(
- Var.create(10.5),
- Var.create(5),
+ LiteralVar.create(10.5),
+ LiteralVar.create(5),
[
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create(10.5),
- Var.create(True),
+ LiteralVar.create(10.5),
+ LiteralVar.create(True),
[
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create(10.5),
- Var.create(5.5),
+ LiteralVar.create(10.5),
+ LiteralVar.create(5.5),
[
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create("10"),
- Var.create("5"),
+ LiteralVar.create("10"),
+ LiteralVar.create("5"),
[
"-",
"/",
@@ -1455,16 +1546,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
"*",
"%",
"**",
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create([10, 20]),
- Var.create([5, 6]),
+ LiteralVar.create([10, 20]),
+ LiteralVar.create([5, 6]),
[
"-",
"/",
@@ -1472,16 +1561,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
"*",
"%",
"**",
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create([10, 20]),
- Var.create(5),
+ LiteralVar.create([10, 20]),
+ LiteralVar.create(5),
[
"+",
"-",
@@ -1493,16 +1580,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
"<",
"<=",
">=",
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create([10, 20]),
- Var.create(True),
+ LiteralVar.create([10, 20]),
+ LiteralVar.create(True),
[
"+",
"-",
@@ -1514,16 +1599,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
"<",
"<=",
">=",
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create([10, 20]),
- Var.create("5"),
+ LiteralVar.create([10, 20]),
+ LiteralVar.create("5"),
[
"+",
"-",
@@ -1536,16 +1619,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
"<",
"<=",
">=",
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create([10, 20]),
- Var.create({"key": "value"}),
+ LiteralVar.create([10, 20]),
+ LiteralVar.create({"key": "value"}),
[
"+",
"-",
@@ -1558,16 +1639,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
"<",
"<=",
">=",
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create([10, 20]),
- Var.create(5.5),
+ LiteralVar.create([10, 20]),
+ LiteralVar.create(5.5),
[
"+",
"-",
@@ -1580,16 +1659,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
"<",
"<=",
">=",
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create({"key": "value"}),
- Var.create({"another_key": "another_value"}),
+ LiteralVar.create({"key": "value"}),
+ LiteralVar.create({"another_key": "another_value"}),
[
"+",
"-",
@@ -1602,16 +1679,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
"<",
"<=",
">=",
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create({"key": "value"}),
- Var.create(5),
+ LiteralVar.create({"key": "value"}),
+ LiteralVar.create(5),
[
"+",
"-",
@@ -1624,16 +1699,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
"<",
"<=",
">=",
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create({"key": "value"}),
- Var.create(True),
+ LiteralVar.create({"key": "value"}),
+ LiteralVar.create(True),
[
"+",
"-",
@@ -1646,16 +1719,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
"<",
"<=",
">=",
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create({"key": "value"}),
- Var.create(5.5),
+ LiteralVar.create({"key": "value"}),
+ LiteralVar.create(5.5),
[
"+",
"-",
@@ -1668,16 +1739,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
"<",
"<=",
">=",
- "|",
"^",
"<<",
">>",
- "&",
],
),
(
- Var.create({"key": "value"}),
- Var.create("5"),
+ LiteralVar.create({"key": "value"}),
+ LiteralVar.create("5"),
[
"+",
"-",
@@ -1690,44 +1759,46 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s
"<",
"<=",
">=",
- "|",
"^",
"<<",
">>",
- "&",
],
),
],
)
def test_invalid_var_operations(operand1_var: Var, operand2_var, operators: List[str]):
for operator in operators:
+ print(f"testing {operator} on {operand1_var!s} and {operand2_var!s}")
with pytest.raises(TypeError):
- operand1_var.operation(op=operator, other=operand2_var)
+ print(eval(f"operand1_var {operator} operand2_var"))
with pytest.raises(TypeError):
- operand1_var.operation(op=operator, other=operand2_var, flip=True)
+ print(eval(f"operand2_var {operator} operand1_var"))
@pytest.mark.parametrize(
"var, expected",
[
- (Var.create("string_value", _var_is_string=True), "`string_value`"),
- (Var.create(1), "1"),
- (Var.create([1, 2, 3]), "[1, 2, 3]"),
- (Var.create({"foo": "bar"}), '{"foo": "bar"}'),
+ (LiteralVar.create("string_value"), '"string_value"'),
+ (LiteralVar.create(1), "1"),
+ (LiteralVar.create([1, 2, 3]), "[1, 2, 3]"),
+ (LiteralVar.create({"foo": "bar"}), '({ ["foo"] : "bar" })'),
(
- Var.create(ATestState.value, _var_is_string=True),
+ LiteralVar.create(ATestState.value),
f"{ATestState.get_full_name()}.value",
),
(
- Var.create(f"{ATestState.value} string", _var_is_string=True),
- f"`${{{ATestState.get_full_name()}.value}} string`",
+ LiteralVar.create(f"{ATestState.value} string"),
+ f'({ATestState.get_full_name()}.value+" string")',
+ ),
+ (
+ LiteralVar.create(ATestState.dict_val),
+ f"{ATestState.get_full_name()}.dict_val",
),
- (Var.create(ATestState.dict_val), f"{ATestState.get_full_name()}.dict_val"),
],
)
def test_var_name_unwrapped(var, expected):
- assert var._var_name_unwrapped == expected
+ assert str(var) == expected
def cv_fget(state: BaseState) -> int:
@@ -1770,3 +1841,24 @@ def test_invalid_computed_var_deps(deps: List):
)
def test_var(state) -> int:
return 1
+
+
+def test_to_string_operation():
+ class Email(str): ...
+
+ class TestState(BaseState):
+ optional_email: Optional[Email] = None
+ email: Email = Email("test@reflex.dev")
+
+ assert (
+ str(TestState.optional_email) == f"{TestState.get_full_name()}.optional_email"
+ )
+ my_state = TestState()
+ assert my_state.optional_email is None
+ assert my_state.email == "test@reflex.dev"
+
+ assert cast(Var, TestState.email)._var_type == Email
+ assert cast(Var, TestState.optional_email)._var_type == Optional[Email]
+
+ single_var = Var.create(Email())
+ assert single_var._var_type == Email
diff --git a/tests/utils/__init__.py b/tests/units/utils/__init__.py
similarity index 100%
rename from tests/utils/__init__.py
rename to tests/units/utils/__init__.py
diff --git a/tests/utils/test_format.py b/tests/units/utils/test_format.py
similarity index 68%
rename from tests/utils/test_format.py
rename to tests/units/utils/test_format.py
index 95ebc047b..2a2aa8259 100644
--- a/tests/utils/test_format.py
+++ b/tests/units/utils/test_format.py
@@ -1,18 +1,20 @@
from __future__ import annotations
import datetime
+import json
from typing import Any, List
import plotly.graph_objects as go
import pytest
from reflex.components.tags.tag import Tag
-from reflex.event import EventChain, EventHandler, EventSpec, FrontendEvent
+from reflex.event import EventChain, EventHandler, EventSpec, JavascriptInputEvent
from reflex.style import Style
from reflex.utils import format
from reflex.utils.serializers import serialize_figure
-from reflex.vars import BaseVar, Var
-from tests.test_state import (
+from reflex.vars.base import LiteralVar, Var
+from reflex.vars.object import ObjectVar
+from tests.units.test_state import (
ChildState,
ChildState2,
ChildState3,
@@ -260,7 +262,7 @@ def test_to_kebab_case(input: str, output: str):
],
)
def test_format_string(input: str, output: str):
- """Test formating the input as JS string literal.
+ """Test formatting the input as JS string literal.
Args:
input: the input string.
@@ -272,16 +274,12 @@ def test_format_string(input: str, output: str):
@pytest.mark.parametrize(
"input,output",
[
- (Var.create(value="test"), "{`test`}"),
- (Var.create(value="test", _var_is_local=True), "{`test`}"),
- (Var.create(value="test", _var_is_local=False), "{test}"),
- (Var.create(value="test", _var_is_string=True), "{`test`}"),
- (Var.create(value="test", _var_is_string=False), "{`test`}"),
- (Var.create(value="test", _var_is_local=False, _var_is_string=False), "{test}"),
+ (LiteralVar.create(value="test"), '"test"'),
+ (Var(_js_expr="test"), "test"),
],
)
def test_format_var(input: Var, output: str):
- assert format.format_var(input) == output
+ assert str(input) == output
@pytest.mark.parametrize(
@@ -312,134 +310,33 @@ def test_format_route(route: str, format_case: bool, expected: bool):
assert format.format_route(route, format_case=format_case) == expected
-@pytest.mark.parametrize(
- "condition,true_value,false_value,is_prop,expected",
- [
- ("cond", "", '""', False, '{isTrue(cond) ? : ""}'),
- ("cond", "", "", False, "{isTrue(cond) ? : }"),
- (
- "cond",
- Var.create_safe(""),
- "",
- False,
- "{isTrue(cond) ? : }",
- ),
- (
- "cond",
- Var.create_safe(""),
- Var.create_safe("