reflex 0.7.12a1__py3-none-any.whl → 0.7.13__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 (55) hide show
  1. reflex/.templates/jinja/app/rxconfig.py.jinja2 +1 -0
  2. reflex/.templates/web/postcss.config.js +0 -1
  3. reflex/.templates/web/utils/state.js +1 -1
  4. reflex/__init__.py +1 -0
  5. reflex/__init__.pyi +1 -0
  6. reflex/app.py +101 -29
  7. reflex/compiler/compiler.py +11 -62
  8. reflex/compiler/templates.py +12 -3
  9. reflex/compiler/utils.py +20 -4
  10. reflex/components/component.py +366 -88
  11. reflex/components/core/helmet.pyi +66 -0
  12. reflex/components/datadisplay/code.py +1 -1
  13. reflex/components/datadisplay/shiki_code_block.py +97 -86
  14. reflex/components/datadisplay/shiki_code_block.pyi +4 -2
  15. reflex/components/el/elements/forms.py +1 -1
  16. reflex/components/lucide/icon.py +2 -1
  17. reflex/components/lucide/icon.pyi +1 -0
  18. reflex/components/plotly/plotly.py +2 -2
  19. reflex/components/plotly/plotly.pyi +2 -3
  20. reflex/components/radix/primitives/accordion.py +1 -1
  21. reflex/components/radix/primitives/drawer.py +1 -1
  22. reflex/components/radix/primitives/form.py +1 -1
  23. reflex/components/radix/themes/base.py +4 -11
  24. reflex/components/radix/themes/components/icon_button.py +2 -2
  25. reflex/components/radix/themes/components/text_field.py +3 -0
  26. reflex/components/radix/themes/components/text_field.pyi +2 -0
  27. reflex/components/radix/themes/layout/list.py +1 -1
  28. reflex/components/tags/iter_tag.py +3 -5
  29. reflex/config.py +57 -7
  30. reflex/constants/__init__.py +0 -2
  31. reflex/event.py +154 -93
  32. reflex/experimental/client_state.py +3 -1
  33. reflex/plugins/__init__.py +7 -0
  34. reflex/plugins/base.py +101 -0
  35. reflex/plugins/tailwind_v3.py +255 -0
  36. reflex/plugins/tailwind_v4.py +258 -0
  37. reflex/state.py +24 -3
  38. reflex/utils/build.py +1 -1
  39. reflex/utils/console.py +1 -1
  40. reflex/utils/exec.py +23 -0
  41. reflex/utils/path_ops.py +26 -6
  42. reflex/utils/prerequisites.py +21 -90
  43. reflex/utils/pyi_generator.py +12 -2
  44. reflex/utils/types.py +15 -1
  45. reflex/vars/base.py +59 -4
  46. reflex/vars/object.py +8 -0
  47. {reflex-0.7.12a1.dist-info → reflex-0.7.13.dist-info}/METADATA +2 -2
  48. {reflex-0.7.12a1.dist-info → reflex-0.7.13.dist-info}/RECORD +52 -50
  49. scripts/hatch_build.py +17 -0
  50. reflex/.templates/jinja/web/tailwind.config.js.jinja2 +0 -66
  51. reflex/.templates/web/styles/tailwind.css +0 -6
  52. reflex/constants/style.py +0 -16
  53. {reflex-0.7.12a1.dist-info → reflex-0.7.13.dist-info}/WHEEL +0 -0
  54. {reflex-0.7.12a1.dist-info → reflex-0.7.13.dist-info}/entry_points.txt +0 -0
  55. {reflex-0.7.12a1.dist-info → reflex-0.7.13.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,66 @@
1
+ """Stub file for reflex/components/core/helmet.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, overload
8
+
9
+ from reflex.components.component import Component
10
+ from reflex.components.core.breakpoints import Breakpoints
11
+ from reflex.event import EventType
12
+ from reflex.vars.base import Var
13
+
14
+ class Helmet(Component):
15
+ @overload
16
+ @classmethod
17
+ def create( # type: ignore
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
+ autofocus: bool | None = None,
30
+ custom_attrs: dict[str, Var | Any] | None = None,
31
+ on_blur: EventType[()] | None = None,
32
+ on_click: EventType[()] | None = None,
33
+ on_context_menu: EventType[()] | None = None,
34
+ on_double_click: EventType[()] | None = None,
35
+ on_focus: EventType[()] | None = None,
36
+ on_mount: EventType[()] | None = None,
37
+ on_mouse_down: EventType[()] | None = None,
38
+ on_mouse_enter: EventType[()] | None = None,
39
+ on_mouse_leave: EventType[()] | None = None,
40
+ on_mouse_move: EventType[()] | None = None,
41
+ on_mouse_out: EventType[()] | None = None,
42
+ on_mouse_over: EventType[()] | None = None,
43
+ on_mouse_up: EventType[()] | None = None,
44
+ on_scroll: EventType[()] | None = None,
45
+ on_unmount: EventType[()] | None = None,
46
+ **props,
47
+ ) -> Helmet:
48
+ """Create the component.
49
+
50
+ Args:
51
+ *children: The children of the component.
52
+ style: The style of the component.
53
+ key: A unique key for the component.
54
+ id: The id for the component.
55
+ ref: The Var to pass as the ref to the component.
56
+ class_name: The class name for the component.
57
+ autofocus: Whether the component should take the focus once the page is loaded
58
+ custom_attrs: custom attribute
59
+ **props: The props of the component.
60
+
61
+ Returns:
62
+ The component.
63
+ """
64
+ ...
65
+
66
+ helmet = Helmet.create
@@ -546,7 +546,7 @@ if ({language_var!s}) {{
546
546
  }}""",
547
547
  _var_data=VarData(
548
548
  imports={
549
- cls.__fields__["library"].default: [
549
+ cls.get_fields()["library"].default_value(): [
550
550
  ImportVar(tag="PrismAsyncLight", alias="SyntaxHighlighter")
551
551
  ]
552
552
  },
@@ -2,11 +2,12 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import dataclasses
5
6
  import re
6
7
  from collections import defaultdict
8
+ from dataclasses import dataclass
7
9
  from typing import Any, Literal
8
10
 
9
- from reflex.base import Base
10
11
  from reflex.components.component import Component, ComponentNamespace
11
12
  from reflex.components.core.colors import color
12
13
  from reflex.components.core.cond import color_mode_cond
@@ -410,99 +411,109 @@ class ShikiDecorations(NoExtrasAllowedProps):
410
411
  always_wrap: bool = False
411
412
 
412
413
 
413
- class ShikiBaseTransformers(Base):
414
+ @dataclass(kw_only=True)
415
+ class ShikiBaseTransformers:
414
416
  """Base for creating transformers."""
415
417
 
416
- library: str
417
- fns: list[FunctionStringVar]
418
- style: Style | None
418
+ library: str = ""
419
+ fns: list[FunctionStringVar] = dataclasses.field(default_factory=list)
420
+ style: Style | None = dataclasses.field(default=None)
419
421
 
420
422
 
423
+ @dataclass(kw_only=True)
421
424
  class ShikiJsTransformer(ShikiBaseTransformers):
422
425
  """A Wrapped shikijs transformer."""
423
426
 
424
427
  library: str = "@shikijs/transformers@3.3.0"
425
- fns: list[FunctionStringVar] = [
426
- FunctionStringVar.create(fn) for fn in SHIKIJS_TRANSFORMER_FNS
427
- ]
428
- style: Style | None = Style(
429
- {
430
- "code": {"line-height": "1.7", "font-size": "0.875em", "display": "grid"},
431
- # Diffs
432
- ".diff": {
433
- "margin": "0 -24px",
434
- "padding": "0 24px",
435
- "width": "calc(100% + 48px)",
436
- "display": "inline-block",
437
- },
438
- ".diff.add": {
439
- "background-color": "rgba(16, 185, 129, .14)",
440
- "position": "relative",
441
- },
442
- ".diff.remove": {
443
- "background-color": "rgba(244, 63, 94, .14)",
444
- "opacity": "0.7",
445
- "position": "relative",
446
- },
447
- ".diff.remove:after": {
448
- "position": "absolute",
449
- "left": "10px",
450
- "content": "'-'",
451
- "color": "#b34e52",
452
- },
453
- ".diff.add:after": {
454
- "position": "absolute",
455
- "left": "10px",
456
- "content": "'+'",
457
- "color": "#18794e",
458
- },
459
- # Highlight
460
- ".highlighted": {
461
- "background-color": "rgba(142, 150, 170, .14)",
462
- "margin": "0 -24px",
463
- "padding": "0 24px",
464
- "width": "calc(100% + 48px)",
465
- "display": "inline-block",
466
- },
467
- ".highlighted.error": {
468
- "background-color": "rgba(244, 63, 94, .14)",
469
- },
470
- ".highlighted.warning": {
471
- "background-color": "rgba(234, 179, 8, .14)",
472
- },
473
- # Highlighted Word
474
- ".highlighted-word": {
475
- "background-color": color("gray", 2),
476
- "border": f"1px solid {color('gray', 5)}",
477
- "padding": "1px 3px",
478
- "margin": "-1px -3px",
479
- "border-radius": "4px",
480
- },
481
- # Focused Lines
482
- ".has-focused .line:not(.focused)": {
483
- "opacity": "0.7",
484
- "filter": "blur(0.095rem)",
485
- "transition": "filter .35s, opacity .35s",
486
- },
487
- ".has-focused:hover .line:not(.focused)": {
488
- "opacity": "1",
489
- "filter": "none",
490
- },
491
- # White Space
492
- # ".tab, .space": {
493
- # "position": "relative", # noqa: ERA001
494
- # },
495
- # ".tab::before": {
496
- # "content": "'⇥'", # noqa: ERA001
497
- # "position": "absolute", # noqa: ERA001
498
- # "opacity": "0.3",# noqa: ERA001
499
- # },
500
- # ".space::before": {
501
- # "content": "'·'", # noqa: ERA001
502
- # "position": "absolute", # noqa: ERA001
503
- # "opacity": "0.3", # noqa: ERA001
504
- # },
505
- }
428
+ fns: list[FunctionStringVar] = dataclasses.field(
429
+ default_factory=lambda: [
430
+ FunctionStringVar.create(fn) for fn in SHIKIJS_TRANSFORMER_FNS
431
+ ]
432
+ )
433
+ style: Style | None = dataclasses.field(
434
+ default_factory=lambda: Style(
435
+ {
436
+ "code": {
437
+ "line-height": "1.7",
438
+ "font-size": "0.875em",
439
+ "display": "grid",
440
+ },
441
+ # Diffs
442
+ ".diff": {
443
+ "margin": "0 -24px",
444
+ "padding": "0 24px",
445
+ "width": "calc(100% + 48px)",
446
+ "display": "inline-block",
447
+ },
448
+ ".diff.add": {
449
+ "background-color": "rgba(16, 185, 129, .14)",
450
+ "position": "relative",
451
+ },
452
+ ".diff.remove": {
453
+ "background-color": "rgba(244, 63, 94, .14)",
454
+ "opacity": "0.7",
455
+ "position": "relative",
456
+ },
457
+ ".diff.remove:after": {
458
+ "position": "absolute",
459
+ "left": "10px",
460
+ "content": "'-'",
461
+ "color": "#b34e52",
462
+ },
463
+ ".diff.add:after": {
464
+ "position": "absolute",
465
+ "left": "10px",
466
+ "content": "'+'",
467
+ "color": "#18794e",
468
+ },
469
+ # Highlight
470
+ ".highlighted": {
471
+ "background-color": "rgba(142, 150, 170, .14)",
472
+ "margin": "0 -24px",
473
+ "padding": "0 24px",
474
+ "width": "calc(100% + 48px)",
475
+ "display": "inline-block",
476
+ },
477
+ ".highlighted.error": {
478
+ "background-color": "rgba(244, 63, 94, .14)",
479
+ },
480
+ ".highlighted.warning": {
481
+ "background-color": "rgba(234, 179, 8, .14)",
482
+ },
483
+ # Highlighted Word
484
+ ".highlighted-word": {
485
+ "background-color": color("gray", 2),
486
+ "border": f"1px solid {color('gray', 5)}",
487
+ "padding": "1px 3px",
488
+ "margin": "-1px -3px",
489
+ "border-radius": "4px",
490
+ },
491
+ # Focused Lines
492
+ ".has-focused .line:not(.focused)": {
493
+ "opacity": "0.7",
494
+ "filter": "blur(0.095rem)",
495
+ "transition": "filter .35s, opacity .35s",
496
+ },
497
+ ".has-focused:hover .line:not(.focused)": {
498
+ "opacity": "1",
499
+ "filter": "none",
500
+ },
501
+ # White Space
502
+ # ".tab, .space": {
503
+ # "position": "relative", # noqa: ERA001
504
+ # },
505
+ # ".tab::before": {
506
+ # "content": "'⇥'", # noqa: ERA001
507
+ # "position": "absolute", # noqa: ERA001
508
+ # "opacity": "0.3",# noqa: ERA001
509
+ # },
510
+ # ".space::before": {
511
+ # "content": "'·'", # noqa: ERA001
512
+ # "position": "absolute", # noqa: ERA001
513
+ # "opacity": "0.3", # noqa: ERA001
514
+ # },
515
+ }
516
+ )
506
517
  )
507
518
 
508
519
  def __init__(self, **kwargs):
@@ -4,9 +4,9 @@
4
4
  # This file was generated by `reflex/utils/pyi_generator.py`!
5
5
  # ------------------------------------------------------
6
6
  from collections.abc import Mapping, Sequence
7
+ from dataclasses import dataclass
7
8
  from typing import Any, Literal, overload
8
9
 
9
- from reflex.base import Base
10
10
  from reflex.components.component import Component, ComponentNamespace
11
11
  from reflex.components.core.breakpoints import Breakpoints
12
12
  from reflex.components.markdown.markdown import MarkdownComponentMap
@@ -343,11 +343,13 @@ class ShikiDecorations(NoExtrasAllowedProps):
343
343
  properties: dict[str, Any]
344
344
  always_wrap: bool
345
345
 
346
- class ShikiBaseTransformers(Base):
346
+ @dataclass(kw_only=True)
347
+ class ShikiBaseTransformers:
347
348
  library: str
348
349
  fns: list[FunctionStringVar]
349
350
  style: Style | None
350
351
 
352
+ @dataclass(kw_only=True)
351
353
  class ShikiJsTransformer(ShikiBaseTransformers):
352
354
  library: str
353
355
  fns: list[FunctionStringVar]
@@ -189,7 +189,7 @@ class Form(BaseHTML):
189
189
  # Render the form hooks and use the hash of the resulting code to create a unique name.
190
190
  props["handle_submit_unique_name"] = ""
191
191
  form = super().create(*children, **props)
192
- form.handle_submit_unique_name = md5(
192
+ form.handle_submit_unique_name = md5( # pyright: ignore[reportAttributeAccessIssue]
193
193
  str(form._get_all_hooks()).encode("utf-8")
194
194
  ).hexdigest()
195
195
  return form
@@ -10,7 +10,7 @@ from reflex.vars.sequence import LiteralStringVar, StringVar
10
10
  class LucideIconComponent(Component):
11
11
  """Lucide Icon Component."""
12
12
 
13
- library = "lucide-react@0.510.0"
13
+ library = "lucide-react@0.511.0"
14
14
 
15
15
 
16
16
  class Icon(LucideIconComponent):
@@ -1463,6 +1463,7 @@ LUCIDE_ICON_LIST = [
1463
1463
  "square_dashed_bottom_code",
1464
1464
  "square_dashed_kanban",
1465
1465
  "square_dashed_mouse_pointer",
1466
+ "square_dashed_top_solid",
1466
1467
  "square_divide",
1467
1468
  "square_dot",
1468
1469
  "square_equal",
@@ -1540,6 +1540,7 @@ LUCIDE_ICON_LIST = [
1540
1540
  "square_dashed_bottom_code",
1541
1541
  "square_dashed_kanban",
1542
1542
  "square_dashed_mouse_pointer",
1543
+ "square_dashed_top_solid",
1543
1544
  "square_divide",
1544
1545
  "square_dot",
1545
1546
  "square_equal",
@@ -12,9 +12,9 @@ from reflex.utils.imports import ImportDict, ImportVar
12
12
  from reflex.vars.base import LiteralVar, Var
13
13
 
14
14
  try:
15
- from plotly.graph_objects import Figure, layout
15
+ from plotly.graph_objs import Figure
16
+ from plotly.graph_objs.layout import Template
16
17
 
17
- Template = layout.Template
18
18
  except ImportError:
19
19
  console.warn("Plotly is not installed. Please run `pip install plotly`.")
20
20
  Figure = Any
@@ -14,9 +14,8 @@ from reflex.utils.imports import ImportDict
14
14
  from reflex.vars.base import Var
15
15
 
16
16
  try:
17
- from plotly.graph_objects import Figure, layout
18
-
19
- Template = layout.Template
17
+ from plotly.graph_objs import Figure
18
+ from plotly.graph_objs.layout import Template
20
19
  except ImportError:
21
20
  console.warn("Plotly is not installed. Please run `pip install plotly`.")
22
21
  Figure = Any
@@ -54,7 +54,7 @@ def _inherited_variant_selector(
54
54
  class AccordionComponent(RadixPrimitiveComponent):
55
55
  """Base class for all @radix-ui/accordion components."""
56
56
 
57
- library = "@radix-ui/react-accordion@1.2.10"
57
+ library = "@radix-ui/react-accordion@1.2.11"
58
58
 
59
59
  # The color scheme of the component.
60
60
  color_scheme: Var[LiteralAccentColor]
@@ -21,7 +21,7 @@ class DrawerComponent(RadixPrimitiveComponent):
21
21
 
22
22
  library = "vaul@1.1.2"
23
23
 
24
- lib_dependencies: list[str] = ["@radix-ui/react-dialog@1.1.13"]
24
+ lib_dependencies: list[str] = ["@radix-ui/react-dialog@1.1.14"]
25
25
 
26
26
 
27
27
  LiteralDirectionType = Literal["top", "bottom", "left", "right"]
@@ -17,7 +17,7 @@ from .base import RadixPrimitiveComponentWithClassName
17
17
  class FormComponent(RadixPrimitiveComponentWithClassName):
18
18
  """Base class for all @radix-ui/react-form components."""
19
19
 
20
- library = "@radix-ui/react-form@0.1.6"
20
+ library = "@radix-ui/react-form@0.1.7"
21
21
 
22
22
 
23
23
  class FormRoot(FormComponent, HTMLForm):
@@ -7,7 +7,6 @@ from typing import Any, ClassVar, Literal
7
7
  from reflex.components import Component
8
8
  from reflex.components.core.breakpoints import Responsive
9
9
  from reflex.components.tags import Tag
10
- from reflex.config import get_config
11
10
  from reflex.utils.imports import ImportDict, ImportVar
12
11
  from reflex.vars.base import Var
13
12
 
@@ -135,7 +134,9 @@ class RadixThemesComponent(Component):
135
134
  """
136
135
  component = super().create(*children, **props)
137
136
  if component.library is None:
138
- component.library = RadixThemesComponent.__fields__["library"].default
137
+ component.library = RadixThemesComponent.get_fields()[
138
+ "library"
139
+ ].default_value()
139
140
  component.alias = "RadixThemes" + (component.tag or type(component).__name__)
140
141
  return component
141
142
 
@@ -239,17 +240,9 @@ class Theme(RadixThemesComponent):
239
240
  Returns:
240
241
  The import dict.
241
242
  """
242
- _imports: ImportDict = {
243
+ return {
243
244
  "$/utils/theme.js": [ImportVar(tag="theme", is_default=True)],
244
245
  }
245
- if get_config().tailwind is None:
246
- # When tailwind is disabled, import the radix-ui styles directly because they will
247
- # not be included in the tailwind.css file.
248
- _imports[""] = ImportVar(
249
- tag="@radix-ui/themes/styles.css",
250
- install=False,
251
- )
252
- return _imports
253
246
 
254
247
  def _render(self, props: dict[str, Any] | None = None) -> Tag:
255
248
  tag = super()._render(props)
@@ -75,7 +75,7 @@ class IconButton(elements.Button, RadixLoadingProp, RadixThemesComponent):
75
75
  )
76
76
  if "size" in props:
77
77
  if isinstance(props["size"], str):
78
- children[0].size = RADIX_TO_LUCIDE_SIZE[props["size"]]
78
+ children[0].size = RADIX_TO_LUCIDE_SIZE[props["size"]] # pyright: ignore[reportAttributeAccessIssue]
79
79
  else:
80
80
  size_map_var = Match.create(
81
81
  props["size"],
@@ -84,7 +84,7 @@ class IconButton(elements.Button, RadixLoadingProp, RadixThemesComponent):
84
84
  )
85
85
  if not isinstance(size_map_var, Var):
86
86
  raise ValueError(f"Match did not return a Var: {size_map_var}")
87
- children[0].size = size_map_var
87
+ children[0].size = size_map_var # pyright: ignore[reportAttributeAccessIssue]
88
88
  return super().create(*children, **props)
89
89
 
90
90
  def add_style(self):
@@ -127,6 +127,9 @@ class TextFieldSlot(RadixThemesComponent):
127
127
  # Override theme color for text field slot
128
128
  color_scheme: Var[LiteralAccentColor]
129
129
 
130
+ # Which side of the input the slot should be placed on
131
+ side: Var[Literal["left", "right"]]
132
+
130
133
 
131
134
  class TextField(ComponentNamespace):
132
135
  """TextField components namespace."""
@@ -471,6 +471,7 @@ class TextFieldSlot(RadixThemesComponent):
471
471
  ]
472
472
  ]
473
473
  | None = None,
474
+ side: Literal["left", "right"] | Var[Literal["left", "right"]] | None = None,
474
475
  style: Sequence[Mapping[str, Any]]
475
476
  | Mapping[str, Any]
476
477
  | Var[Mapping[str, Any]]
@@ -507,6 +508,7 @@ class TextFieldSlot(RadixThemesComponent):
507
508
  Args:
508
509
  *children: Child components.
509
510
  color_scheme: Override theme color for text field slot
511
+ side: Which side of the input the slot should be placed on
510
512
  style: The style of the component.
511
513
  key: A unique key for the component.
512
514
  id: The id for the component.
@@ -170,7 +170,7 @@ class ListItem(Li, MarkdownComponentMap):
170
170
  """
171
171
  for child in children:
172
172
  if isinstance(child, Text):
173
- child.as_ = "span"
173
+ child.as_ = "span" # pyright: ignore[reportAttributeAccessIssue]
174
174
  elif isinstance(child, Icon) and "display" not in child.style:
175
175
  child.style["display"] = "inline"
176
176
  return super().create(*children, **props)
@@ -105,8 +105,8 @@ class IterTag(Tag):
105
105
  The rendered component.
106
106
  """
107
107
  # Import here to avoid circular imports.
108
+ from reflex.compiler.compiler import _into_component_once
108
109
  from reflex.components.base.fragment import Fragment
109
- from reflex.components.component import Component
110
110
  from reflex.components.core.cond import Cond
111
111
  from reflex.components.core.foreach import Foreach
112
112
 
@@ -128,11 +128,9 @@ class IterTag(Tag):
128
128
  if isinstance(component, (Foreach, Cond)):
129
129
  component = Fragment.create(component)
130
130
 
131
- # If the component is a tuple, unpack and wrap it in a fragment.
132
- if isinstance(component, tuple):
133
- component = Fragment.create(*component)
131
+ component = _into_component_once(component)
134
132
 
135
- if not isinstance(component, Component):
133
+ if component is None:
136
134
  raise ValueError("The render function must return a component.")
137
135
 
138
136
  # Set the component key.