Skip to content

Commit e3cd9a1

Browse files
adhami3310masenf
authored andcommitted
clean up random fields that aren't marked correctly as not javascript fields (#5484)
* treat all is_javascript that are not events as vars * fix markdown element * clean up some stuff * pyi generate
1 parent 1148770 commit e3cd9a1

11 files changed

Lines changed: 55 additions & 50 deletions

File tree

pyi_hashes.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"reflex/components/base/error_boundary.pyi": "cb264905a4e8dd450f7a59c8ccee6280",
99
"reflex/components/base/fragment.pyi": "bf9f8d708d32ae475e8b492f29a1b853",
1010
"reflex/components/base/link.pyi": "12b3fd940e4acf8ee6016dfb8da34879",
11-
"reflex/components/base/meta.pyi": "96fdfb33ffe5ae3f5324526036be099f",
11+
"reflex/components/base/meta.pyi": "907920173adfabfe1bd6b066032f4ef7",
1212
"reflex/components/base/script.pyi": "43a0e21f257b10d2c76ed359284a9d80",
1313
"reflex/components/base/strict_mode.pyi": "d169c575d676c73edc6a3f593badfd1f",
1414
"reflex/components/core/__init__.pyi": "7ab6923c0e08c8990a1d2e8f7869ca38",
@@ -20,11 +20,11 @@
2020
"reflex/components/core/helmet.pyi": "20afb0edbadb506d5cf374f153b3c6cf",
2121
"reflex/components/core/html.pyi": "faf9bb353ef4784e7f17ac97c93ef697",
2222
"reflex/components/core/sticky.pyi": "cdf17e6cd287e7300acd25669701d117",
23-
"reflex/components/core/upload.pyi": "3abe07bdedc58a253accfc97f4207db8",
23+
"reflex/components/core/upload.pyi": "4a44f34dc8e9450a383ee60a87a69e2c",
2424
"reflex/components/datadisplay/__init__.pyi": "87eae833026739e8d48a9891e185b3c2",
25-
"reflex/components/datadisplay/code.pyi": "67c4ac180d48cd7708471744e2201205",
25+
"reflex/components/datadisplay/code.pyi": "3787ca724cae7b29d57ea03f981b8c22",
2626
"reflex/components/datadisplay/dataeditor.pyi": "23f777b8a46eff2afd95035dd5fc51a7",
27-
"reflex/components/datadisplay/shiki_code_block.pyi": "71b00d76364a92e246ff393fdd8cddcc",
27+
"reflex/components/datadisplay/shiki_code_block.pyi": "0bf1ed97bcc4159df150d56d92d78945",
2828
"reflex/components/el/__init__.pyi": "93bde7e3672a442bb2562a9b04d8b9d9",
2929
"reflex/components/el/element.pyi": "7faa2cda13a04870d6c1cbfb4b3a2a0a",
3030
"reflex/components/el/elements/__init__.pyi": "6f09637fb00205071f19eb73491d256f",
@@ -40,7 +40,7 @@
4040
"reflex/components/el/elements/typography.pyi": "dc4e234a7a58be0a9c2c6036a52f9b59",
4141
"reflex/components/gridjs/datatable.pyi": "5c19d2b5788a8520d43a4d6dcc247705",
4242
"reflex/components/lucide/icon.pyi": "e48c9fa2fe6308d366634b6a5157bf3a",
43-
"reflex/components/markdown/markdown.pyi": "68d8f112cf1e2ceff0fd0606a2abcf62",
43+
"reflex/components/markdown/markdown.pyi": "a569dd6a60d67baebfc4d04cddf85020",
4444
"reflex/components/moment/moment.pyi": "4ca29ae9cae720eb5c4955682e4cb7df",
4545
"reflex/components/plotly/plotly.pyi": "1de86aa6881e59d4053206e62e3039c3",
4646
"reflex/components/radix/__init__.pyi": "7dcf3869b498d6cbf3ec9986c9bf3c86",
@@ -53,7 +53,7 @@
5353
"reflex/components/radix/primitives/slider.pyi": "6dd3197c7d8e4af0a7de3e34ff940597",
5454
"reflex/components/radix/themes/__init__.pyi": "55d491b7e1fe8aaa9ddc9834a819b54d",
5555
"reflex/components/radix/themes/base.pyi": "82885483a3aa7cc88d19b33d596d140a",
56-
"reflex/components/radix/themes/color_mode.pyi": "e2f94787f6e3498e2aaa4e2c37d135c2",
56+
"reflex/components/radix/themes/color_mode.pyi": "889d9f492136a4600da3a79b9a3c5cc4",
5757
"reflex/components/radix/themes/components/__init__.pyi": "4e70d106bc0aba70f2f23fc32c452aee",
5858
"reflex/components/radix/themes/components/alert_dialog.pyi": "ccff6da776d85e93199982c59c412a6d",
5959
"reflex/components/radix/themes/components/aspect_ratio.pyi": "b11efdce4c5954f6cbd2ba6f3b1b544c",
@@ -111,7 +111,7 @@
111111
"reflex/components/react_player/react_player.pyi": "a9917f411d51cf3f291758c9e01844f2",
112112
"reflex/components/react_player/video.pyi": "ef4730235b7902fa30859083db8b36a3",
113113
"reflex/components/recharts/__init__.pyi": "ea5b61055f486497a1901429a9d7c9df",
114-
"reflex/components/recharts/cartesian.pyi": "75f7506f7854c52ce59517336ae790d0",
114+
"reflex/components/recharts/cartesian.pyi": "d9558034d606669ef40f7212b5644539",
115115
"reflex/components/recharts/charts.pyi": "58415e7aef3d4642494e1b86aea6589c",
116116
"reflex/components/recharts/general.pyi": "a12735989ef36152b2dab954604953c0",
117117
"reflex/components/recharts/polar.pyi": "ff9f90861ae950d6db9c1bc160303182",

