diff --git a/reflex/__init__.py b/reflex/__init__.py index 276c05b99..e60fb0aef 100644 --- a/reflex/__init__.py +++ b/reflex/__init__.py @@ -104,6 +104,7 @@ _ALL_COMPONENTS = [ "EditorOptions", "icon", "markdown", + "list", "list_item", "unordered_list", "ordered_list", diff --git a/reflex/__init__.pyi b/reflex/__init__.pyi index 65e8f36fe..cd01f13db 100644 --- a/reflex/__init__.pyi +++ b/reflex/__init__.pyi @@ -90,6 +90,7 @@ from reflex.components import EditorButtonList as EditorButtonList from reflex.components import EditorOptions as EditorOptions from reflex.components import icon as icon from reflex.components import markdown as markdown +from reflex.components import list as list from reflex.components import list_item as list_item from reflex.components import unordered_list as unordered_list from reflex.components import ordered_list as ordered_list diff --git a/reflex/components/radix/themes/layout/__init__.py b/reflex/components/radix/themes/layout/__init__.py index ccc0b6f4c..4832c60db 100644 --- a/reflex/components/radix/themes/layout/__init__.py +++ b/reflex/components/radix/themes/layout/__init__.py @@ -5,7 +5,7 @@ from .center import Center from .container import Container from .flex import Flex from .grid import Grid -from .list import ListItem, OrderedList, UnorderedList +from .list import list_ns as list from .section import Section from .spacer import Spacer from .stack import HStack, Stack, VStack @@ -20,9 +20,9 @@ spacer = Spacer.create stack = Stack.create hstack = HStack.create vstack = VStack.create -list_item = ListItem.create -ordered_list = OrderedList.create -unordered_list = UnorderedList.create +list_item = list.item +ordered_list = list.ordered +unordered_list = list.unordered __all__ = [ "box", @@ -35,6 +35,7 @@ __all__ = [ "stack", "hstack", "vstack", + "list", "list_item", "ordered_list", "unordered_list", diff --git a/reflex/components/radix/themes/layout/list.py b/reflex/components/radix/themes/layout/list.py index 11c84a786..825d818de 100644 --- a/reflex/components/radix/themes/layout/list.py +++ b/reflex/components/radix/themes/layout/list.py @@ -171,6 +171,10 @@ class ListItem(Li): class List(ComponentNamespace): """List components.""" - item = ListItem.create - ordered = OrderedList.create - unordered = UnorderedList.create + item = staticmethod(ListItem.create) + ordered = staticmethod(OrderedList.create) + unordered = staticmethod(UnorderedList.create) + __call__ = staticmethod(BaseList.create) + + +list_ns = List() diff --git a/reflex/components/radix/themes/layout/list.pyi b/reflex/components/radix/themes/layout/list.pyi index 74029553f..140d48a55 100644 --- a/reflex/components/radix/themes/layout/list.pyi +++ b/reflex/components/radix/themes/layout/list.pyi @@ -1058,6 +1058,324 @@ class ListItem(Li): ... class List(ComponentNamespace): - item = ListItem.create - ordered = OrderedList.create - unordered = UnorderedList.create + item = staticmethod(ListItem.create) + ordered = staticmethod(OrderedList.create) + unordered = staticmethod(UnorderedList.create) + + @staticmethod + def __call__( + *children, + items: Optional[Union[Union[Var[Iterable], Iterable], Iterable]] = None, + list_style_type: Optional[ + Union[ + Var[ + Union[ + 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", + ], + ] + ], + Union[ + 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, + as_child: Optional[Union[Var[bool], bool]] = None, + direction: Optional[ + Union[ + Var[Literal["row", "column", "row-reverse", "column-reverse"]], + Literal["row", "column", "row-reverse", "column-reverse"], + ] + ] = None, + align: Optional[ + Union[ + Var[Literal["start", "center", "end", "baseline", "stretch"]], + Literal["start", "center", "end", "baseline", "stretch"], + ] + ] = None, + justify: Optional[ + Union[ + Var[Literal["start", "center", "end", "between"]], + Literal["start", "center", "end", "between"], + ] + ] = None, + wrap: Optional[ + Union[ + Var[Literal["nowrap", "wrap", "wrap-reverse"]], + Literal["nowrap", "wrap", "wrap-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"], + ] + ] = None, + access_key: Optional[ + Union[Var[Union[str, int, bool]], Union[str, int, bool]] + ] = None, + auto_capitalize: Optional[ + Union[Var[Union[str, int, bool]], Union[str, int, bool]] + ] = None, + content_editable: Optional[ + Union[Var[Union[str, int, bool]], Union[str, int, bool]] + ] = None, + context_menu: Optional[ + Union[Var[Union[str, int, bool]], Union[str, int, bool]] + ] = None, + dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, + draggable: Optional[ + Union[Var[Union[str, int, bool]], Union[str, int, bool]] + ] = None, + enter_key_hint: Optional[ + Union[Var[Union[str, int, bool]], Union[str, int, bool]] + ] = None, + hidden: Optional[ + Union[Var[Union[str, int, bool]], Union[str, int, bool]] + ] = None, + input_mode: Optional[ + Union[Var[Union[str, int, bool]], Union[str, int, bool]] + ] = None, + item_prop: Optional[ + Union[Var[Union[str, int, bool]], Union[str, int, bool]] + ] = None, + lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, + role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, + slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, + spell_check: Optional[ + Union[Var[Union[str, int, bool]], Union[str, int, bool]] + ] = None, + tab_index: Optional[ + Union[Var[Union[str, int, bool]], Union[str, int, bool]] + ] = None, + title: Optional[ + Union[Var[Union[str, int, bool]], Union[str, int, bool]] + ] = None, + p: 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, + px: 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, + py: 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, + pt: 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, + pr: 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, + pb: 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, + pl: 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, + shrink: Optional[Union[Var[Literal["0", "1"]], Literal["0", "1"]]] = None, + grow: Optional[Union[Var[Literal["0", "1"]], 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, + key: Optional[Any] = None, + id: Optional[Any] = None, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + on_blur: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_click: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_context_menu: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_double_click: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_focus: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_mount: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_mouse_down: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_mouse_enter: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_mouse_leave: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_mouse_move: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_mouse_out: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_mouse_over: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_mouse_up: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_scroll: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = None, + on_unmount: Optional[ + Union[EventHandler, EventSpec, list, function, BaseVar] + ] = 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". + 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" + 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. + 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