reflex 0.6.6.post3__py3-none-any.whl → 0.6.7a1__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 (141) hide show
  1. reflex/.templates/jinja/web/pages/stateful_component.js.jinja2 +5 -1
  2. reflex/.templates/web/utils/state.js +36 -28
  3. reflex/__init__.py +1 -1
  4. reflex/__init__.pyi +1 -0
  5. reflex/app.py +41 -16
  6. reflex/assets.py +2 -2
  7. reflex/base.py +8 -7
  8. reflex/compiler/templates.py +1 -0
  9. reflex/compiler/utils.py +2 -3
  10. reflex/components/base/bare.py +2 -2
  11. reflex/components/component.py +54 -29
  12. reflex/components/core/banner.py +2 -2
  13. reflex/components/core/banner.pyi +1 -1
  14. reflex/components/core/client_side_routing.py +2 -2
  15. reflex/components/core/client_side_routing.pyi +1 -1
  16. reflex/components/core/clipboard.py +11 -9
  17. reflex/components/core/clipboard.pyi +1 -1
  18. reflex/components/core/cond.py +3 -3
  19. reflex/components/core/foreach.py +1 -1
  20. reflex/components/core/html.pyi +1 -1
  21. reflex/components/core/upload.py +8 -8
  22. reflex/components/datadisplay/code.py +5 -5
  23. reflex/components/datadisplay/dataeditor.py +8 -28
  24. reflex/components/datadisplay/dataeditor.pyi +1 -1
  25. reflex/components/datadisplay/shiki_code_block.py +7 -7
  26. reflex/components/dynamic.py +2 -2
  27. reflex/components/el/elements/__init__.py +1 -1
  28. reflex/components/el/elements/__init__.pyi +1 -1
  29. reflex/components/el/elements/base.py +2 -2
  30. reflex/components/el/elements/base.pyi +1 -1
  31. reflex/components/el/elements/forms.py +40 -10
  32. reflex/components/el/elements/forms.pyi +17 -15
  33. reflex/components/el/elements/inline.py +1 -1
  34. reflex/components/el/elements/inline.pyi +28 -28
  35. reflex/components/el/elements/media.py +1 -4
  36. reflex/components/el/elements/media.pyi +25 -26
  37. reflex/components/el/elements/metadata.py +6 -6
  38. reflex/components/el/elements/metadata.pyi +4 -4
  39. reflex/components/el/elements/other.py +17 -9
  40. reflex/components/el/elements/other.pyi +7 -7
  41. reflex/components/el/elements/scripts.py +1 -2
  42. reflex/components/el/elements/scripts.pyi +3 -3
  43. reflex/components/el/elements/sectioning.py +16 -16
  44. reflex/components/el/elements/sectioning.pyi +15 -15
  45. reflex/components/el/elements/tables.py +1 -1
  46. reflex/components/el/elements/tables.pyi +10 -10
  47. reflex/components/el/elements/typography.py +1 -1
  48. reflex/components/el/elements/typography.pyi +15 -15
  49. reflex/components/markdown/markdown.py +3 -3
  50. reflex/components/next/image.py +1 -1
  51. reflex/components/next/image.pyi +1 -1
  52. reflex/components/plotly/plotly.py +2 -2
  53. reflex/components/radix/primitives/accordion.py +2 -1
  54. reflex/components/radix/primitives/form.pyi +3 -3
  55. reflex/components/radix/primitives/slider.py +1 -1
  56. reflex/components/radix/themes/base.py +4 -10
  57. reflex/components/radix/themes/color_mode.pyi +2 -2
  58. reflex/components/radix/themes/components/alert_dialog.pyi +1 -1
  59. reflex/components/radix/themes/components/badge.pyi +1 -1
  60. reflex/components/radix/themes/components/button.pyi +1 -1
  61. reflex/components/radix/themes/components/callout.pyi +5 -5
  62. reflex/components/radix/themes/components/card.pyi +1 -1
  63. reflex/components/radix/themes/components/checkbox.pyi +3 -3
  64. reflex/components/radix/themes/components/context_menu.py +11 -0
  65. reflex/components/radix/themes/components/context_menu.pyi +155 -0
  66. reflex/components/radix/themes/components/dialog.pyi +1 -1
  67. reflex/components/radix/themes/components/hover_card.pyi +1 -1
  68. reflex/components/radix/themes/components/icon_button.py +1 -1
  69. reflex/components/radix/themes/components/icon_button.pyi +1 -1
  70. reflex/components/radix/themes/components/inset.pyi +1 -1
  71. reflex/components/radix/themes/components/popover.pyi +1 -1
  72. reflex/components/radix/themes/components/radio_group.py +2 -4
  73. reflex/components/radix/themes/components/radio_group.pyi +1 -1
  74. reflex/components/radix/themes/components/select.pyi +3 -3
  75. reflex/components/radix/themes/components/slider.pyi +1 -1
  76. reflex/components/radix/themes/components/switch.pyi +1 -1
  77. reflex/components/radix/themes/components/table.pyi +7 -7
  78. reflex/components/radix/themes/components/tabs.pyi +2 -2
  79. reflex/components/radix/themes/components/text_area.py +3 -0
  80. reflex/components/radix/themes/components/text_area.pyi +3 -1
  81. reflex/components/radix/themes/components/text_field.py +16 -1
  82. reflex/components/radix/themes/components/text_field.pyi +105 -17
  83. reflex/components/radix/themes/layout/box.pyi +1 -1
  84. reflex/components/radix/themes/layout/center.pyi +1 -1
  85. reflex/components/radix/themes/layout/flex.pyi +1 -1
  86. reflex/components/radix/themes/layout/grid.pyi +1 -1
  87. reflex/components/radix/themes/layout/list.py +0 -4
  88. reflex/components/radix/themes/layout/list.pyi +3 -8
  89. reflex/components/radix/themes/layout/section.pyi +1 -1
  90. reflex/components/radix/themes/layout/spacer.pyi +1 -1
  91. reflex/components/radix/themes/layout/stack.pyi +3 -3
  92. reflex/components/radix/themes/typography/blockquote.pyi +1 -1
  93. reflex/components/radix/themes/typography/code.pyi +1 -1
  94. reflex/components/radix/themes/typography/heading.pyi +1 -1
  95. reflex/components/radix/themes/typography/link.py +5 -1
  96. reflex/components/radix/themes/typography/link.pyi +1 -1
  97. reflex/components/radix/themes/typography/text.pyi +7 -7
  98. reflex/components/recharts/cartesian.py +1 -1
  99. reflex/components/recharts/charts.py +4 -4
  100. reflex/components/recharts/polar.py +1 -1
  101. reflex/components/recharts/polar.pyi +1 -1
  102. reflex/components/sonner/toast.py +4 -7
  103. reflex/components/suneditor/editor.py +6 -6
  104. reflex/components/suneditor/editor.pyi +6 -6
  105. reflex/config.py +25 -10
  106. reflex/constants/compiler.py +6 -0
  107. reflex/constants/config.py +2 -0
  108. reflex/constants/custom_components.py +1 -1
  109. reflex/constants/route.py +1 -1
  110. reflex/custom_components/custom_components.py +21 -21
  111. reflex/event.py +57 -22
  112. reflex/experimental/client_state.py +2 -1
  113. reflex/experimental/layout.py +0 -6
  114. reflex/model.py +125 -9
  115. reflex/reflex.py +5 -6
  116. reflex/state.py +203 -88
  117. reflex/style.py +1 -4
  118. reflex/testing.py +10 -11
  119. reflex/utils/build.py +1 -1
  120. reflex/utils/console.py +75 -6
  121. reflex/utils/exceptions.py +12 -0
  122. reflex/utils/exec.py +10 -10
  123. reflex/utils/export.py +1 -2
  124. reflex/utils/format.py +11 -8
  125. reflex/utils/path_ops.py +2 -2
  126. reflex/utils/prerequisites.py +31 -28
  127. reflex/utils/processes.py +4 -4
  128. reflex/utils/pyi_generator.py +12 -11
  129. reflex/utils/types.py +6 -3
  130. reflex/vars/__init__.py +1 -0
  131. reflex/vars/base.py +75 -38
  132. reflex/vars/datetime.py +222 -0
  133. reflex/vars/function.py +3 -3
  134. reflex/vars/number.py +3 -3
  135. reflex/vars/object.py +5 -5
  136. reflex/vars/sequence.py +7 -7
  137. {reflex-0.6.6.post3.dist-info → reflex-0.6.7a1.dist-info}/METADATA +2 -2
  138. {reflex-0.6.6.post3.dist-info → reflex-0.6.7a1.dist-info}/RECORD +141 -140
  139. {reflex-0.6.6.post3.dist-info → reflex-0.6.7a1.dist-info}/LICENSE +0 -0
  140. {reflex-0.6.6.post3.dist-info → reflex-0.6.7a1.dist-info}/WHEEL +0 -0
  141. {reflex-0.6.6.post3.dist-info → reflex-0.6.7a1.dist-info}/entry_points.txt +0 -0