reflex/components/base/meta.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from reflex.components.base.bare import Bare
66
from reflex.components.el import elements
7+
from reflex.vars.base import Var
78

89

910
class Title(elements.Title):
@@ -28,31 +29,19 @@ def render(self) -> dict:
2829
class Meta(elements.Meta):
2930
"""A component that displays metadata for the current page."""
3031

31-
# The description of character encoding.
32-
char_set: str | None = None
33-
34-
# The value of meta.
35-
content: str | None = None
36-
37-
# The name of metadata.
38-
name: str | None = None
39-
40-
# The type of metadata value.
41-
property: str | None = None
42-
4332
# The type of metadata value.
44-
http_equiv: str | None = None
33+
property: Var[str]
4534

4635

4736
class Description(elements.Meta):
4837
"""A component that displays the title of the current page."""
4938

5039
# The type of the description.
51-
name: str | None = "description"
40+
name: Var[str] = Var.create("description")
5241

5342

5443
class Image(elements.Meta):
5544
"""A component that displays the title of the current page."""
5645

5746
# The type of the image.
58-
property: str | None = "og:image"
47+
property: Var[str] = Var.create("og:image")

reflex/components/core/foreach.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import Any
99

1010
from reflex.components.base.fragment import Fragment
11-
from reflex.components.component import Component
11+
from reflex.components.component import Component, field
1212
from reflex.components.core.cond import cond
1313
from reflex.components.tags import IterTag
1414
from reflex.constants import MemoizationMode
@@ -36,7 +36,7 @@ class Foreach(Component):
3636
iterable: Var[Iterable]
3737

3838
# A function from the render args to the component.
39-
render_fn: Callable = Fragment.create
39+
render_fn: Callable = field(default=Fragment.create, is_javascript_property=False)
4040

4141
@classmethod
4242
def create(

reflex/components/core/match.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Any
55

66
from reflex.components.base import Fragment
7-
from reflex.components.component import BaseComponent, Component, MemoizationLeaf
7+
from reflex.components.component import BaseComponent, Component, MemoizationLeaf, field
88
from reflex.components.tags import MatchTag, Tag
99
from reflex.style import Style
1010
from reflex.utils import format
@@ -21,10 +21,10 @@ class Match(MemoizationLeaf):
2121
cond: Var[Any]
2222

2323
# The list of match cases to be matched.
24-
match_cases: list[Any] = []
24+
match_cases: list[Any] = field(default_factory=list, is_javascript_property=False)
2525

2626
# The catchall case to match.
27-
default: Any
27+
default: Any = field(default=None, is_javascript_property=False)
2828

2929
@classmethod
3030
def create(cls, cond: Any, *cases) -> Component | Var:

reflex/components/core/upload.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
ComponentNamespace,
1313
MemoizationLeaf,
1414
StatefulComponent,
15+
field,
1516
)
1617
from reflex.components.core.cond import cond
1718
from reflex.components.el.elements.forms import Input
@@ -234,7 +235,7 @@ class Upload(MemoizationLeaf):
234235
on_drop: EventHandler[_on_drop_spec]
235236

236237
# Style rules to apply when actively dragging.
237-
drag_active_style: Style | None = None
238+
drag_active_style: Style | None = field(default=None, is_javascript_property=False)
238239

239240
@classmethod
240241
def create(cls, *children, **props) -> Component:

reflex/components/datadisplay/code.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import dataclasses
66
from typing import ClassVar, Literal
77

8-
from reflex.components.component import Component, ComponentNamespace
8+
from reflex.components.component import Component, ComponentNamespace, field
99
from reflex.components.core.cond import color_mode_cond
1010
from reflex.components.lucide.icon import Icon
1111
from reflex.components.markdown.markdown import MarkdownComponentMap
@@ -407,16 +407,24 @@ class CodeBlock(Component, MarkdownComponentMap):
407407
wrap_long_lines: Var[bool]
408408

409409
# A custom style for the code block.
410-
custom_style: dict[str, str | Var | Color] = {}
410+
custom_style: dict[str, str | Var | Color] = field(
411+
default_factory=dict, is_javascript_property=False
412+
)
411413

412414
# Props passed down to the code tag.
413415
code_tag_props: Var[dict[str, str]]
414416

415417
# Whether a copy button should appear.
416-
can_copy: bool | None = False
418+
can_copy: bool | None = field(
419+
default=False,
420+
is_javascript_property=False,
421+
)
417422

