reflex 0.8.1a1__py3-none-any.whl → 0.8.2a1__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.

Potentially problematic release.


This version of reflex might be problematic. Click here for more details.

@@ -29,7 +29,6 @@ def index() -> rx.Component:
29
29
  justify="center",
30
30
  min_height="85vh",
31
31
  ),
32
- rx.logo(),
33
32
  )
34
33
 
35
34
 
reflex/app.py CHANGED
@@ -22,6 +22,7 @@ from collections.abc import (
22
22
  Sequence,
23
23
  )
24
24
  from datetime import datetime
25
+ from itertools import chain
25
26
  from pathlib import Path
26
27
  from timeit import default_timer as timer
27
28
  from types import SimpleNamespace
@@ -238,10 +239,6 @@ def default_error_boundary(*children: Component, **props) -> Component:
238
239
  )
239
240
 
240
241
 
241
- class OverlayFragment(Fragment):
242
- """Alias for Fragment, used to wrap the overlay_component."""
243
-
244
-
245
242
  @dataclasses.dataclass(frozen=True)
246
243
  class UploadFile(StarletteUploadFile):
247
244
  """A file uploaded to the server.
@@ -369,6 +366,11 @@ class App(MiddlewareMixin, LifespanMixin):
369
366
  )
370
367
  )
371
368
 
369
+ # Extra app wraps to be applied to the whole app.
370
+ extra_app_wraps: dict[tuple[int, str], Callable[[bool], Component | None]] = (
371
+ dataclasses.field(default_factory=dict)
372
+ )
373
+
372
374
  # Components to add to the head of every page.
373
375
  head_components: list[Component] = dataclasses.field(default_factory=list)
374
376
 
@@ -515,8 +517,8 @@ class App(MiddlewareMixin, LifespanMixin):
515
517
  async_mode="asgi",
516
518
  cors_allowed_origins=(
517
519
  "*"
518
- if config.cors_allowed_origins == ["*"]
519
- else config.cors_allowed_origins
520
+ if config.cors_allowed_origins == ("*",)
521
+ else list(config.cors_allowed_origins)
520
522
  ),
521
523
  cors_credentials=True,
522
524
  max_http_buffer_size=environment.REFLEX_SOCKET_MAX_HTTP_BUFFER_SIZE.get(),
@@ -1031,25 +1033,31 @@ class App(MiddlewareMixin, LifespanMixin):
1031
1033
  # By default, compile the app.
1032
1034
  return True
1033
1035
 
1034
- def _add_overlay_to_component(self, component: Component) -> Component:
1035
- if self.overlay_component is None:
1036
- return component
1037
-
1036
+ def _add_overlay_to_component(
1037
+ self, component: Component, overlay_component: Component
1038
+ ) -> Component:
1038
1039
  children = component.children
1039
- overlay_component = self._generate_component(self.overlay_component)
1040
1040
 
1041
1041
  if children[0] == overlay_component:
1042
1042
  return component
1043
1043
 
1044
- # recreate OverlayFragment with overlay_component as first child
1045
- return OverlayFragment.create(overlay_component, *children)
1044
+ return Fragment.create(overlay_component, *children)
1046
1045
 
1047
1046
  def _setup_overlay_component(self):
1048
1047
  """If a State is not used and no overlay_component is specified, do not render the connection modal."""
1049
- if self._state is None and self.overlay_component is default_overlay_component:
1050
- self.overlay_component = None
1048
+ if self.overlay_component is None:
1049
+ return
1050
+ console.deprecate(
1051
+ feature_name="overlay_component",
1052
+ reason="Use `extra_app_wraps` to add the overlay component instead.",
1053
+ deprecation_version="0.8.2",
1054
+ removal_version="0.9.0",
1055
+ )
1056
+ overlay_component = self._generate_component(self.overlay_component)
1051
1057
  for k, component in self._pages.items():
1052
- self._pages[k] = self._add_overlay_to_component(component)
1058
+ self._pages[k] = self._add_overlay_to_component(
1059
+ component, overlay_component
1060
+ )
1053
1061
 
1054
1062
  def _setup_sticky_badge(self):
1055
1063
  """Add the sticky badge to the app."""
@@ -1261,7 +1269,10 @@ class App(MiddlewareMixin, LifespanMixin):
1261
1269
  app_wrappers[(1, "ToasterProvider")] = toast_provider
1262
1270
 
1263
1271
  # Add the app wraps to the app.
1264
- for key, app_wrap in self.app_wraps.items():
1272
+ for key, app_wrap in chain(
1273
+ self.app_wraps.items(), self.extra_app_wraps.items()
1274
+ ):
1275
+ # If the app wrap is a callable, generate the component
1265
1276
  component = app_wrap(self._state is not None)
1266
1277
  if component is not None:
1267
1278
  app_wrappers[key] = component
@@ -2076,9 +2087,20 @@ class EventNamespace(AsyncNamespace):
2076
2087
  # Get the client IP
2077
2088
  try:
2078
2089
  client_ip = environ["asgi.scope"]["client"][0]
2090
+ headers["asgi-scope-client"] = client_ip
2079
2091
  except (KeyError, IndexError):
2080
2092
  client_ip = environ.get("REMOTE_ADDR", "0.0.0.0")
2081
2093
 
2094
+ # Unroll reverse proxy forwarded headers.
2095
+ client_ip = (
2096
+ headers.get(
2097
+ "x-forwarded-for",
2098
+ client_ip,
2099
+ )
2100
+ .partition(",")[0]
2101
+ .strip()
2102
+ )
2103
+
2082
2104
  async with contextlib.aclosing(
2083
2105
  process(self.app, event, sid, headers, client_ip)
2084
2106
  ) as updates_gen:
@@ -828,10 +828,9 @@ def compile_unevaluated_page(
828
828
  enable_state = True
829
829
  break
830
830
 
831
- from reflex.app import OverlayFragment
832
831
  from reflex.utils.format import make_default_page_title
833
832
 
834
- component = OverlayFragment.create(component)
833
+ component = Fragment.create(component)
835
834
 
836
835
  meta_args = {
837
836
  "title": (
@@ -15,6 +15,7 @@ from . import (
15
15
  plotly,
16
16
  radix,
17
17
  react_player,
18
+ react_router,
18
19
  recharts,
19
20
  sonner,
20
21
  )
@@ -34,6 +35,7 @@ __all__ = [
34
35
  "plotly",
35
36
  "radix",
36
37
  "react_player",
38
+ "react_router",
37
39
  "recharts",
38
40
  "sonner",
39
41
  ]
@@ -4,6 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  from reflex.components.base.bare import Bare
6
6
  from reflex.components.el import elements
7
+ from reflex.components.el.elements.metadata import Meta as Meta # for compatibility
7
8
  from reflex.vars.base import Var
8
9
 
9
10
 
@@ -26,13 +27,6 @@ class Title(elements.Title):
26
27
  return super().render()
27
28
 
28
29
 
29
- class Meta(elements.Meta):
30
- """A component that displays metadata for the current page."""
31
-
32
- # The type of metadata value.
33
- property: Var[str]
34
-
35
-
36
30
  class Description(elements.Meta):
37
31
  """A component that displays the title of the current page."""
38
32
 
@@ -8,6 +8,7 @@ from typing import Any, Literal
8
8
 
9
9
  from reflex.components.core.breakpoints import Breakpoints
10
10
  from reflex.components.el import elements
11
+ from reflex.components.el.elements.metadata import Meta as Meta
11
12
  from reflex.event import EventType, PointerEventInfo
12
13
  from reflex.vars.base import Var
13
14
 
@@ -63,261 +64,6 @@ class Title(elements.Title):
63
64
  The component.
64
65
  """
