reflex 0.5.3a2__py3-none-any.whl → 0.5.4__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.

Files changed (69) hide show
  1. reflex/.templates/apps/demo/code/webui/state.py +3 -2
  2. reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js +19 -20
  3. reflex/.templates/web/utils/state.js +6 -0
  4. reflex/__init__.py +7 -1
  5. reflex/__init__.pyi +2 -0
  6. reflex/app.py +2 -5
  7. reflex/compiler/compiler.py +2 -2
  8. reflex/components/chakra/base.py +3 -1
  9. reflex/components/chakra/forms/checkbox.py +1 -1
  10. reflex/components/chakra/forms/pininput.py +1 -1
  11. reflex/components/chakra/forms/rangeslider.py +1 -1
  12. reflex/components/chakra/navigation/link.py +3 -1
  13. reflex/components/component.py +43 -15
  14. reflex/components/core/banner.py +2 -1
  15. reflex/components/core/client_side_routing.py +3 -3
  16. reflex/components/core/client_side_routing.pyi +1 -0
  17. reflex/components/core/debounce.py +3 -1
  18. reflex/components/core/foreach.py +1 -1
  19. reflex/components/core/upload.py +2 -1
  20. reflex/components/datadisplay/code.py +4 -1
  21. reflex/components/datadisplay/dataeditor.py +11 -8
  22. reflex/components/datadisplay/dataeditor.pyi +1 -0
  23. reflex/components/el/elements/forms.py +25 -14
  24. reflex/components/el/elements/forms.pyi +2 -1
  25. reflex/components/markdown/markdown.py +17 -11
  26. reflex/components/markdown/markdown.pyi +12 -8
  27. reflex/components/plotly/plotly.py +82 -14
  28. reflex/components/plotly/plotly.pyi +15 -82
  29. reflex/components/radix/primitives/accordion.py +1 -1
  30. reflex/components/radix/themes/base.py +10 -2
  31. reflex/components/radix/themes/base.pyi +1 -0
  32. reflex/components/radix/themes/color_mode.py +1 -1
  33. reflex/components/radix/themes/components/checkbox.py +3 -1
  34. reflex/components/radix/themes/components/radio_group.py +6 -4
  35. reflex/components/radix/themes/components/separator.py +1 -1
  36. reflex/components/radix/themes/layout/container.py +1 -1
  37. reflex/components/radix/themes/layout/section.py +1 -1
  38. reflex/components/recharts/cartesian.py +42 -14
  39. reflex/components/recharts/cartesian.pyi +81 -17
  40. reflex/components/recharts/charts.py +12 -21
  41. reflex/components/recharts/charts.pyi +53 -14
  42. reflex/components/sonner/toast.py +37 -17
  43. reflex/components/sonner/toast.pyi +9 -5
  44. reflex/components/tags/tag.py +2 -1
  45. reflex/config.py +22 -14
  46. reflex/constants/__init__.py +2 -0
  47. reflex/constants/config.py +7 -0
  48. reflex/event.py +24 -15
  49. reflex/experimental/__init__.py +22 -2
  50. reflex/experimental/client_state.py +81 -23
  51. reflex/experimental/hooks.py +35 -35
  52. reflex/experimental/layout.py +17 -5
  53. reflex/experimental/layout.pyi +536 -0
  54. reflex/reflex.py +9 -5
  55. reflex/style.py +3 -2
  56. reflex/testing.py +44 -13
  57. reflex/utils/compat.py +5 -0
  58. reflex/utils/format.py +12 -2
  59. reflex/utils/processes.py +27 -0
  60. reflex/utils/pyi_generator.py +11 -4
  61. reflex/utils/serializers.py +114 -15
  62. reflex/utils/types.py +6 -2
  63. reflex/vars.py +57 -20
  64. reflex/vars.pyi +2 -2
  65. {reflex-0.5.3a2.dist-info → reflex-0.5.4.dist-info}/METADATA +1 -1
  66. {reflex-0.5.3a2.dist-info → reflex-0.5.4.dist-info}/RECORD +69 -68
  67. {reflex-0.5.3a2.dist-info → reflex-0.5.4.dist-info}/LICENSE +0 -0
  68. {reflex-0.5.3a2.dist-info → reflex-0.5.4.dist-info}/WHEEL +0 -0
  69. {reflex-0.5.3a2.dist-info → reflex-0.5.4.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,536 @@
1
+ """Stub file for reflex/experimental/layout.py"""
2
+ # ------------------- DO NOT EDIT ----------------------
3
+ # This file was generated by `reflex/utils/pyi_generator.py`!
4
+ # ------------------------------------------------------
5
+
6
+ from typing import Any, Dict, Literal, Optional, Union, overload
7
+ from reflex.vars import Var, BaseVar, ComputedVar
8
+ from reflex.event import EventChain, EventHandler, EventSpec
9
+ from reflex.style import Style
10
+ from typing import Any, List
11
+ from reflex import color, cond
12
+ from reflex.components.base.fragment import Fragment
13
+ from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
14
+ from reflex.components.radix.primitives.drawer import DrawerRoot, drawer
15
+ from reflex.components.radix.themes.components.icon_button import IconButton
16
+ from reflex.components.radix.themes.layout.box import Box
17
+ from reflex.components.radix.themes.layout.container import Container
18
+ from reflex.components.radix.themes.layout.stack import HStack
19
+ from reflex.event import call_script
20
+ from reflex.experimental import hooks
21
+ from reflex.state import ComponentState
22
+ from reflex.style import Style
23
+ from reflex.vars import Var
24
+
25
+ class Sidebar(Box, MemoizationLeaf):
26
+ @overload
27
+ @classmethod
28
+ def create( # type: ignore
29
+ cls,
30
+ *children,
31
+ access_key: Optional[
32
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
33
+ ] = None,
34
+ auto_capitalize: Optional[
35
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
36
+ ] = None,
37
+ content_editable: Optional[
38
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
39
+ ] = None,
40
+ context_menu: Optional[
41
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
42
+ ] = None,
43
+ dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None,
44
+ draggable: Optional[
45
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
46
+ ] = None,
47
+ enter_key_hint: Optional[
48
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
49
+ ] = None,
50
+ hidden: Optional[
51
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
52
+ ] = None,
53
+ input_mode: Optional[
54
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
55
+ ] = None,
56
+ item_prop: Optional[
57
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
58
+ ] = None,
59
+ lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None,
60
+ role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None,
61
+ slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None,
62
+ spell_check: Optional[
63
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
64
+ ] = None,
65
+ tab_index: Optional[
66
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
67
+ ] = None,
68
+ title: Optional[
69
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
70
+ ] = None,
71
+ style: Optional[Style] = None,
72
+ key: Optional[Any] = None,
73
+ id: Optional[Any] = None,
74
+ class_name: Optional[Any] = None,
75
+ autofocus: Optional[bool] = None,
76
+ custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
77
+ on_blur: Optional[
78
+ Union[EventHandler, EventSpec, list, function, BaseVar]
79
+ ] = None,
80
+ on_click: Optional[
81
+ Union[EventHandler, EventSpec, list, function, BaseVar]
82
+ ] = None,
83
+ on_context_menu: Optional[
84
+ Union[EventHandler, EventSpec, list, function, BaseVar]
85
+ ] = None,
86
+ on_double_click: Optional[
87
+ Union[EventHandler, EventSpec, list, function, BaseVar]
88
+ ] = None,
89
+ on_focus: Optional[
90
+ Union[EventHandler, EventSpec, list, function, BaseVar]
91
+ ] = None,
92
+ on_mount: Optional[
93
+ Union[EventHandler, EventSpec, list, function, BaseVar]
94
+ ] = None,
95
+ on_mouse_down: Optional[
96
+ Union[EventHandler, EventSpec, list, function, BaseVar]
97
+ ] = None,
98
+ on_mouse_enter: Optional[
99
+ Union[EventHandler, EventSpec, list, function, BaseVar]
100
+ ] = None,
101
+ on_mouse_leave: Optional[
102
+ Union[EventHandler, EventSpec, list, function, BaseVar]
103
+ ] = None,
104
+ on_mouse_move: Optional[
105
+ Union[EventHandler, EventSpec, list, function, BaseVar]
106
+ ] = None,
107
+ on_mouse_out: Optional[
108
+ Union[EventHandler, EventSpec, list, function, BaseVar]
109
+ ] = None,
110
+ on_mouse_over: Optional[
111
+ Union[EventHandler, EventSpec, list, function, BaseVar]
112
+ ] = None,
113
+ on_mouse_up: Optional[
114
+ Union[EventHandler, EventSpec, list, function, BaseVar]
115
+ ] = None,
116
+ on_scroll: Optional[
117
+ Union[EventHandler, EventSpec, list, function, BaseVar]
118
+ ] = None,
119
+ on_unmount: Optional[
120
+ Union[EventHandler, EventSpec, list, function, BaseVar]
121
+ ] = None,
122
+ **props
123
+ ) -> "Sidebar":
124
+ """Create the sidebar component.
125
+
126
+ Args:
127
+ children: The children components.
128
+ props: The properties of the sidebar.
129
+
130
+ Returns:
131
+ The sidebar component.
132
+ """
133
+ ...
134
+ def add_style(self) -> dict[str, Any] | None: ...
135
+ def add_hooks(self) -> List[Var]: ...
136
+
137
+ class StatefulSidebar(ComponentState):
138
+ open: bool
139
+
140
+ def toggle(self): ...
141
+ @classmethod
142
+ def get_component(cls, *children, **props): ...
143
+
144
+ class DrawerSidebar(DrawerRoot):
145
+ @overload
146
+ @classmethod
147
+ def create( # type: ignore
148
+ cls,
149
+ *children,
150
+ open: Optional[Union[Var[bool], bool]] = None,
151
+ should_scale_background: Optional[Union[Var[bool], bool]] = None,
152
+ close_threshold: Optional[Union[Var[float], float]] = None,
153
+ snap_points: Optional[List[Union[str, float]]] = None,
154
+ fade_from_index: Optional[Union[Var[int], int]] = None,
155
+ scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
156
+ modal: Optional[Union[Var[bool], bool]] = None,
157
+ direction: Optional[
158
+ Union[
159
+ Var[Literal["top", "bottom", "left", "right"]],
160
+ Literal["top", "bottom", "left", "right"],
161
+ ]
162
+ ] = None,
163
+ preventScrollRestoration: Optional[Union[Var[bool], bool]] = None,
164
+ as_child: Optional[Union[Var[bool], bool]] = None,
165
+ style: Optional[Style] = None,
166
+ key: Optional[Any] = None,
167
+ id: Optional[Any] = None,
168
+ class_name: Optional[Any] = None,
169
+ autofocus: Optional[bool] = None,
170
+ custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
171
+ on_blur: Optional[
172
+ Union[EventHandler, EventSpec, list, function, BaseVar]
173
+ ] = None,
174
+ on_click: Optional[
175
+ Union[EventHandler, EventSpec, list, function, BaseVar]
176
+ ] = None,
177
+ on_context_menu: Optional[
178
+ Union[EventHandler, EventSpec, list, function, BaseVar]
179
+ ] = None,
180
+ on_double_click: Optional[
181
+ Union[EventHandler, EventSpec, list, function, BaseVar]
182
+ ] = None,
183
+ on_focus: Optional[
184
+ Union[EventHandler, EventSpec, list, function, BaseVar]
185
+ ] = None,
186
+ on_mount: Optional[
187
+ Union[EventHandler, EventSpec, list, function, BaseVar]
188
+ ] = None,
189
+ on_mouse_down: Optional[
190
+ Union[EventHandler, EventSpec, list, function, BaseVar]
191
+ ] = None,
192
+ on_mouse_enter: Optional[
193
+ Union[EventHandler, EventSpec, list, function, BaseVar]
194
+ ] = None,
195
+ on_mouse_leave: Optional[
196
+ Union[EventHandler, EventSpec, list, function, BaseVar]
197
+ ] = None,
198
+ on_mouse_move: Optional[
199
+ Union[EventHandler, EventSpec, list, function, BaseVar]
200
+ ] = None,
201
+ on_mouse_out: Optional[
202
+ Union[EventHandler, EventSpec, list, function, BaseVar]
203
+ ] = None,
204
+ on_mouse_over: Optional[
205
+ Union[EventHandler, EventSpec, list, function, BaseVar]
206
+ ] = None,
207
+ on_mouse_up: Optional[
208
+ Union[EventHandler, EventSpec, list, function, BaseVar]
209
+ ] = None,
210
+ on_open_change: Optional[
211
+ Union[EventHandler, EventSpec, list, function, BaseVar]
212
+ ] = None,
213
+ on_scroll: Optional[
214
+ Union[EventHandler, EventSpec, list, function, BaseVar]
215
+ ] = None,
216
+ on_unmount: Optional[
217
+ Union[EventHandler, EventSpec, list, function, BaseVar]
218
+ ] = None,
219
+ **props
220
+ ) -> "DrawerSidebar":
221
+ """Create the sidebar component.
222
+
223
+ Args:
224
+ children: The children components.
225
+ props: The properties of the sidebar.
226
+
227
+ Returns:
228
+ The drawer sidebar component.
229
+ """
230
+ ...
231
+
232
+ sidebar_trigger_style = {
233
+ "position": "fixed",
234
+ "z_index": "15",
235
+ "color": color("accent", 12),
236
+ "background_color": "transparent",
237
+ "padding": "0",
238
+ }
239
+
240
+ class SidebarTrigger(Fragment):
241
+ @overload
242
+ @classmethod
243
+ def create( # type: ignore
244
+ cls,
245
+ *children,
246
+ style: Optional[Style] = None,
247
+ key: Optional[Any] = None,
248
+ id: Optional[Any] = None,
249
+ class_name: Optional[Any] = None,
250
+ autofocus: Optional[bool] = None,
251
+ custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
252
+ on_blur: Optional[
253
+ Union[EventHandler, EventSpec, list, function, BaseVar]
254
+ ] = None,
255
+ on_click: Optional[
256
+ Union[EventHandler, EventSpec, list, function, BaseVar]
257
+ ] = None,
258
+ on_context_menu: Optional[
259
+ Union[EventHandler, EventSpec, list, function, BaseVar]
260
+ ] = None,
261
+ on_double_click: Optional[
262
+ Union[EventHandler, EventSpec, list, function, BaseVar]
263
+ ] = None,
264
+ on_focus: Optional[
265
+ Union[EventHandler, EventSpec, list, function, BaseVar]
266
+ ] = None,
267
+ on_mount: Optional[
268
+ Union[EventHandler, EventSpec, list, function, BaseVar]
269
+ ] = None,
270
+ on_mouse_down: Optional[
271
+ Union[EventHandler, EventSpec, list, function, BaseVar]
272
+ ] = None,
273
+ on_mouse_enter: Optional[
274
+ Union[EventHandler, EventSpec, list, function, BaseVar]
275
+ ] = None,
276
+ on_mouse_leave: Optional[
277
+ Union[EventHandler, EventSpec, list, function, BaseVar]
278
+ ] = None,
279
+ on_mouse_move: Optional[
280
+ Union[EventHandler, EventSpec, list, function, BaseVar]
281
+ ] = None,
282
+ on_mouse_out: Optional[
283
+ Union[EventHandler, EventSpec, list, function, BaseVar]
284
+ ] = None,
285
+ on_mouse_over: Optional[
286
+ Union[EventHandler, EventSpec, list, function, BaseVar]
287
+ ] = None,
288
+ on_mouse_up: Optional[
289
+ Union[EventHandler, EventSpec, list, function, BaseVar]
290
+ ] = None,
291
+ on_scroll: Optional[
292
+ Union[EventHandler, EventSpec, list, function, BaseVar]
293
+ ] = None,
294
+ on_unmount: Optional[
295
+ Union[EventHandler, EventSpec, list, function, BaseVar]
296
+ ] = None,
297
+ **props
298
+ ) -> "SidebarTrigger":
299
+ """Create the sidebar trigger component.
300
+
301
+ Args:
302
+ sidebar: The sidebar component.
303
+ props: The properties of the sidebar trigger.
304
+
305
+ Returns:
306
+ The sidebar trigger component.
307
+ """
308
+ ...
309
+
310
+ class Layout(Box):
311
+ @overload
312
+ @classmethod
313
+ def create( # type: ignore
314
+ cls,
315
+ *children,
316
+ sidebar: Optional[Component] = None,
317
+ access_key: Optional[
318
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
319
+ ] = None,
320
+ auto_capitalize: Optional[
321
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
322
+ ] = None,
323
+ content_editable: Optional[
324
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
325
+ ] = None,
326
+ context_menu: Optional[
327
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
328
+ ] = None,
329
+ dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None,
330
+ draggable: Optional[
331
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
332
+ ] = None,
333
+ enter_key_hint: Optional[
334
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
335
+ ] = None,
336
+ hidden: Optional[
337
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
338
+ ] = None,
339
+ input_mode: Optional[
340
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
341
+ ] = None,
342
+ item_prop: Optional[
343
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
344
+ ] = None,
345
+ lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None,
346
+ role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None,
347
+ slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None,
348
+ spell_check: Optional[
349
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
350
+ ] = None,
351
+ tab_index: Optional[
352
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
353
+ ] = None,
354
+ title: Optional[
355
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
356
+ ] = None,
357
+ style: Optional[Style] = None,
358
+ key: Optional[Any] = None,
359
+ id: Optional[Any] = None,
360
+ class_name: Optional[Any] = None,
361
+ autofocus: Optional[bool] = None,
362
+ custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
363
+ on_blur: Optional[
364
+ Union[EventHandler, EventSpec, list, function, BaseVar]
365
+ ] = None,
366
+ on_click: Optional[
367
+ Union[EventHandler, EventSpec, list, function, BaseVar]
368
+ ] = None,
369
+ on_context_menu: Optional[
370
+ Union[EventHandler, EventSpec, list, function, BaseVar]
371
+ ] = None,
372
+ on_double_click: Optional[
373
+ Union[EventHandler, EventSpec, list, function, BaseVar]
374
+ ] = None,
375
+ on_focus: Optional[
376
+ Union[EventHandler, EventSpec, list, function, BaseVar]
377
+ ] = None,
378
+ on_mount: Optional[
379
+ Union[EventHandler, EventSpec, list, function, BaseVar]
380
+ ] = None,
381
+ on_mouse_down: Optional[
382
+ Union[EventHandler, EventSpec, list, function, BaseVar]
383
+ ] = None,
384
+ on_mouse_enter: Optional[
385
+ Union[EventHandler, EventSpec, list, function, BaseVar]
386
+ ] = None,
387
+ on_mouse_leave: Optional[
388
+ Union[EventHandler, EventSpec, list, function, BaseVar]
389
+ ] = None,
390
+ on_mouse_move: Optional[
391
+ Union[EventHandler, EventSpec, list, function, BaseVar]
392
+ ] = None,
393
+ on_mouse_out: Optional[
394
+ Union[EventHandler, EventSpec, list, function, BaseVar]
395
+ ] = None,
396
+ on_mouse_over: Optional[
397
+ Union[EventHandler, EventSpec, list, function, BaseVar]
398
+ ] = None,
399
+ on_mouse_up: Optional[
400
+ Union[EventHandler, EventSpec, list, function, BaseVar]
401
+ ] = None,
402
+ on_scroll: Optional[
403
+ Union[EventHandler, EventSpec, list, function, BaseVar]
404
+ ] = None,
405
+ on_unmount: Optional[
406
+ Union[EventHandler, EventSpec, list, function, BaseVar]
407
+ ] = None,
408
+ **props
409
+ ) -> "Layout":
410
+ """Create the layout component.
411
+
412
+ Args:
413
+ content: The content component.
414
+ sidebar: The sidebar component.
415
+ props: The properties of the layout.
416
+
417
+ Returns:
418
+ The layout component.
419
+ """
420
+ ...
421
+
422
+ class LayoutNamespace(ComponentNamespace):
423
+ drawer_sidebar = staticmethod(DrawerSidebar.create)
424
+ stateful_sidebar = staticmethod(StatefulSidebar.create)
425
+ sidebar = staticmethod(Sidebar.create)
426
+
427
+ @staticmethod
428
+ def __call__(
429
+ *children,
430
+ sidebar: Optional[Component] = None,
431
+ access_key: Optional[
432
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
433
+ ] = None,
434
+ auto_capitalize: Optional[
435
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
436
+ ] = None,
437
+ content_editable: Optional[
438
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
439
+ ] = None,
440
+ context_menu: Optional[
441
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
442
+ ] = None,
443
+ dir: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None,
444
+ draggable: Optional[
445
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
446
+ ] = None,
447
+ enter_key_hint: Optional[
448
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
449
+ ] = None,
450
+ hidden: Optional[
451
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
452
+ ] = None,
453
+ input_mode: Optional[
454
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
455
+ ] = None,
456
+ item_prop: Optional[
457
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
458
+ ] = None,
459
+ lang: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None,
460
+ role: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None,
461
+ slot: Optional[Union[Var[Union[str, int, bool]], Union[str, int, bool]]] = None,
462
+ spell_check: Optional[
463
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
464
+ ] = None,
465
+ tab_index: Optional[
466
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
467
+ ] = None,
468
+ title: Optional[
469
+ Union[Var[Union[str, int, bool]], Union[str, int, bool]]
470
+ ] = None,
471
+ style: Optional[Style] = None,
472
+ key: Optional[Any] = None,
473
+ id: Optional[Any] = None,
474
+ class_name: Optional[Any] = None,
475
+ autofocus: Optional[bool] = None,
476
+ custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
477
+ on_blur: Optional[
478
+ Union[EventHandler, EventSpec, list, function, BaseVar]
479
+ ] = None,
480
+ on_click: Optional[
481
+ Union[EventHandler, EventSpec, list, function, BaseVar]
482
+ ] = None,
483
+ on_context_menu: Optional[
484
+ Union[EventHandler, EventSpec, list, function, BaseVar]
485
+ ] = None,
486
+ on_double_click: Optional[
487
+ Union[EventHandler, EventSpec, list, function, BaseVar]
488
+ ] = None,
489
+ on_focus: Optional[
490
+ Union[EventHandler, EventSpec, list, function, BaseVar]
491
+ ] = None,
492
+ on_mount: Optional[
493
+ Union[EventHandler, EventSpec, list, function, BaseVar]
494
+ ] = None,
495
+ on_mouse_down: Optional[
496
+ Union[EventHandler, EventSpec, list, function, BaseVar]
497
+ ] = None,
498
+ on_mouse_enter: Optional[
499
+ Union[EventHandler, EventSpec, list, function, BaseVar]
500
+ ] = None,
501
+ on_mouse_leave: Optional[
502
+ Union[EventHandler, EventSpec, list, function, BaseVar]
503
+ ] = None,
504
+ on_mouse_move: Optional[
505
+ Union[EventHandler, EventSpec, list, function, BaseVar]
506
+ ] = None,
507
+ on_mouse_out: Optional[
508
+ Union[EventHandler, EventSpec, list, function, BaseVar]
509
+ ] = None,
510
+ on_mouse_over: Optional[
511
+ Union[EventHandler, EventSpec, list, function, BaseVar]
512
+ ] = None,
513
+ on_mouse_up: Optional[
514
+ Union[EventHandler, EventSpec, list, function, BaseVar]
515
+ ] = None,
516
+ on_scroll: Optional[
517
+ Union[EventHandler, EventSpec, list, function, BaseVar]
518
+ ] = None,
519
+ on_unmount: Optional[
520
+ Union[EventHandler, EventSpec, list, function, BaseVar]
521
+ ] = None,
522
+ **props
523
+ ) -> "Layout":
524
+ """Create the layout component.
525
+
526
+ Args:
527
+ content: The content component.
528
+ sidebar: The sidebar component.
529
+ props: The properties of the layout.
530
+
531
+ Returns:
532
+ The layout component.
533
+ """
534
+ ...
535
+
536
+ layout = LayoutNamespace()
reflex/reflex.py CHANGED
@@ -157,12 +157,16 @@ def _run(
157
157
  if prerequisites.needs_reinit(frontend=frontend):
158
158
  _init(name=config.app_name, loglevel=loglevel)
159
159
 
160
- # Find the next available open port.
161
- if frontend and processes.is_process_on_port(frontend_port):
162
- frontend_port = processes.change_port(frontend_port, "frontend")
160
+ # Find the next available open port if applicable.
161
+ if frontend:
162
+ frontend_port = processes.handle_port(
163
+ "frontend", frontend_port, str(constants.DefaultPorts.FRONTEND_PORT)
164
+ )
163
165
 
164
- if backend and processes.is_process_on_port(backend_port):
165
- backend_port = processes.change_port(backend_port, "backend")
166
+ if backend:
167
+ backend_port = processes.handle_port(
168
+ "backend", backend_port, str(constants.DefaultPorts.BACKEND_PORT)
169
+ )
166
170
 
167
171
  # Apply the new ports to the config.
168
172
  if frontend_port != str(config.frontend_port):
reflex/style.py CHANGED
@@ -12,6 +12,7 @@ from reflex.vars import BaseVar, Var, VarData
12
12
 
13
13
  VarData.update_forward_refs() # Ensure all type definitions are resolved
14
14
 
15
+ SYSTEM_COLOR_MODE: str = "system"
15
16
  LIGHT_COLOR_MODE: str = "light"
16
17
  DARK_COLOR_MODE: str = "dark"
17
18
 
@@ -78,7 +79,7 @@ def convert_item(style_item: str | Var) -> tuple[str, VarData | None]:
78
79
  return str(style_item), style_item._var_data
79
80
 
80
81
  # Otherwise, convert to Var to collapse VarData encoded in f-string.
81
- new_var = Var.create(style_item)
82
+ new_var = Var.create(style_item, _var_is_string=False)
82
83
  if new_var is not None and new_var._var_data:
83
84
  # The wrapped backtick is used to identify the Var for interpolation.
84
85
  return f"`{str(new_var)}`", new_var._var_data
@@ -203,7 +204,7 @@ class Style(dict):
203
204
  value: The value to set.
204
205
  """
205
206
  # Create a Var to collapse VarData encoded in f-string.
206
- _var = Var.create(value)
207
+ _var = Var.create(value, _var_is_string=False)
207
208
  if _var is not None:
208
209
  # Carry the imports/hooks when setting a Var as a value.
209
210
  self._var_data = VarData.merge(self._var_data, _var._var_data)
reflex/testing.py CHANGED
@@ -297,6 +297,27 @@ class AppHarness:
297
297
  self.backend_thread = threading.Thread(target=self.backend.run)
298
298
  self.backend_thread.start()
299
299
 
300
+ async def _reset_backend_state_manager(self):
301
+ """Reset the StateManagerRedis event loop affinity.
302
+
303
+ This is necessary when the backend is restarted and the state manager is a
304
+ StateManagerRedis instance.
305
+ """
306
+ if (
307
+ self.app_instance is not None
308
+ and isinstance(
309
+ self.app_instance.state_manager,
310
+ StateManagerRedis,
311
+ )
312
+ and self.app_instance.state is not None
313
+ ):
314
+ with contextlib.suppress(RuntimeError):
315
+ await self.app_instance.state_manager.close()
316
+ self.app_instance._state_manager = StateManagerRedis.create(
317
+ state=self.app_instance.state,
318
+ )
319
+ assert isinstance(self.app_instance.state_manager, StateManagerRedis)
320
+
300
321
  def _start_frontend(self):
301
322
  # Set up the frontend.
302
323
  with chdir(self.app_path):
@@ -520,7 +541,9 @@ class AppHarness:
520
541
  self,
521
542
  driver_clz: Optional[Type["WebDriver"]] = None,
522
543
  driver_kwargs: dict[str, Any] | None = None,
544
+ driver_options: ArgOptions | None = None,
523
545
  driver_option_args: List[str] | None = None,
546
+ driver_option_capabilities: dict[str, Any] | None = None,
524
547
  ) -> "WebDriver":
525
548
  """Get a selenium webdriver instance pointed at the app.
526
549
 
@@ -528,7 +551,9 @@ class AppHarness:
528
551
  driver_clz: webdriver.Chrome (default), webdriver.Firefox, webdriver.Safari,
529
552
  webdriver.Edge, etc
530
553
  driver_kwargs: additional keyword arguments to pass to the webdriver constructor
554
+ driver_options: selenium ArgOptions instance to pass to the webdriver constructor
531
555
  driver_option_args: additional arguments for the webdriver options
556
+ driver_option_capabilities: additional capabilities for the webdriver options
532
557
 
533
558
  Returns:
534
559
  Instance of the given webdriver navigated to the frontend url of the app.
@@ -544,37 +569,43 @@ class AppHarness:
544
569
  if self.frontend_url is None:
545
570
  raise RuntimeError("Frontend is not running.")
546
571
  want_headless = False
547
- options: ArgOptions | None = None
548
572
  if os.environ.get("APP_HARNESS_HEADLESS"):
549
573
  want_headless = True
550
574
  if driver_clz is None:
551
575
  requested_driver = os.environ.get("APP_HARNESS_DRIVER", "Chrome")
552
576
  driver_clz = getattr(webdriver, requested_driver)
553
- options = getattr(webdriver, f"{requested_driver}Options")()
577
+ if driver_options is None:
578
+ driver_options = getattr(webdriver, f"{requested_driver}Options")()
554
579
  if driver_clz is webdriver.Chrome:
555
- options = webdriver.ChromeOptions()
556
- options.add_argument("--class=AppHarness")
580
+ if driver_options is None:
581
+ driver_options = webdriver.ChromeOptions()
582
+ driver_options.add_argument("--class=AppHarness")
557
583
  if want_headless:
558
- options.add_argument("--headless=new")
584
+ driver_options.add_argument("--headless=new")
559
585
  elif driver_clz is webdriver.Firefox:
560
- options = webdriver.FirefoxOptions()
586
+ if driver_options is None:
587
+ driver_options = webdriver.FirefoxOptions()
561
588
  if want_headless:
562
- options.add_argument("-headless")
589
+ driver_options.add_argument("-headless")
563
590
  elif driver_clz is webdriver.Edge:
564
- options = webdriver.EdgeOptions()
591
+ if driver_options is None:
592
+ driver_options = webdriver.EdgeOptions()
565
593
  if want_headless:
566
- options.add_argument("headless")
567
- if options is None:
594
+ driver_options.add_argument("headless")
595
+ if driver_options is None:
568
596
  raise RuntimeError(f"Could not determine options for {driver_clz}")
569
597
  if args := os.environ.get("APP_HARNESS_DRIVER_ARGS"):
570
598
  for arg in args.split(","):
571
- options.add_argument(arg)
599
+ driver_options.add_argument(arg)
572
600
  if driver_option_args is not None:
573
601
  for arg in driver_option_args:
574
- options.add_argument(arg)
602
+ driver_options.add_argument(arg)
603
+ if driver_option_capabilities is not None:
604
+ for key, value in driver_option_capabilities.items():
605
+ driver_options.set_capability(key, value)
575
606
  if driver_kwargs is None:
576
607
  driver_kwargs = {}
577
- driver = driver_clz(options=options, **driver_kwargs) # type: ignore
608
+ driver = driver_clz(options=driver_options, **driver_kwargs) # type: ignore
578
609
  driver.get(self.frontend_url)
579
610
  self._frontends.append(driver)
580
611
  return driver