@@ -6,11 +6,12 @@ from typing import Dict, List, Tuple, Union
6
6
 
7
7
  from reflex.components.base.fragment import Fragment
8
8
  from reflex.components.tags.tag import Tag
9
+ from reflex.constants.compiler import Hooks
9
10
  from reflex.event import EventChain, EventHandler, passthrough_event_spec
10
11
  from reflex.utils.format import format_prop, wrap
11
12
  from reflex.utils.imports import ImportVar
12
13
  from reflex.vars import get_unique_variable_name
13
- from reflex.vars.base import Var
14
+ from reflex.vars.base import Var, VarData
14
15
 
15
16
 
16
17
  class Clipboard(Fragment):
@@ -51,7 +52,7 @@ class Clipboard(Fragment):
51
52
  return super().create(*children, **props)
52
53
 
53
54
  def _exclude_props(self) -> list[str]:
54
- return super()._exclude_props() + ["on_paste", "on_paste_event_actions"]
55
+ return [*super()._exclude_props(), "on_paste", "on_paste_event_actions"]
55
56
 
56
57
  def _render(self) -> Tag:
57
58
  tag = super()._render()
@@ -72,7 +73,7 @@ class Clipboard(Fragment):
72
73
  ),
73
74
  }
74
75
 
75
- def add_hooks(self) -> list[str]:
76
+ def add_hooks(self) -> list[str | Var[str]]:
76
77
  """Add hook to register paste event listener.
77
78
 
78
79
  Returns:
@@ -83,13 +84,14 @@ class Clipboard(Fragment):
83
84
  return []
84
85
  if isinstance(on_paste, EventChain):
85
86
  on_paste = wrap(str(format_prop(on_paste)).strip("{}"), "(")
87
+ hook_expr = f"usePasteHandler({self.targets!s}, {self.on_paste_event_actions!s}, {on_paste!s})"
88
+
86
89
  return [
87
- "usePasteHandler(%s, %s, %s)"
88
- % (
89
- str(self.targets),
90
- str(self.on_paste_event_actions),
91
- on_paste,
92
- )
90
+ Var(
91
+ hook_expr,
92
+ _var_type="str",
93
+ _var_data=VarData(position=Hooks.HookPosition.POST_TRIGGER),
94
+ ),
93
95
  ]
94
96
 
95
97
 
@@ -71,6 +71,6 @@ class Clipboard(Fragment):
71
71
  ...
72
72
 
73
73
  def add_imports(self) -> dict[str, ImportVar]: ...
74
- def add_hooks(self) -> list[str]: ...
74
+ def add_hooks(self) -> list[str | Var[str]]: ...
75
75
 
76
76
  clipboard = Clipboard.create
@@ -49,9 +49,9 @@ class Cond(MemoizationLeaf):
49
49
  The conditional component.
50
50
  """