65
66
 
66
- class Meta(elements.Meta):
67
- @classmethod
68
- def create(
69
- cls,
70
- *children,
71
- property: Var[str] | str | None = None,
72
- char_set: Var[str] | str | None = None,
73
- content: Var[str] | str | None = None,
74
- http_equiv: Var[str] | str | None = None,
75
- name: Var[str] | str | None = None,
76
- access_key: Var[str] | str | None = None,
77
- auto_capitalize: Literal[
78
- "characters", "none", "off", "on", "sentences", "words"
79
- ]
80
- | Var[Literal["characters", "none", "off", "on", "sentences", "words"]]
81
- | None = None,
82
- content_editable: Literal["inherit", "plaintext-only", False, True]
83
- | Var[Literal["inherit", "plaintext-only", False, True]]
84
- | None = None,
85
- context_menu: Var[str] | str | None = None,
86
- dir: Var[str] | str | None = None,
87
- draggable: Var[bool] | bool | None = None,
88
- enter_key_hint: Literal[
89
- "done", "enter", "go", "next", "previous", "search", "send"
90
- ]
91
- | Var[Literal["done", "enter", "go", "next", "previous", "search", "send"]]
92
- | None = None,
93
- hidden: Var[bool] | bool | None = None,
94
- input_mode: Literal[
95
- "decimal", "email", "none", "numeric", "search", "tel", "text", "url"
96
- ]
97
- | Var[
98
- Literal[
99
- "decimal", "email", "none", "numeric", "search", "tel", "text", "url"
100
- ]
101
- ]
102
- | None = None,
103
- item_prop: Var[str] | str | None = None,
104
- lang: Var[str] | str | None = None,
105
- role: Literal[
106
- "alert",
107
- "alertdialog",
108
- "application",
109
- "article",
110
- "banner",
111
- "button",
112
- "cell",
113
- "checkbox",
114
- "columnheader",
115
- "combobox",
116
- "complementary",
117
- "contentinfo",
118
- "definition",
119
- "dialog",
120
- "directory",
121
- "document",
122
- "feed",
123
- "figure",
124
- "form",
125
- "grid",
126
- "gridcell",
127
- "group",
128
- "heading",
129
- "img",
130
- "link",
131
- "list",
132
- "listbox",
133
- "listitem",
134
- "log",
135
- "main",
136
- "marquee",
137
- "math",
138
- "menu",
139
- "menubar",
140
- "menuitem",
141
- "menuitemcheckbox",
142
- "menuitemradio",
143
- "navigation",
144
- "none",
145
- "note",
146
- "option",
147
- "presentation",
148
- "progressbar",
149
- "radio",
150
- "radiogroup",
151
- "region",
152
- "row",
153
- "rowgroup",
154
- "rowheader",
155
- "scrollbar",
156
- "search",
157
- "searchbox",
158
- "separator",
159
- "slider",
160
- "spinbutton",
161
- "status",
162
- "switch",
163
- "tab",
164
- "table",
165
- "tablist",
166
- "tabpanel",
167
- "term",
168
- "textbox",
169
- "timer",
170
- "toolbar",
171
- "tooltip",
172
- "tree",
173
- "treegrid",
174
- "treeitem",
175
- ]
176
- | Var[
177
- Literal[
178
- "alert",
179
- "alertdialog",
180
- "application",
181
- "article",
182
- "banner",
183
- "button",
184
- "cell",
185
- "checkbox",
186
- "columnheader",
187
- "combobox",
188
- "complementary",
189
- "contentinfo",
190
- "definition",
191
- "dialog",
192
- "directory",
193
- "document",
194
- "feed",
195
- "figure",
196
- "form",
197
- "grid",
198
- "gridcell",
199
- "group",
200
- "heading",
201
- "img",
202
- "link",
203
- "list",
204
- "listbox",
205
- "listitem",
206
- "log",
207
- "main",
208
- "marquee",
209
- "math",
210
- "menu",
211
- "menubar",
212
- "menuitem",
213
- "menuitemcheckbox",
214
- "menuitemradio",
215
- "navigation",
216
- "none",
217
- "note",
218
- "option",
219
- "presentation",
220
- "progressbar",
221
- "radio",
222
- "radiogroup",
223
- "region",
224
- "row",
225
- "rowgroup",
226
- "rowheader",
227
- "scrollbar",
228
- "search",
229
- "searchbox",
230
- "separator",
231
- "slider",
232
- "spinbutton",
233
- "status",
234
- "switch",
235
- "tab",
236
- "table",
237
- "tablist",
238
- "tabpanel",
239
- "term",
240
- "textbox",
241
- "timer",
242
- "toolbar",
243
- "tooltip",
244
- "tree",
245
- "treegrid",
246
- "treeitem",
247
- ]
248
- ]
249
- | None = None,
250
- slot: Var[str] | str | None = None,
251
- spell_check: Var[bool] | bool | None = None,
252
- tab_index: Var[int] | int | None = None,
253
- title: Var[str] | str | None = None,
254
- style: Sequence[Mapping[str, Any]]
255
- | Mapping[str, Any]
256
- | Var[Mapping[str, Any]]
257
- | Breakpoints
258
- | None = None,
259
- key: Any | None = None,
260
- id: Any | None = None,
261
- ref: Var | None = None,
262
- class_name: Any | None = None,
263
- autofocus: bool | None = None,
264
- custom_attrs: dict[str, Var | Any] | None = None,
265
- on_blur: EventType[()] | None = None,
266
- on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
267
- on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
268
- on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
269
- on_focus: EventType[()] | None = None,
270
- on_mount: EventType[()] | None = None,
271
- on_mouse_down: EventType[()] | None = None,
272
- on_mouse_enter: EventType[()] | None = None,
273
- on_mouse_leave: EventType[()] | None = None,
274
- on_mouse_move: EventType[()] | None = None,
275
- on_mouse_out: EventType[()] | None = None,
276
- on_mouse_over: EventType[()] | None = None,
277
- on_mouse_up: EventType[()] | None = None,
278
- on_scroll: EventType[()] | None = None,
279
- on_scroll_end: EventType[()] | None = None,
280
- on_unmount: EventType[()] | None = None,
281
- **props,
282
- ) -> Meta:
283
- """Create the component.
284
-
285
- Args:
286
- *children: The children of the component.
287
- property: The type of metadata value.
288
- char_set: Specifies the character encoding for the HTML document
289
- content: Defines the content of the metadata
290
- http_equiv: Provides an HTTP header for the information/value of the content attribute
291
- name: Specifies a name for the metadata
292
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
293
- auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
294
- content_editable: Indicates whether the element's content is editable.
295
- context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
296
- dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
297
- draggable: Defines whether the element can be dragged.
298
- enter_key_hint: Hints what media types the media element is able to play.
299
- hidden: Defines whether the element is hidden.
300
- input_mode: Defines the type of the element.
301
- item_prop: Defines the name of the element for metadata purposes.
302
- lang: Defines the language used in the element.
303
- role: Defines the role of the element.
304
- slot: Assigns a slot in a shadow DOM shadow tree to an element.
305
- spell_check: Defines whether the element may be checked for spelling errors.
306
- tab_index: Defines the position of the current element in the tabbing order.
307
- title: Defines a tooltip for the element.
308
- style: The style of the component.
309
- key: A unique key for the component.
310
- id: The id for the component.
311
- ref: The Var to pass as the ref to the component.
312
- class_name: The class name for the component.
313
- autofocus: Whether the component should take the focus once the page is loaded
314
- custom_attrs: custom attribute
315
- **props: The props of the component.
316
-
317
- Returns:
318
- The component.
319
- """
320
-
321
67
  class Description(elements.Meta):
