From 991f6e018377cdd1b6d160e937f5b4c3f5f9bf37 Mon Sep 17 00:00:00 2001 From: Carlos <36110765+carlosabadia@users.noreply.github.com> Date: Wed, 12 Jun 2024 18:21:36 +0200 Subject: [PATCH] [REF-3012] Add defs, lineargradient and stop html elements (#3467) --- reflex/components/el/__init__.pyi | 6 + reflex/components/el/elements/__init__.py | 3 + reflex/components/el/elements/__init__.pyi | 9 + reflex/components/el/elements/media.py | 52 +++ reflex/components/el/elements/media.pyi | 428 +++++++++++++++++++++ reflex/components/recharts/charts.py | 1 + 6 files changed, 499 insertions(+) diff --git a/reflex/components/el/__init__.pyi b/reflex/components/el/__init__.pyi index 0181309eb..403b60415 100644 --- a/reflex/components/el/__init__.pyi +++ b/reflex/components/el/__init__.pyi @@ -101,6 +101,9 @@ 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 svg as svg +from .elements.media import defs as defs +from .elements.media import lineargradient as lineargradient +from .elements.media import stop as stop from .elements.media import path as path from .elements.media import Area as Area from .elements.media import Audio as Audio @@ -115,6 +118,9 @@ 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 Svg as Svg +from .elements.media import Defs as Defs +from .elements.media import Lineargradient as Lineargradient +from .elements.media import Stop as Stop from .elements.media import Path as Path from .elements.metadata import base as base from .elements.metadata import head as head diff --git a/reflex/components/el/elements/__init__.py b/reflex/components/el/elements/__init__.py index 70a7dad4a..581eabc36 100644 --- a/reflex/components/el/elements/__init__.py +++ b/reflex/components/el/elements/__init__.py @@ -64,6 +64,9 @@ _MAPPING = { "portal", "source", "svg", + "defs", + "lineargradient", + "stop", "path", ], "metadata": [ diff --git a/reflex/components/el/elements/__init__.pyi b/reflex/components/el/elements/__init__.pyi index adaf63049..7df9bd12f 100644 --- a/reflex/components/el/elements/__init__.pyi +++ b/reflex/components/el/elements/__init__.pyi @@ -99,6 +99,9 @@ from .media import picture as picture from .media import portal as portal from .media import source as source from .media import svg as svg +from .media import defs as defs +from .media import lineargradient as lineargradient +from .media import stop as stop from .media import path as path from .media import Area as Area from .media import Audio as Audio @@ -113,6 +116,9 @@ from .media import Picture as Picture from .media import Portal as Portal from .media import Source as Source from .media import Svg as Svg +from .media import Defs as Defs +from .media import Lineargradient as Lineargradient +from .media import Stop as Stop from .media import Path as Path from .metadata import base as base from .metadata import head as head @@ -285,6 +291,9 @@ _MAPPING = { "portal", "source", "svg", + "defs", + "lineargradient", + "stop", "path", ], "metadata": ["base", "head", "link", "meta", "title"], diff --git a/reflex/components/el/elements/media.py b/reflex/components/el/elements/media.py index 9a64995c7..272dc02a8 100644 --- a/reflex/components/el/elements/media.py +++ b/reflex/components/el/elements/media.py @@ -2,6 +2,7 @@ from typing import Any, Union from reflex import Component +from reflex.constants.colors import Color from reflex.vars import Var as Var from .base import BaseHTML @@ -309,6 +310,54 @@ class Svg(BaseHTML): tag = "svg" +class Defs(BaseHTML): + """Display the defs element.""" + + tag = "defs" + + +class Lineargradient(BaseHTML): + """Display the linearGradient element.""" + + tag = "linearGradient" + + # Units for the gradient + gradient_units: Var[Union[str, bool]] + + # Transform applied to the gradient + gradient_transform: Var[Union[str, bool]] + + # Method used to spread the gradient + spread_method: Var[Union[str, bool]] + + # X coordinate of the starting point of the gradient + x1: Var[Union[str, int, bool]] + + # X coordinate of the ending point of the gradient + x2: Var[Union[str, int, bool]] + + # Y coordinate of the starting point of the gradient + y1: Var[Union[str, int, bool]] + + # Y coordinate of the ending point of the gradient + y2: Var[Union[str, int, bool]] + + +class Stop(BaseHTML): + """Display the stop element.""" + + tag = "stop" + + # Offset of the gradient stop + offset: Var[Union[str, float, int]] + + # Color of the gradient stop + stop_color: Var[Union[str, Color, bool]] + + # Opacity of the gradient stop + stop_opacity: Var[Union[str, float, int, bool]] + + class Path(BaseHTML): """Display the path element.""" @@ -331,4 +380,7 @@ picture = Picture.create portal = Portal.create source = Source.create svg = Svg.create +defs = Defs.create +lineargradient = Lineargradient.create +stop = Stop.create path = Path.create diff --git a/reflex/components/el/elements/media.pyi b/reflex/components/el/elements/media.pyi index d2d9ca287..ab7059ef9 100644 --- a/reflex/components/el/elements/media.pyi +++ b/reflex/components/el/elements/media.pyi @@ -9,6 +9,7 @@ from reflex.event import EventChain, EventHandler, EventSpec from reflex.style import Style from typing import Any, Union from reflex import Component +from reflex.constants.colors import Color from reflex.vars import Var as Var from .base import BaseHTML @@ -1953,6 +1954,430 @@ class Svg(BaseHTML): """ ... +class Defs(BaseHTML): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + 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, + style: Optional[Style] = None, + key: Optional[Any] = None, + id: Optional[Any] = None, + class_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 + ) -> "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. + 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 Lineargradient(BaseHTML): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + gradient_units: Optional[Union[Var[Union[str, bool]], Union[str, bool]]] = None, + gradient_transform: Optional[ + Union[Var[Union[str, bool]], Union[str, bool]] + ] = None, + spread_method: Optional[Union[Var[Union[str, bool]], Union[str, bool]]] = None, + x1: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, + x2: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, + y1: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None, + y2: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = 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, + style: Optional[Style] = None, + key: Optional[Any] = None, + id: Optional[Any] = None, + class_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 + ) -> "Lineargradient": + """Create the component. + + Args: + *children: The children of the component. + gradient_units: Units for the gradient + gradient_transform: Transform applied to the gradient + spread_method: Method used to spread the gradient + x1: X coordinate of the starting point of the gradient + 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. + 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 Stop(BaseHTML): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + offset: Optional[ + Union[Var[Union[str, float, int]], Union[str, float, int]] + ] = None, + stop_color: Optional[ + Union[Var[Union[str, Color, bool]], Union[str, Color, bool]] + ] = None, + stop_opacity: Optional[ + Union[Var[Union[str, float, int, bool]], Union[str, float, int, bool]] + ] = 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, + style: Optional[Style] = None, + key: Optional[Any] = None, + id: Optional[Any] = None, + class_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 + ) -> "Stop": + """Create the component. + + Args: + *children: The children of the component. + 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. + 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 Path(BaseHTML): @overload @classmethod @@ -2100,4 +2525,7 @@ picture = Picture.create portal = Portal.create source = Source.create svg = Svg.create +defs = Defs.create +lineargradient = Lineargradient.create +stop = Stop.create path = Path.create diff --git a/reflex/components/recharts/charts.py b/reflex/components/recharts/charts.py index 71a1b4feb..342c11b57 100644 --- a/reflex/components/recharts/charts.py +++ b/reflex/components/recharts/charts.py @@ -143,6 +143,7 @@ class AreaChart(CategoricalChartBase): "Legend", "GraphingTooltip", "Area", + "Defs", ]