418423
# A custom copy button to override the default one.
419-
copy_button: bool | Component | None = None
424+
copy_button: bool | Component | None = field(
425+
default=None,
426+
is_javascript_property=False,
427+
)
420428

421429
@classmethod
422430
def create(
@@ -498,9 +506,6 @@ def _render(self):
498506

499507
return out
500508

501-
def _exclude_props(self) -> list[str]:
502-
return ["can_copy", "copy_button"]
503-
504509

505510
class CodeblockNamespace(ComponentNamespace):
506511
"""Namespace for the CodeBlock component."""

reflex/components/datadisplay/shiki_code_block.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from dataclasses import dataclass
99
from typing import Any, Literal
1010

11-
from reflex.components.component import Component, ComponentNamespace
11+
from reflex.components.component import Component, ComponentNamespace, field
1212
from reflex.components.core.colors import color
1313
from reflex.components.core.cond import color_mode_cond
1414
from reflex.components.el.elements.forms import Button
@@ -721,10 +721,12 @@ class ShikiHighLevelCodeBlock(ShikiCodeBlock):
721721
show_line_numbers: Var[bool]
722722

723723
# Whether a copy button should appear.
724-
can_copy: bool = False
724+
can_copy: bool = field(default=False, is_javascript_property=False)
725725

726726
# copy_button: A custom copy button to override the default one.
727-
copy_button: Component | bool | None = None
727+
copy_button: Component | bool | None = field(
728+
default=None, is_javascript_property=False
729+
)
728730

729731
@classmethod
730732
def create(

reflex/components/markdown/markdown.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from hashlib import md5
1010
from typing import Any
1111

12-
from reflex.components.component import BaseComponent, Component, CustomComponent
12+
from reflex.components.component import BaseComponent, Component, CustomComponent, field
1313
from reflex.components.tags.tag import Tag
1414
from reflex.utils.imports import ImportDict, ImportVar
1515
from reflex.vars.base import LiteralVar, Var, VarData
@@ -150,10 +150,12 @@ class Markdown(Component):
150150
is_default = True
151151

152152
# The component map from a tag to a lambda that creates a component.
153-
component_map: dict[str, Any] = {}
153+
component_map: dict[str, Any] = field(
154+
default_factory=dict, is_javascript_property=False
155+
)
154156

155157
# The hash of the component map, generated at create() time.
156-
component_map_hash: str = ""
158+
component_map_hash: str = field(default="", is_javascript_property=False)
157159

158160
@classmethod
159161
def create(cls, *children, **props) -> Component:

reflex/components/radix/themes/color_mode.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from typing import Any, Literal, get_args
2121

22-
from reflex.components.component import BaseComponent
22+
from reflex.components.component import BaseComponent, field
2323
from reflex.components.core.cond import Cond, color_mode_cond, cond
2424
from reflex.components.lucide.icon import Icon
2525
from reflex.components.radix.themes.components.dropdown_menu import dropdown_menu
@@ -99,10 +99,12 @@ class ColorModeIconButton(IconButton):
9999
"""Icon Button for toggling light / dark mode via toggle_color_mode."""
100100

101101
# The position of the icon button. Follow document flow if None.
102-
position: LiteralPosition | Var[LiteralPosition] | None = None
102+
position: LiteralPosition | Var[LiteralPosition] | None = field(
103+
default=None, is_javascript_property=False
104+
)
103105

104106
# Allow picking the "system" value for the color mode.
105-
allow_system: bool = False
107+
allow_system: bool = field(default=False, is_javascript_property=False)
106108

107109
@classmethod
108110
def create(
@@ -168,9 +170,6 @@ def color_mode_item(_color_mode: Literal["light", "dark", "system"]):
168170
**props,
169171
)
170172

171-
def _exclude_props(self) -> list[str]:
172-
return ["position", "allow_system"]
173-
174173

175174
class ColorModeSwitch(Switch):
176175
"""Switch for toggling light / dark mode via toggle_color_mode."""

reflex/components/recharts/cartesian.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from collections.abc import Sequence
6-
from typing import Any, ClassVar
6+
from typing import Any, ClassVar, TypedDict
77

88
from reflex.constants import EventTriggers
99
from reflex.constants.colors import Color
@@ -663,6 +663,13 @@ class Reference(Recharts):
663663
is_front: Var[bool]
664664

665665

666+
class Segment(TypedDict):
667+
"""A segment in a ReferenceLine or ReferenceArea."""
668+
669+
x: str | int
670+
y: str | int
671+
672+
666673
class ReferenceLine(Reference):
667674
"""A ReferenceLine component in Recharts."""
668675

@@ -686,7 +693,7 @@ class ReferenceLine(Reference):
686693
_valid_children: ClassVar[list[str]] = ["Label"]
687694

688695
# Array of endpoints in { x, y } format. These endpoints would be used to draw the ReferenceLine.
689-
segment: Sequence[Any] = []
696+
segment: Var[Sequence[Segment]]
690697

691698

692699
class ReferenceDot(Reference):

0 commit comments

Comments
 (0)