51
51
  # Wrap everything in fragments.
52
- if comp1.__class__.__name__ != "Fragment":
52
+ if type(comp1).__name__ != "Fragment":
53
53
  comp1 = Fragment.create(comp1)
54
- if comp2 is None or comp2.__class__.__name__ != "Fragment":
54
+ if comp2 is None or type(comp2).__name__ != "Fragment":
55
55
  comp2 = Fragment.create(comp2) if comp2 else Fragment.create()
56
56
  return Fragment.create(
57
57
  cls(
@@ -94,7 +94,7 @@ class Cond(MemoizationLeaf):
94
94
  ).set(
95
95
  props=tag.format_props(),
96
96
  ),
97
- cond_state=f"isTrue({str(self.cond)})",
97
+ cond_state=f"isTrue({self.cond!s})",
98
98
  )
99
99
 
100
100
  def add_imports(self) -> ImportDict:
@@ -54,7 +54,7 @@ class Foreach(Component):
54
54
  iterable = LiteralVar.create(iterable)
55
55
  if iterable._var_type == Any:
56
56
  raise ForeachVarError(
57
- f"Could not foreach over var `{str(iterable)}` of type Any. "
57
+ f"Could not foreach over var `{iterable!s}` of type Any. "
58
58
  "(If you are trying to foreach over a state var, add a type annotation to the var). "
59
59
  "See https://reflex.dev/docs/library/dynamic-rendering/foreach/"
60
60
  )
@@ -71,7 +71,7 @@ class Html(Div):
71
71
  Args:
72
72
  *children: The children of the component.
73
73
  dangerouslySetInnerHTML: The HTML to render.
74
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
74
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
75
75
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
76
76
  content_editable: Indicates whether the element's content is editable.
