reflex-components-core 0.9.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. reflex_components_core/__init__.py +20 -0
  2. reflex_components_core/__init__.pyi +8 -0
  3. reflex_components_core/base/__init__.py +29 -0
  4. reflex_components_core/base/__init__.pyi +35 -0
  5. reflex_components_core/base/app_wrap.py +19 -0
  6. reflex_components_core/base/app_wrap.pyi +52 -0
  7. reflex_components_core/base/bare.py +247 -0
  8. reflex_components_core/base/body.py +7 -0
  9. reflex_components_core/base/body.pyi +273 -0
  10. reflex_components_core/base/document.py +39 -0
  11. reflex_components_core/base/document.pyi +403 -0
  12. reflex_components_core/base/error_boundary.py +179 -0
  13. reflex_components_core/base/error_boundary.pyi +89 -0
  14. reflex_components_core/base/fragment.py +13 -0
  15. reflex_components_core/base/fragment.pyi +80 -0
  16. reflex_components_core/base/link.py +38 -0
  17. reflex_components_core/base/link.pyi +551 -0
  18. reflex_components_core/base/meta.py +47 -0
  19. reflex_components_core/base/meta.pyi +620 -0
  20. reflex_components_core/base/script.py +77 -0
  21. reflex_components_core/base/script.pyi +320 -0
  22. reflex_components_core/base/strict_mode.py +10 -0
  23. reflex_components_core/base/strict_mode.pyi +78 -0
  24. reflex_components_core/core/__init__.py +60 -0
  25. reflex_components_core/core/__init__.pyi +85 -0
  26. reflex_components_core/core/_upload.py +696 -0
  27. reflex_components_core/core/auto_scroll.py +123 -0
  28. reflex_components_core/core/auto_scroll.pyi +279 -0
  29. reflex_components_core/core/banner.py +481 -0
  30. reflex_components_core/core/banner.pyi +787 -0
  31. reflex_components_core/core/breakpoints.py +4 -0
  32. reflex_components_core/core/clipboard.py +101 -0
  33. reflex_components_core/core/clipboard.pyi +92 -0
  34. reflex_components_core/core/colors.py +53 -0
  35. reflex_components_core/core/cond.py +197 -0
  36. reflex_components_core/core/debounce.py +150 -0
  37. reflex_components_core/core/debounce.pyi +108 -0
  38. reflex_components_core/core/foreach.py +180 -0
  39. reflex_components_core/core/helmet.py +14 -0
  40. reflex_components_core/core/helmet.pyi +80 -0
  41. reflex_components_core/core/html.py +48 -0
  42. reflex_components_core/core/html.pyi +280 -0
  43. reflex_components_core/core/layout/__init__.py +1 -0
  44. reflex_components_core/core/markdown_component_map.py +78 -0
  45. reflex_components_core/core/match.py +300 -0
  46. reflex_components_core/core/responsive.py +69 -0
  47. reflex_components_core/core/sticky.py +130 -0
  48. reflex_components_core/core/sticky.pyi +973 -0
  49. reflex_components_core/core/upload.py +490 -0
  50. reflex_components_core/core/upload.pyi +462 -0
  51. reflex_components_core/core/window_events.py +142 -0
  52. reflex_components_core/core/window_events.pyi +95 -0
  53. reflex_components_core/datadisplay/__init__.py +20 -0
  54. reflex_components_core/datadisplay/__init__.pyi +18 -0
  55. reflex_components_core/datadisplay/logo.py +72 -0
  56. reflex_components_core/el/__init__.py +24 -0
  57. reflex_components_core/el/__init__.pyi +520 -0
  58. reflex_components_core/el/element.py +22 -0
  59. reflex_components_core/el/element.pyi +78 -0
  60. reflex_components_core/el/elements/__init__.py +160 -0
  61. reflex_components_core/el/elements/__init__.pyi +655 -0
  62. reflex_components_core/el/elements/base.py +142 -0
  63. reflex_components_core/el/elements/base.pyi +351 -0
  64. reflex_components_core/el/elements/forms.py +799 -0
  65. reflex_components_core/el/elements/forms.pyi +4934 -0
  66. reflex_components_core/el/elements/inline.py +256 -0
  67. reflex_components_core/el/elements/inline.pyi +7384 -0
  68. reflex_components_core/el/elements/media.py +1018 -0
  69. reflex_components_core/el/elements/media.pyi +13681 -0
  70. reflex_components_core/el/elements/metadata.py +106 -0
  71. reflex_components_core/el/elements/metadata.pyi +1254 -0
  72. reflex_components_core/el/elements/other.py +81 -0
  73. reflex_components_core/el/elements/other.pyi +1848 -0
  74. reflex_components_core/el/elements/scripts.py +58 -0
  75. reflex_components_core/el/elements/scripts.pyi +840 -0
  76. reflex_components_core/el/elements/sectioning.py +110 -0
  77. reflex_components_core/el/elements/sectioning.pyi +3930 -0
  78. reflex_components_core/el/elements/tables.py +114 -0
  79. reflex_components_core/el/elements/tables.pyi +2657 -0
  80. reflex_components_core/el/elements/typography.py +153 -0
  81. reflex_components_core/el/elements/typography.pyi +4210 -0
  82. reflex_components_core/react_router/__init__.py +5 -0
  83. reflex_components_core/react_router/dom.py +75 -0
  84. reflex_components_core/react_router/dom.pyi +337 -0
  85. reflex_components_core-0.9.0.dist-info/METADATA +17 -0
  86. reflex_components_core-0.9.0.dist-info/RECORD +87 -0
  87. reflex_components_core-0.9.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,20 @@