322
68
  @classmethod
323
69
  def create(
@@ -327,6 +73,7 @@ class Description(elements.Meta):
327
73
  char_set: Var[str] | str | None = None,
328
74
  content: Var[str] | str | None = None,
329
75
  http_equiv: Var[str] | str | None = None,
76
+ property: Var[str] | str | None = None,
330
77
  access_key: Var[str] | str | None = None,
331
78
  auto_capitalize: Literal[
332
79
  "characters", "none", "off", "on", "sentences", "words"
@@ -542,6 +289,7 @@ class Description(elements.Meta):
542
289
  char_set: Specifies the character encoding for the HTML document
543
290
  content: Defines the content of the metadata
544
291
  http_equiv: Provides an HTTP header for the information/value of the content attribute
292
+ property: The type of metadata value.
545
293
  access_key: Provides a hint for generating a keyboard shortcut for the current element.
546
294
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
547
295
  content_editable: Indicates whether the element's content is editable.
@@ -792,7 +540,7 @@ class Image(elements.Meta):
792
540
 
793
541
  Args:
794
542
  *children: The children of the component.
795
- property: The type of the image.
543
+ property: The type of metadata value.
796
544
  char_set: Specifies the character encoding for the HTML document
797
545
  content: Defines the content of the metadata
798
546
  http_equiv: Provides an HTTP header for the information/value of the content attribute
@@ -268,7 +268,9 @@ class WifiOffPulse(Icon):
268
268
  Returns:
269
269
  The icon component with default props applied.
270
270
  """
271
- pulse_var = Var(_js_expr="pulse")
271
+ pulse_var = Var(r"keyframes({ from: { opacity: 0 }, to: { opacity: 1 } })").to(
272
+ str
273
+ )
272
274
  return super().create(
273
275
  "wifi_off",
274
276
  color=props.pop("color", "crimson"),
@@ -289,18 +291,6 @@ class WifiOffPulse(Icon):
289
291
  """
290
292
  return {"@emotion/react": [ImportVar(tag="keyframes")]}
291
293
 
292
- def _get_custom_code(self) -> str | None:
293
- return """
294
- const pulse = keyframes`
295
- 0% {
296
- opacity: 0;
297
- }
298
- 100% {
299
- opacity: 1;
300
- }
301
- `
302
- """
303
-
304
294
 
305
295
  class ConnectionPulser(Div):
306
296
  """A connection pulser component."""
@@ -20,8 +20,8 @@ from reflex.vars.base import Var
20
20
  DEFAULT_UPLOAD_ID: str
21
21
  upload_files_context_var_data: VarData
22
22
 
23
- def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var: ...
24
- def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var: ...
23
+ def upload_file(id_: str | Var[str] = DEFAULT_UPLOAD_ID) -> Var: ...
24
+ def selected_files(id_: str | Var[str] = DEFAULT_UPLOAD_ID) -> Var: ...
25
25
  @CallableEventSpec
26
26
  def clear_selected_files(id_: str = DEFAULT_UPLOAD_ID) -> EventSpec: ...
27
27
  def cancel_upload(upload_id: str) -> EventSpec: ...
@@ -3,6 +3,8 @@
3
3
  # This file was generated by `reflex/utils/pyi_generator.py`!
4
4
  # ------------------------------------------------------
5
5
 
6
+ from reflex.components.react_router import link as a
7
+
6
8
  from . import elements
7
9
  from .elements.forms import (
8
10
  Button,
@@ -63,7 +65,6 @@ from .elements.inline import (
63
65
  Time,
64
66
  U,
65
67
  Wbr,
66
- a,
67
68
  abbr,
68
69
  b,
69
70
  bdi,
@@ -73,6 +73,9 @@ class Meta(BaseHTML): # Inherits common attributes from BaseHTML
73
73
  # Specifies a name for the metadata
74
74
  name: Var[str]
75
75
 
76
+ # The type of metadata value.
77
+ property: Var[str]
78
+
76
79
 
77
80
  class Title(Element):
78
81
  """Display the title element."""
@@ -803,6 +803,7 @@ class Meta(BaseHTML):
803
803
  content: Var[str] | str | None = None,
804
804
  http_equiv: Var[str] | str | None = None,
805
805
  name: Var[str] | str | None = None,
806
+ property: Var[str] | str | None = None,
806
807
  access_key: Var[str] | str | None = None,
807
808
  auto_capitalize: Literal[
808
809
  "characters", "none", "off", "on", "sentences", "words"
@@ -1018,6 +1019,7 @@ class Meta(BaseHTML):
1018
1019
  content: Defines the content of the metadata
1019
1020
  http_equiv: Provides an HTTP header for the information/value of the content attribute
1020
1021
  name: Specifies a name for the metadata
1022
+ property: The type of metadata value.
1021
1023
  access_key: Provides a hint for generating a keyboard shortcut for the current element.
1022
1024
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
1023
1025
  content_editable: Indicates whether the element's content is editable.
@@ -431,6 +431,14 @@ class AccordionIcon(Icon):
431
431
  return super().create(tag="chevron_down", class_name=cls_name, **props)
432
432
 
433
433
 
434
+ SLIDE_DOWN = Var(
435
+ r'keyframes({ from: { height: 0 }, to: { height: "var(--radix-accordion-content-height)" } })'
436
+ )
437
+ SLIDE_UP = Var(
438
+ r'keyframes({ from: { height: "var(--radix-accordion-content-height)" }, to: { height: 0 } })'
439
+ )
440
+
441
+
434
442
  class AccordionContent(AccordionComponent):
435
443
  """An accordion component."""
436
444
 
@@ -464,44 +472,17 @@ class AccordionContent(AccordionComponent):
464
472
 
465
473
  return super().create(*children, class_name=cls_name, **props)
466
474
 
467
- def add_custom_code(self) -> list[str]:
468
- """Add custom code to the component.
469
-
470
- Returns:
471
- The custom code of the component.
472
- """
473
- return [
474
- """
475
- const slideDown = keyframes`
476
- from {
477
- height: 0;
478
- }
479
- to {
480
- height: var(--radix-accordion-content-height);
481
- }
482
- `
483
- const slideUp = keyframes`
484
- from {
485
- height: var(--radix-accordion-content-height);
486
- }
487
- to {
488
- height: 0;
489
- }
490
- `
491
- """
492
- ]
493
-
494
475
  def add_style(self) -> dict[str, Any] | None:
495
476
  """Add style to the component.
496
477
 
497
478
  Returns:
498
479
  The style of the component.
499
480
  """
500
- slide_down = Var("slideDown").to(str) + Var.create(
481
+ slide_down = SLIDE_DOWN.to(str) + Var.create(
501
482
  " var(--animation-duration) var(--animation-easing)",
502
483
  )
503
484
 
504
- slide_up = Var("slideUp").to(str) + Var.create(
485
+ slide_up = SLIDE_UP.to(str) + Var.create(
505
486
  " var(--animation-duration) var(--animation-easing)",
506
487
  )
507
488
 
@@ -706,6 +706,13 @@ class AccordionIcon(Icon):
706
706
  The Accordion icon Component.
707
707
  """
708
708
 
709
+ SLIDE_DOWN = Var(
710
+ 'keyframes({ from: { height: 0 }, to: { height: "var(--radix-accordion-content-height)" } })'
711
+ )
712
+ SLIDE_UP = Var(
713
+ 'keyframes({ from: { height: "var(--radix-accordion-content-height)" }, to: { height: 0 } })'
714
+ )
715
+
709
716
  class AccordionContent(AccordionComponent):
710
717
  def add_imports(self) -> dict: ...
711
718
  @classmethod
@@ -824,7 +831,6 @@ class AccordionContent(AccordionComponent):
824
831
  The Accordion content Component.
825
832
  """
826
833
 
827
- def add_custom_code(self) -> list[str]: ...
828
834
  def add_style(self) -> dict[str, Any] | None: ...
829
835
 
830
836
  class Accordion(ComponentNamespace):