77
77
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -29,7 +29,7 @@ from reflex.event import (
29
29
  from reflex.utils import format
30
30
  from reflex.utils.imports import ImportVar
31
31
  from reflex.vars import VarData
32
- from reflex.vars.base import CallableVar, LiteralVar, Var, get_unique_variable_name
32
+ from reflex.vars.base import CallableVar, Var, get_unique_variable_name
33
33
  from reflex.vars.sequence import LiteralStringVar
34
34
 
35
35
  DEFAULT_UPLOAD_ID: str = "default"
@@ -61,7 +61,7 @@ def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var:
61
61
  id_var = LiteralStringVar.create(id_)
62
62
  var_name = f"""e => setFilesById(filesById => {{
63
63
  const updatedFilesById = Object.assign({{}}, filesById);
64
- updatedFilesById[{str(id_var)}] = e;
64
+ updatedFilesById[{id_var!s}] = e;
65
65
  return updatedFilesById;
66
66
  }})
67
67
  """
@@ -87,7 +87,7 @@ def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var:
87
87
  """
88
88
  id_var = LiteralStringVar.create(id_)
89
89
  return Var(
90
- _js_expr=f"(filesById[{str(id_var)}] ? filesById[{str(id_var)}].map((f) => (f.path || f.name)) : [])",
90
+ _js_expr=f"(filesById[{id_var!s}] ? filesById[{id_var!s}].map((f) => (f.path || f.name)) : [])",
91
91
  _var_type=List[str],
92
92
  _var_data=VarData.merge(
93
93
  upload_files_context_var_data, id_var._get_all_var_data()
@@ -108,7 +108,8 @@ def clear_selected_files(id_: str = DEFAULT_UPLOAD_ID) -> EventSpec:
108
108
  # UploadFilesProvider assigns a special function to clear selected files
109
109
  # into the shared global refs object to make it accessible outside a React
110
110
  # component via `run_script` (otherwise backend could never clear files).
111
- return run_script(f"refs['__clear_selected_files']({id_!r})")
111
+ func = Var("__clear_selected_files")._as_ref()
112
+ return run_script(f"{func}({id_!r})")
112
113
 
113
114
 
114
115
  def cancel_upload(upload_id: str) -> EventSpec:
@@ -120,9 +121,8 @@ def cancel_upload(upload_id: str) -> EventSpec:
120
121
  Returns:
121
122
  An event spec that cancels the upload when triggered.
122
123
  """
123
- return run_script(
124
- f"upload_controllers[{str(LiteralVar.create(upload_id))}]?.abort()"
125
- )
124
+ controller = Var(f"__upload_controllers_{upload_id}")._as_ref()
125
+ return run_script(f"{controller}?.abort()")
126
126
 
127
127
 
128
128
  def get_upload_dir() -> Path:
@@ -301,7 +301,7 @@ class Upload(MemoizationLeaf):
301
301
  )
302
302
 
303
303
  left_side = f"const {{getRootProps: {root_props_unique_name}, getInputProps: {input_props_unique_name}}} "
304
- right_side = f"useDropzone({str(use_dropzone_arguments)})"
304
+ right_side = f"useDropzone({use_dropzone_arguments!s})"
305
305
 