1
+ """Reflex base UI components package."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from reflex_base.utils import lazy_loader
6
+
7
+ _SUBMODULES: set[str] = {
8
+ "base",
9
+ "core",
10
+ "datadisplay",
11
+ "el",
12
+ }
13
+
14
+ _SUBMOD_ATTRS: dict[str, list[str]] = {}
15
+
16
+ __getattr__, __dir__, __all__ = lazy_loader.attach(
17
+ __name__,
18
+ submodules=_SUBMODULES,
19
+ submod_attrs=_SUBMOD_ATTRS,
20
+ )
@@ -0,0 +1,8 @@
1
+ """Stub file for reflex_components_core/__init__.py"""
2
+ # ------------------- DO NOT EDIT ----------------------
3
+ # This file was generated by `reflex/utils/pyi_generator.py`!
4
+ # ------------------------------------------------------
5
+
6
+ from . import base, core, datadisplay, el
7
+
8
+ __all__ = ["base", "core", "datadisplay", "el"]
@@ -0,0 +1,29 @@
1
+ """Base components."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from reflex_base.utils import lazy_loader
6
+
7
+ _SUBMODULES: set[str] = {"app_wrap", "bare"}
8
+
9
+ _SUBMOD_ATTRS: dict[str, list[str]] = {
10
+ "body": ["Body"],
11
+ "document": ["Scripts", "Outlet", "ScrollRestoration", "Links", "Meta"],
12
+ "fragment": [
13
+ "Fragment",
14
+ "fragment",
15
+ ],
16
+ "error_boundary": [
17
+ "ErrorBoundary",
18
+ "error_boundary",
19
+ ],
20
+ "link": ["RawLink", "ScriptTag"],
21
+ "meta": ["Description", "Image", "Meta", "Title"],
22
+ "script": ["Script", "script"],
23
+ }
24
+
25
+ __getattr__, __dir__, __all__ = lazy_loader.attach(
26
+ __name__,
27
+ submodules=_SUBMODULES,
28
+ submod_attrs=_SUBMOD_ATTRS,
29
+ )
@@ -0,0 +1,35 @@
1
+ """Stub file for reflex_components_core/base/__init__.py"""
2
+ # ------------------- DO NOT EDIT ----------------------
3
+ # This file was generated by `reflex/utils/pyi_generator.py`!
4
+ # ------------------------------------------------------
5
+
6
+ from . import app_wrap, bare
7
+ from .body import Body
8
+ from .document import Links, Outlet, Scripts, ScrollRestoration
9
+ from .error_boundary import ErrorBoundary, error_boundary
10
+ from .fragment import Fragment, fragment
11
+ from .link import RawLink, ScriptTag
12
+ from .meta import Description, Image, Meta, Title
13
+ from .script import Script, script
14
+
15
+ __all__ = [
16
+ "Body",
17
+ "Description",
18
+ "ErrorBoundary",
19
+ "Fragment",
20
+ "Image",
21
+ "Links",
22
+ "Meta",
23
+ "Outlet",
24
+ "RawLink",
25
+ "Script",
26
+ "ScriptTag",
27
+ "Scripts",
28
+ "ScrollRestoration",
29
+ "Title",
30
+ "app_wrap",
31
+ "bare",
32
+ "error_boundary",
33
+ "fragment",
34
+ "script",
35
+ ]
@@ -0,0 +1,19 @@
1
+ """Top-level component that wraps the entire app."""
2
+
3
+ from reflex_base.components.component import Component
4
+ from reflex_base.vars.base import Var
5
+
6
+ from reflex_components_core.base.fragment import Fragment
7
+
8
+
9
+ class AppWrap(Fragment):
10
+ """Top-level component that wraps the entire app."""
11
+
12
+ @classmethod
13
+ def create(cls) -> Component:
14
+ """Create a new AppWrap component.
15
+
16
+ Returns:
17
+ A new AppWrap component containing {children}.
18
+ """
19
+ return super().create(Var(_js_expr="children"))
@@ -0,0 +1,52 @@
1
+ """Stub file for reflex_components_core/base/app_wrap.py"""
2
+
3
+ # ------------------- DO NOT EDIT ----------------------
4
+ # This file was generated by `reflex/utils/pyi_generator.py`!
5
+ # ------------------------------------------------------
6
+ from collections.abc import Mapping, Sequence
7
+ from typing import Any
8
+
9
+ from reflex_base.event import EventType, PointerEventInfo
10
+ from reflex_base.vars.base import Var
11
+
12
+ from reflex_components_core.base.fragment import Fragment
13
+ from reflex_components_core.core.breakpoints import Breakpoints
14
+
15
+ class AppWrap(Fragment):
16
+ @classmethod
17
+ def create(
18
+ cls,
19
+ *children,
20
+ style: Sequence[Mapping[str, Any]]
21
+ | Mapping[str, Any]
22
+ | Var[Mapping[str, Any]]
23
+ | Breakpoints
24
+ | None = None,
25
+ key: Any | None = None,
26
+ id: Any | None = None,
27
+ ref: Var | None = None,
28
+ class_name: Any | None = None,
29
+ custom_attrs: dict[str, Any | Var] | None = None,
30
+ on_blur: EventType[()] | None = None,
31
+ on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
32
+ on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
33
+ on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
34
+ on_focus: EventType[()] | None = None,
35
+ on_mount: EventType[()] | None = None,
36
+ on_mouse_down: EventType[()] | None = None,
37
+ on_mouse_enter: EventType[()] | None = None,
38
+ on_mouse_leave: EventType[()] | None = None,
39
+ on_mouse_move: EventType[()] | None = None,
40
+ on_mouse_out: EventType[()] | None = None,
41
+ on_mouse_over: EventType[()] | None = None,
42
+ on_mouse_up: EventType[()] | None = None,
43
+ on_scroll: EventType[()] | None = None,
44
+ on_scroll_end: EventType[()] | None = None,
45
+ on_unmount: EventType[()] | None = None,
46
+ **props,
47
+ ) -> AppWrap:
48
+ """Create a new AppWrap component.
49
+
50
+ Returns:
51
+ A new AppWrap component containing {children}.
52
+ """
@@ -0,0 +1,247 @@
1
+ """A bare component."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Iterator, Sequence
6
+ from typing import Any
7
+
8
+ from reflex_base.components.component import BaseComponent, Component, ComponentStyle
9
+ from reflex_base.components.tags import Tag
10
+ from reflex_base.components.tags.tagless import Tagless
11
+ from reflex_base.environment import PerformanceMode, environment
12
+ from reflex_base.utils import console
13
+ from reflex_base.utils.decorator import once
14
+ from reflex_base.utils.imports import ParsedImportDict
15
+ from reflex_base.vars import BooleanVar, ObjectVar, Var
16
+ from reflex_base.vars.base import GLOBAL_CACHE, VarData
17
+ from reflex_base.vars.sequence import LiteralStringVar
18
+
19
+
20
+ @once
21
+ def get_performance_mode():
22
+ """Get the performance mode.
23
+
24
+ Returns:
25
+ The performance mode.
26
+ """
27
+ return environment.REFLEX_PERF_MODE.get()
28
+
29
+
30
+ def validate_str(value: str):
31
+ """Validate a string value.
32
+
33
+ Args:
34
+ value: The value to validate.
35
+
36
+ Raises:
37
+ ValueError: If the value is a Var and the performance mode is set to raise.
38
+ """
39
+ perf_mode = get_performance_mode()
40
+ if perf_mode != PerformanceMode.OFF and value.startswith("reflex___state"):
41
+ if perf_mode == PerformanceMode.WARN:
42
+ console.warn(
43
+ f"Output includes {value!s} which will be displayed as a string. If you are calling `str` on a Var, consider using .to_string() instead."
44
+ )
45
+ elif perf_mode == PerformanceMode.RAISE:
46
+ msg = f"Output includes {value!s} which will be displayed as a string. If you are calling `str` on a Var, consider using .to_string() instead."
47
+ raise ValueError(msg)
48
+
49
+
50
+ def _components_from_var(var: Var) -> Sequence[BaseComponent]:
51
+ var_data = var._get_all_var_data()
52
+ return var_data.components if var_data else ()
53
+
54
+
55
+ class Bare(Component):
56
+ """A component with no tag."""
57
+
58
+ contents: Var[Any]
59
+
60
+ @classmethod
61
+ def create(cls, contents: Any) -> Component:
62
+ """Create a Bare component, with no tag.
63
+
64
+ Args:
65
+ contents: The contents of the component.
66
+
67
+ Returns:
68
+ The component.
69
+ """
70
+ if isinstance(contents, Var):
71
+ if isinstance(contents, LiteralStringVar):
72
+ validate_str(contents._var_value)
73
+ return cls._unsafe_create(children=[], contents=contents)
74
+ if isinstance(contents, str):
75
+ validate_str(contents)
76
+ contents = Var.create(contents if contents is not None else "")
77
+
78
+ return cls._unsafe_create(children=[], contents=contents)
79
+
80
+ def _get_all_hooks_internal(self) -> dict[str, VarData | None]:
81
+ """Include the hooks for the component.
82
+
83
+ Returns:
84
+ The hooks for the component.
85
+ """
86
+ hooks = super()._get_all_hooks_internal()
87
+ if isinstance(self.contents, Var):
88
+ for component in _components_from_var(self.contents):
89
+ hooks |= component._get_all_hooks_internal()
90
+ return hooks
91
+
92
+ def _get_all_hooks(self) -> dict[str, VarData | None]:
93
+ """Include the hooks for the component.
94
+
95
+ Returns:
96
+ The hooks for the component.
97
+ """
98
+ hooks = super()._get_all_hooks()
99
+ if isinstance(self.contents, Var):
100
+ for component in _components_from_var(self.contents):
101
+ hooks |= component._get_all_hooks()
102
+ return hooks
103
+
104
+ def _get_all_imports(self, collapse: bool = False) -> ParsedImportDict:
105
+ """Include the imports for the component.
106
+
107
+ Args:
108
+ collapse: Whether to collapse the imports.
109
+
110
+ Returns:
111
+ The imports for the component.
112
+ """
113
+ imports = super()._get_all_imports(collapse=collapse)
114
+ if isinstance(self.contents, Var):
115
+ var_data = self.contents._get_all_var_data()
116
+ if var_data:
117
+ imports |= {k: list(v) for k, v in var_data.imports}
118
+ return imports
119
+
120
+ def _get_all_dynamic_imports(self) -> set[str]:
121
+ """Get dynamic imports for the component.
122
+
123
+ Returns:
124
+ The dynamic imports.
125
+ """
126
+ dynamic_imports = super()._get_all_dynamic_imports()
127
+ if isinstance(self.contents, Var):
128
+ for component in _components_from_var(self.contents):
129
+ dynamic_imports |= component._get_all_dynamic_imports()
130
+ return dynamic_imports
131
+
132
+ def _get_all_custom_code(self) -> dict[str, None]:
133
+ """Get custom code for the component.
134
+
135
+ Returns:
136
+ The custom code.
137
+ """
138
+ custom_code = super()._get_all_custom_code()
139
+ if isinstance(self.contents, Var):
140
+ for component in _components_from_var(self.contents):
141
+ custom_code |= component._get_all_custom_code()
142
+ return custom_code
143
+
144
+ def _get_all_app_wrap_components(
145
+ self, *, ignore_ids: set[int] | None = None
146
+ ) -> dict[tuple[int, str], Component]:
147
+ """Get the components that should be wrapped in the app.
148
+
149
+ Args:
150
+ ignore_ids: The ids to ignore when collecting components.
151
+
152
+ Returns:
153
+ The components that should be wrapped in the app.
154
+ """
155
+ ignore_ids = ignore_ids or set()
156
+ app_wrap_components = super()._get_all_app_wrap_components(
157
+ ignore_ids=ignore_ids
158
+ )
159
+ if isinstance(self.contents, Var):
160
+ for component in _components_from_var(self.contents):
161
+ component_id = id(component)
162
+ if isinstance(component, Component) and component_id not in ignore_ids:
163
+ ignore_ids.add(component_id)
164
+ app_wrap_components |= component._get_all_app_wrap_components(
165
+ ignore_ids=ignore_ids
166
+ )
167
+ return app_wrap_components
168
+
169
+ def _get_all_refs(self) -> dict[str, None]:
170
+ """Get the refs for the children of the component.
171
+
172
+ Returns:
173
+ The refs for the children.
174
+ """
175
+ refs = super()._get_all_refs()
176
+ if isinstance(self.contents, Var):
177
+ for component in _components_from_var(self.contents):
178
+ refs |= component._get_all_refs()
179
+ return refs
180
+
181
+ def _render(self) -> Tag:
182
+ contents = (
183
+ Var.create(self.contents)
184
+ if not isinstance(self.contents, Var)
185
+ else self.contents
186
+ )
187
+ if isinstance(contents, (BooleanVar, ObjectVar)):
188
+ return Tagless(contents=f"{contents.to_string()!s}")
189
+ return Tagless(contents=f"{contents!s}")
190
+
191
+ def render(self) -> dict:
192
+ """Render the component as a dictionary.
193
+
194
+ This is overridden to provide a short performant path for rendering.
195
+
196
+ Returns:
197
+ The rendered component.
198
+ """
199
+ contents = (
200
+ Var.create(self.contents)
201
+ if not isinstance(self.contents, Var)
202
+ else self.contents
203
+ )
204
+ if isinstance(contents, (BooleanVar, ObjectVar)):
205
+ return {"contents": f"{contents.to_string()!s}"}
206
+ return {"contents": f"{contents!s}"}
207
+
208
+ def _add_style_recursive(
209
+ self, style: ComponentStyle, theme: Component | None = None
210
+ ) -> Component:
211
+ """Add style to the component and its children.
212
+
213
+ Args:
214
+ style: The style to add.
215
+ theme: The theme to add.
216
+
217
+ Returns:
218
+ The component with the style added.
219
+ """
220
+ new_self = super()._add_style_recursive(style, theme)
221
+
222
+ are_components_touched = False
223
+
224
+ if isinstance(self.contents, Var):
225
+ for component in _components_from_var(self.contents):
226
+ if isinstance(component, Component):
227
+ component._add_style_recursive(style, theme)
228
+ are_components_touched = True
229
+
230
+ if are_components_touched:
231
+ GLOBAL_CACHE.clear()
232
+
233
+ return new_self
234
+
235
+ def _get_vars(
236
+ self, include_children: bool = False, ignore_ids: set[int] | None = None
237
+ ) -> Iterator[Var]:
238
+ """Walk all Vars used in this component.
239
+
240
+ Args:
241
+ include_children: Whether to include Vars from children.
242
+ ignore_ids: The ids to ignore.
243
+
244
+ Yields:
245
+ The contents if it is a Var, otherwise nothing.
246
+ """
247
+ yield self.contents
@@ -0,0 +1,7 @@
1
+ """Display the page body."""
2
+
3
+ from reflex_components_core.el import elements
4
+
5
+
6
+ class Body(elements.Body):
7
+ """A body component."""