306
306
  var_data = VarData.merge(
307
307
  VarData(
@@ -519,13 +519,13 @@ class CodeBlock(Component, MarkdownComponentMap):
519
519
  The hook to register the language.
520
520
  """
521
521
  return f"""
522
- if ({str(_LANGUAGE)}) {{
522
+ if ({_LANGUAGE!s}) {{
523
523
  (async () => {{
524
524
  try {{
525
- const module = await import(`react-syntax-highlighter/dist/cjs/languages/prism/${{{str(_LANGUAGE)}}}`);
526
- SyntaxHighlighter.registerLanguage({str(_LANGUAGE)}, module.default);
525
+ const module = await import(`react-syntax-highlighter/dist/cjs/languages/prism/${{{_LANGUAGE!s}}}`);
526
+ SyntaxHighlighter.registerLanguage({_LANGUAGE!s}, module.default);
527
527
  }} catch (error) {{
528
- console.error(`Error importing language module for ${{{str(_LANGUAGE)}}}:`, error);
528
+ console.error(`Error importing language module for ${{{_LANGUAGE!s}}}:`, error);
529
529
  }}
530
530
  }})();
531
531
  }}
@@ -547,7 +547,7 @@ class CodeBlock(Component, MarkdownComponentMap):
547
547
  The hooks for the component.
548
548
  """
549
549
  return [
550
- f"const {str(_LANGUAGE)} = {str(self.language)}",
550
+ f"const {_LANGUAGE!s} = {self.language!s}",
551
551
  self._get_language_registration_hook(),
552
552
  ]
553
553
 
@@ -51,27 +51,6 @@ class GridColumnIcons(Enum):
51
51
  VideoUri = "video_uri"
52
52
 
53
53
 
54
- # @serializer
55
- # def serialize_gridcolumn_icon(icon: GridColumnIcons) -> str:
56
- # """Serialize grid column icon.
57
-
58
- # Args:
59
- # icon: the Icon to serialize.
60
-
61
- # Returns:
62
- # The serialized value.
63
- # """
64
- # return "prefix" + str(icon)
65
-
66
-
67
- # class DataEditorColumn(Base):
68
- # """Column."""
69
-
70
- # title: str
71
- # id: Optional[str] = None
72
- # type_: str = "str"
73
-
74
-
75
54
  class DataEditorTheme(Base):
76
55
  """The theme for the DataEditor component."""
77
56
 
@@ -229,7 +208,7 @@ class DataEditor(NoSSRComponent):
229
208
  header_height: Var[int]
230
209
 
231
210
  # Additional header icons:
232
- # header_icons: Var[Any] # (TODO: must be a map of name: svg)
211
+ # header_icons: Var[Any] # (TODO: must be a map of name: svg) #noqa: ERA001
233
212
 
234
213
  # The maximum width a column can be automatically sized to.
235
214
  max_column_auto_width: Var[int]
@@ -360,8 +339,11 @@ class DataEditor(NoSSRComponent):
360
339
  editor_id = get_unique_variable_name()
361
340
 
362
341
  # Define the name of the getData callback associated with this component and assign to get_cell_content.
363
- data_callback = f"getData_{editor_id}"
364
- self.get_cell_content = Var(_js_expr=data_callback) # type: ignore
342
+ if self.get_cell_content is not None:
343
+ data_callback = self.get_cell_content._js_expr
344
+ else:
345
+ data_callback = f"getData_{editor_id}"
346
+ self.get_cell_content = Var(_js_expr=data_callback) # type: ignore
365
347
 
366
348
  code = [f"function {data_callback}([col, row])" "{"]
367
349
 
@@ -406,10 +388,8 @@ class DataEditor(NoSSRComponent):
406
388
  props["rows"] = data.length() if isinstance(data, Var) else len(data)
407
389
 
408
390
  if not isinstance(columns, Var) and len(columns):
409
- if (
410
- types.is_dataframe(type(data))
411
- or isinstance(data, Var)
412
- and types.is_dataframe(data._var_type)
391
+ if types.is_dataframe(type(data)) or (
392
+ isinstance(data, Var) and types.is_dataframe(data._var_type)
413
393
  ):
414
394
  raise ValueError(
415
395
  "Cannot pass in both a pandas dataframe and columns to the data_editor component."
@@ -288,7 +288,7 @@ class DataEditor(NoSSRComponent):
288
288
  freeze_columns: The number of columns which should remain in place when scrolling horizontally. Doesn't include rowMarkers.
289
289
  group_header_height: Controls the header of the group header row.
290
290
  header_height: Controls the height of the header row.
291
- max_column_auto_width: Additional header icons: header_icons: Var[Any] # (TODO: must be a map of name: svg) The maximum width a column can be automatically sized to.
291
+ max_column_auto_width: The maximum width a column can be automatically sized to.
292
292
  max_column_width: The maximum width a column can be resized to.
293
293
  min_column_width: The minimum width a column can be resized to.
294
294
  row_height: Determins the height of each row.
@@ -490,17 +490,17 @@ class ShikiJsTransformer(ShikiBaseTransformers):
490
490
  },
491
491
  # White Space
492
492
  # ".tab, .space": {
493
- # "position": "relative",
493
+ # "position": "relative", # noqa: ERA001
494
494
  # },
495
495
  # ".tab::before": {
496
- # "content": "'⇥'",
497
- # "position": "absolute",
498
- # "opacity": "0.3",
496
+ # "content": "'⇥'", # noqa: ERA001
497
+ # "position": "absolute", # noqa: ERA001
498
+ # "opacity": "0.3",# noqa: ERA001
499
499
  # },
500
500
  # ".space::before": {
501
- # "content": "'·'",
502
- # "position": "absolute",
503
- # "opacity": "0.3",
501
+ # "content": "'·'", # noqa: ERA001
502
+ # "position": "absolute", # noqa: ERA001
503
+ # "opacity": "0.3", # noqa: ERA001
504
504
  # },
505
505
  }
506
506
  )
@@ -173,7 +173,7 @@ def load_dynamic_serializer():
173
173
  f"const [{unique_var_name}, set_{unique_var_name}] = useState(null);": None,
174
174
  "useEffect(() => {"
175
175
  "let isMounted = true;"
176
- f"evalReactComponent({str(js_string)})"
176
+ f"evalReactComponent({js_string!s})"
177
177
  ".then((component) => {"
178
178
  "if (isMounted) {"
179
179
  f"set_{unique_var_name}(component);"
@@ -183,7 +183,7 @@ def load_dynamic_serializer():
183
183
  "isMounted = false;"
184
184
  "};"
185
185
  "}"
186
- f", [{str(js_string)}]);": None,
186
+ f", [{js_string!s}]);": None,
187
187
  },
188
188
  ),
189
189
  ),
@@ -127,7 +127,7 @@ _MAPPING = {
127
127
 
128
128
 
129
129
  EXCLUDE = ["del_", "Del", "image"]
130
- for _, v in _MAPPING.items():
130
+ for v in _MAPPING.values():
131
131
  v.extend([mod.capitalize() for mod in v if mod not in EXCLUDE])
132
132
 
133
133
  _SUBMOD_ATTRS: dict[str, list[str]] = _MAPPING
@@ -339,5 +339,5 @@ _MAPPING = {
339
339
  ],
340
340
  }
341
341
  EXCLUDE = ["del_", "Del", "image"]
342
- for _, v in _MAPPING.items():
342
+ for v in _MAPPING.values():
343
343
  v.extend([mod.capitalize() for mod in v if mod not in EXCLUDE])
@@ -1,4 +1,4 @@
1
- """Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
1
+ """Base classes."""
2
2
 
3
3
  from typing import Union
4
4
 
@@ -9,7 +9,7 @@ from reflex.vars.base import Var
9
9
  class BaseHTML(Element):
10
10
  """Base class for common attributes."""
11
11
 
12
- # Provides a hint for generating a keyboard shortcut for the current element.
12
+ # Provides a hint for generating a keyboard shortcut for the current element.
13
13
  access_key: Var[Union[str, int, bool]]
14
14
 
15
15
  # Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
@@ -67,7 +67,7 @@ class BaseHTML(Element):
67
67
 
68
68
  Args:
69
69
  *children: The children of the component.
70
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
70
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
71
71
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
72
72
  content_editable: Indicates whether the element's content is editable.
73
73
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -1,4 +1,4 @@
1
- """Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
1
+ """Forms classes."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -18,6 +18,7 @@ from reflex.event import (
18
18
  prevent_default,
19
19
  )
20
20
  from reflex.utils.imports import ImportDict
21
+ from reflex.utils.types import is_optional
21
22
  from reflex.vars import VarData
22
23
  from reflex.vars.base import LiteralVar, Var
23
24
 
@@ -84,7 +85,6 @@ class Datalist(BaseHTML):
84
85
  """Display the datalist element."""
85
86
 
86
87
  tag = "datalist"
87
- # No unique attributes, only common ones are inherited
88
88
 
89
89
 
90
90
  class Fieldset(Element):
@@ -241,16 +241,15 @@ class Form(BaseHTML):
241
241
  if ref.startswith("refs_"):
242
242
  ref_var = Var(_js_expr=ref[:-3])._as_ref()
243
243
  form_refs[ref[len("refs_") : -3]] = Var(
244
- _js_expr=f"getRefValues({str(ref_var)})",
244
+ _js_expr=f"getRefValues({ref_var!s})",
245
245
  _var_data=VarData.merge(ref_var._get_all_var_data()),
246
246
  )
247
247
  else:
248
248
  ref_var = Var(_js_expr=ref)._as_ref()
249
249
  form_refs[ref[4:]] = Var(
250
- _js_expr=f"getRefValue({str(ref_var)})",
250
+ _js_expr=f"getRefValue({ref_var!s})",
251
251
  _var_data=VarData.merge(ref_var._get_all_var_data()),
252
252
  )
253
- # print(repr(form_refs))
254
253
  return form_refs
255
254
 
256
255
  def _get_vars(self, include_children: bool = True) -> Iterator[Var]:
@@ -258,7 +257,8 @@ class Form(BaseHTML):
258
257
  yield from self._get_form_refs().values()
259
258
 
260
259
  def _exclude_props(self) -> list[str]:
261
- return super()._exclude_props() + [
260
+ return [
261
+ *super()._exclude_props(),
262
262
  "reset_on_submit",
263
263
  "handle_submit_unique_name",
264
264
  ]
@@ -383,6 +383,33 @@ class Input(BaseHTML):
383
383
  # Fired when a key is released
384
384
  on_key_up: EventHandler[key_event]
385
385
 
386
+ @classmethod
387
+ def create(cls, *children, **props):
388
+ """Create an Input component.
389
+
390
+ Args:
391
+ *children: The children of the component.
392
+ **props: The properties of the component.
393
+
394
+ Returns:
395
+ The component.
396
+ """
397
+ from reflex.vars.number import ternary_operation
398
+
399
+ value = props.get("value")
400
+
401
+ # React expects an empty string(instead of null) for controlled inputs.
402
+ if value is not None and is_optional(
403
+ (value_var := Var.create(value))._var_type
404
+ ):
405
+ props["value"] = ternary_operation(
406
+ (value_var != Var.create(None)) # pyright: ignore [reportGeneralTypeIssues]
407
+ & (value_var != Var(_js_expr="undefined")),
408
+ value,
409
+ Var.create(""),
410
+ )
411
+ return super().create(*children, **props)
412
+
386
413
 
387
414
  class Label(BaseHTML):
388
415
  """Display the label element."""
@@ -400,7 +427,6 @@ class Legend(BaseHTML):
400
427
  """Display the legend element."""
401
428
 
402
429
  tag = "legend"
403
- # No unique attributes, only common ones are inherited
404
430
 
405
431
 
406
432
  class Meter(BaseHTML):
@@ -570,6 +596,9 @@ class Textarea(BaseHTML):
570
596
  # Visible width of the text control, in average character widths
571
597
  cols: Var[Union[str, int, bool]]
572
598
 
599
+ # The default value of the textarea when initially rendered
600
+ default_value: Var[str]
601
+
573
602
  # Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
574
603
  dirname: Var[Union[str, int, bool]]
575
604
 
@@ -649,19 +678,20 @@ class Textarea(BaseHTML):
649
678
  "Cannot combine `enter_key_submit` with `on_key_down`.",
650
679
  )
651
680
  custom_attrs["on_key_down"] = Var(
652
- _js_expr=f"(e) => enterKeySubmitOnKeyDown(e, {str(enter_key_submit)})",
681
+ _js_expr=f"(e) => enterKeySubmitOnKeyDown(e, {enter_key_submit!s})",
653
682
  _var_data=VarData.merge(enter_key_submit._get_all_var_data()),
654
683
  )
655
684
  if auto_height is not None:
656
685
  auto_height = Var.create(auto_height)
657
686
  custom_attrs["on_input"] = Var(
658
- _js_expr=f"(e) => autoHeightOnInput(e, {str(auto_height)})",
687
+ _js_expr=f"(e) => autoHeightOnInput(e, {auto_height!s})",
659
688
  _var_data=VarData.merge(auto_height._get_all_var_data()),
660
689
  )
661
690
  return super().create(*children, **props)
662
691
 
663
692
  def _exclude_props(self) -> list[str]:
664
- return super()._exclude_props() + [
693
+ return [
694
+ *super()._exclude_props(),
665
695
  "auto_height",
666
696
  "enter_key_submit",
667
697
  ]
@@ -103,7 +103,7 @@ class Button(BaseHTML):
103
103
  name: Name of the button, used when sending form data
104
104
  type: Type of the button (submit, reset, or button)
105
105
  value: Value of the button, used when sending form data
106
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
106
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
107
107
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
108
108
  content_editable: Indicates whether the element's content is editable.
109
109
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -189,7 +189,7 @@ class Datalist(BaseHTML):
189
189
 
190
190
  Args:
191
191
  *children: The children of the component.
192
- access_key: No unique attributes, only common ones are inherited Provides a hint for generating a keyboard shortcut for the current element.
192
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
193
193
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
194
194
  content_editable: Indicates whether the element's content is editable.
195
195
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -367,7 +367,7 @@ class Form(BaseHTML):
367
367
  reset_on_submit: If true, the form will be cleared after submit.
368
368
  handle_submit_unique_name: The name used to make this form's submit handler function unique.
369
369
  on_submit: Fired when the form is submitted
370
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
370
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
371
371
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
372
372
  content_editable: Indicates whether the element's content is editable.
373
373
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -512,7 +512,7 @@ class Input(BaseHTML):
512
512
  on_unmount: Optional[EventType[[], BASE_STATE]] = None,
513
513
  **props,
514
514
  ) -> "Input":
515
- """Create the component.
515
+ """Create an Input component.
516
516
 
517
517
  Args:
518
518
  *children: The children of the component.
@@ -554,7 +554,7 @@ class Input(BaseHTML):
554
554
  on_blur: Fired when the input loses focus
555
555
  on_key_down: Fired when a key is pressed down
556
556
  on_key_up: Fired when a key is released
557
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
557
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
558
558
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
559
559
  content_editable: Indicates whether the element's content is editable.
560
560
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -576,7 +576,7 @@ class Input(BaseHTML):
576
576
  class_name: The class name for the component.
577
577
  autofocus: Whether the component should take the focus once the page is loaded
578
578
  custom_attrs: custom attribute
579
- **props: The props of the component.
579
+ **props: The properties of the component.
580
580
 
581
581
  Returns:
582
582
  The component.
@@ -644,7 +644,7 @@ class Label(BaseHTML):
644
644
  *children: The children of the component.
645
645
  html_for: ID of a form control with which the label is associated
646
646
  form: Associates the label with a form (by id)
647
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
647
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
648
648
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
649
649
  content_editable: Indicates whether the element's content is editable.
650
650
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -730,7 +730,7 @@ class Legend(BaseHTML):
730
730
 
731
731
  Args:
732
732
  *children: The children of the component.
733
- access_key: No unique attributes, only common ones are inherited Provides a hint for generating a keyboard shortcut for the current element.
733
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
734
734
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
735
735
  content_editable: Indicates whether the element's content is editable.
736
736
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -830,7 +830,7 @@ class Meter(BaseHTML):
830
830
  min: Minimum value of the range
831
831
  optimum: Optimum value in the range
832
832
  value: Current value of the meter
833
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
833
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
834
834
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
835
835
  content_editable: Indicates whether the element's content is editable.
836
836
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -920,7 +920,7 @@ class Optgroup(BaseHTML):
920
920
  *children: The children of the component.
921
921
  disabled: Disables the optgroup
922
922
  label: Label for the optgroup
923
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
923
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
924
924
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
925
925
  content_editable: Indicates whether the element's content is editable.
926
926
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -1014,7 +1014,7 @@ class Option(BaseHTML):
1014
1014
  label: Label for the option, if the text is not the label
1015
1015
  selected: Indicates that the option is initially selected
1016
1016
  value: Value to be sent as form data
1017
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
1017
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
1018
1018
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
1019
1019
  content_editable: Indicates whether the element's content is editable.
1020
1020
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -1106,7 +1106,7 @@ class Output(BaseHTML):
1106
1106
  html_for: Associates the output with one or more elements (by their IDs)
1107
1107
  form: Associates the output with a form (by id)
1108
1108
  name: Name of the output element for form submission
1109
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
1109
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
1110
1110
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
1111
1111
  content_editable: Indicates whether the element's content is editable.
1112
1112
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -1198,7 +1198,7 @@ class Progress(BaseHTML):
1198
1198
  form: Associates the progress element with a form (by id)
1199
1199
  max: Maximum value of the progress indicator
1200
1200
  value: Current value of the progress indicator
1201
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
1201
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
1202
1202
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
1203
1203
  content_editable: Indicates whether the element's content is editable.
1204
1204
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -1306,7 +1306,7 @@ class Select(BaseHTML):
1306
1306
  required: Indicates that the select control must have a selected option
1307
1307
  size: Number of visible options in a drop-down list
1308
1308
  on_change: Fired when the select value changes
1309
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
1309
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
1310
1310
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
1311
1311
  content_editable: Indicates whether the element's content is editable.
1312
1312
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -1350,6 +1350,7 @@ class Textarea(BaseHTML):
1350
1350
  auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
1351
1351
  auto_height: Optional[Union[Var[bool], bool]] = None,
1352
1352
  cols: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
1353
+ default_value: Optional[Union[Var[str], str]] = None,
1353
1354
  dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
1354
1355
  disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
1355
1356
  enter_key_submit: Optional[Union[Var[bool], bool]] = None,
@@ -1439,6 +1440,7 @@ class Textarea(BaseHTML):
1439
1440
  auto_focus: Automatically focuses the textarea when the page loads
1440
1441
  auto_height: Automatically fit the content height to the text (use min-height with this prop)
1441
1442
  cols: Visible width of the text control, in average character widths
1443
+ default_value: The default value of the textarea when initially rendered
1442
1444
  dirname: Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted
1443
1445
  disabled: Disables the textarea
1444
1446
  enter_key_submit: Enter key submits form (shift-enter adds new line)
@@ -1457,7 +1459,7 @@ class Textarea(BaseHTML):
1457
1459
  on_blur: Fired when the input loses focus
1458
1460
  on_key_down: Fired when a key is pressed down
1459
1461
  on_key_up: Fired when a key is released
1460
- access_key: Provides a hint for generating a keyboard shortcut for the current element.
1462
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
1461
1463
  auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
1462
1464
  content_editable: Indicates whether the element's content is editable.
1463
1465
  context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -1,4 +1,4 @@
1
- """Element classes. This is an auto-generated file. Do not edit. See ../generate.py."""
1
+ """Inline classes."""
2
2
 
3
3
  from typing import Union
4
4