reflex 0.8.0a6__py3-none-any.whl → 0.8.1__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 (38) hide show
  1. reflex/.templates/web/utils/state.js +18 -1
  2. reflex/.templates/web/vite-plugin-safari-cachebust.js +160 -0
  3. reflex/.templates/web/vite.config.js +28 -6
  4. reflex/app.py +1 -1
  5. reflex/components/__init__.py +1 -0
  6. reflex/components/__init__.pyi +2 -0
  7. reflex/components/component.py +53 -1
  8. reflex/components/core/banner.py +3 -13
  9. reflex/components/core/upload.py +5 -5
  10. reflex/components/core/upload.pyi +2 -2
  11. reflex/components/el/__init__.py +7 -1
  12. reflex/components/el/__init__.pyi +2 -1
  13. reflex/components/radix/primitives/accordion.py +10 -29
  14. reflex/components/radix/primitives/accordion.pyi +7 -1
  15. reflex/components/radix/themes/typography/link.py +1 -30
  16. reflex/components/radix/themes/typography/link.pyi +1 -304
  17. reflex/components/react_router/__init__.py +5 -0
  18. reflex/components/react_router/dom.py +69 -0
  19. reflex/components/react_router/dom.pyi +321 -0
  20. reflex/components/recharts/recharts.py +2 -2
  21. reflex/config.py +7 -36
  22. reflex/constants/compiler.py +1 -1
  23. reflex/constants/installer.py +2 -2
  24. reflex/environment.py +116 -0
  25. reflex/event.py +18 -1
  26. reflex/istate/data.py +142 -69
  27. reflex/plugins/tailwind_v4.py +2 -2
  28. reflex/state.py +3 -3
  29. reflex/utils/exec.py +35 -8
  30. reflex/utils/lazy_loader.py +7 -1
  31. reflex/utils/misc.py +1 -2
  32. reflex/utils/processes.py +27 -3
  33. reflex/utils/pyi_generator.py +17 -2
  34. {reflex-0.8.0a6.dist-info → reflex-0.8.1.dist-info}/METADATA +3 -3
  35. {reflex-0.8.0a6.dist-info → reflex-0.8.1.dist-info}/RECORD +38 -34
  36. {reflex-0.8.0a6.dist-info → reflex-0.8.1.dist-info}/WHEEL +0 -0
  37. {reflex-0.8.0a6.dist-info → reflex-0.8.1.dist-info}/entry_points.txt +0 -0
  38. {reflex-0.8.0a6.dist-info → reflex-0.8.1.dist-info}/licenses/LICENSE +0 -0
@@ -295,6 +295,20 @@ export const applyEvent = async (event, socket, navigate, params) => {
295
295
  return false;
296
296
  }
297
297
 
298
+ if (event.name == "_blur_focus") {
299
+ const ref =
300
+ event.payload.ref in refs ? refs[event.payload.ref] : event.payload.ref;
301
+ const current = ref?.current;
302
+ if (current === undefined || current?.blur === undefined) {
303
+ console.error(
304
+ `No element found for ref ${event.payload.ref} in _blur_focus`,
305
+ );
306
+ } else {
307
+ current.blur();
308
+ }
309
+ return false;
310
+ }
311
+
298
312
  if (event.name == "_set_value") {
299
313
  const ref =
300
314
  event.payload.ref in refs ? refs[event.payload.ref] : event.payload.ref;
@@ -370,7 +384,10 @@ export const applyEvent = async (event, socket, navigate, params) => {
370
384
  ...Object.fromEntries(new URLSearchParams(window.location.search)),
371
385
  ...params(),
372
386
  },
373
- asPath: window.location.pathname + window.location.search,
387
+ asPath:
388
+ window.location.pathname +
389
+ window.location.search +
390
+ window.location.hash,
374
391
  };
375
392
  }
376
393
 
@@ -0,0 +1,160 @@
1
+ /* vite-plugin-safari-cachebust.js
2
+ *
3
+ * Rewrite modulepreload <link> tags and ESM imports to include a cache-busting
4
+ * query parameter for Safari browser.
5
+ *
6
+ * https://github.com/remix-run/react-router/issues/12761
7
+ *
8
+ * The issue seems to be Safari over-aggressive caching of ESM imports (and modulepreload)
9
+ * which does not respect the cache-control headers sent by the server. This approach
10
+ * allows hot reload to work in Safari when adding routes or changing dependencies.
11
+ *
12
+ * No equivalent transformation is needed for production builds, as the
13
+ * output already contains the file hash in the name.
14
+ */
15
+
16
+ /**
17
+ * @typedef {import('vite').Plugin} Plugin
18
+ * @typedef {import('vite').ViteDevServer} ViteDevServer
19
+ * @typedef {import('http').IncomingMessage} IncomingMessage
20
+ * @typedef {import('http').ServerResponse} ServerResponse
21
+ * @typedef {import('connect').NextHandleFunction} NextHandleFunction
22
+ */
23
+
24
+ const pluginName = "vite-plugin-safari-cachebust";
25
+
26
+ /**
27
+ * Creates a Vite plugin that adds cache-busting for Safari browsers
28
+ * @returns {Plugin} The Vite plugin
29
+ */
30
+ export default function safariCacheBustPlugin() {
31
+ return {
32
+ name: pluginName,
33
+ /**
34
+ * Configure the dev server with the Safari middleware
35
+ * @param {ViteDevServer} server - The Vite dev server instance
36
+ */
37
+ configureServer(server) {
38
+ server.middlewares.use(createSafariMiddleware());
39
+ },
40
+ };
41
+ }
42
+
43
+ /**
44
+ * Determines if the user agent is Safari
45
+ * @param {string} ua - The user agent string
46
+ * @returns {boolean} True if the browser is Safari
47
+ */
48
+ function isSafari(ua) {
49
+ return /Safari/.test(ua) && !/Chrome/.test(ua);
50
+ }
51
+
52
+ /**
53
+ * Creates a middleware that adds cache-busting for Safari browsers
54
+ * @returns {NextHandleFunction} The middleware function
55
+ */
56
+ function createSafariMiddleware() {
57
+ // Set when a log message for rewriting n links has been emitted.
58
+ let _have_logged_n = -1;
59
+
60
+ /**
61
+ * Rewrites module import links in HTML content with cache-busting parameters
62
+ * @param {string} html - The HTML content to process
63
+ * @returns {string} The processed HTML content
64
+ */
65
+ function rewriteModuleImports(html) {
66
+ const currentTimestamp = new Date().getTime();
67
+ const parts = html.split(/(<link\s+rel="modulepreload"[^>]*>)/g);
68
+ /** @type {[string, string][]} */
69
+ const replacements = parts
70
+ .map((chunk) => {
71
+ const match = chunk.match(
72
+ /<link\s+rel="modulepreload"\s+href="([^"]+)"(.*?)\/?>/,
73
+ );
74
+ if (!match) return;
75
+
76
+ const [fullMatch, href, rest] = match;
77
+ if (/^(https?:)?\/\//.test(href)) return;
78
+
79
+ try {
80
+ const newHref = href.includes("?")
81
+ ? `${href}&__reflex_ts=${currentTimestamp}`
82
+ : `${href}?__reflex_ts=${currentTimestamp}`;
83
+ return [href, newHref];
84
+ } catch {
85
+ // no worries;
86
+ }
87
+ })
88
+ .filter(Boolean);
89
+ if (replacements.length && _have_logged_n !== replacements.length) {
90
+ _have_logged_n = replacements.length;
91
+ console.debug(
92
+ `[${pluginName}] Rewrote ${replacements.length} modulepreload links with __reflex_ts param.`,
93
+ );
94
+ }
95
+ return replacements.reduce((accumulator, [target, replacement]) => {
96
+ return accumulator.split(target).join(replacement);
97
+ }, html);
98
+ }
99
+
100
+ /**
101
+ * Middleware function to handle Safari cache busting
102
+ * @param {IncomingMessage} req - The incoming request
103
+ * @param {ServerResponse} res - The server response
104
+ * @param {(err?: any) => void} next - The next middleware function
105
+ * @returns {void}
106
+ */
107
+ return function safariCacheBustMiddleware(req, res, next) {
108
+ const ua = req.headers["user-agent"] || "";
109
+ // Remove our special cache bust query param to avoid affecting lower middleware layers.
110
+ if (
111
+ req.url &&
112
+ (req.url.includes("?__reflex_ts=") || req.url.includes("&__reflex_ts="))
113
+ ) {
114
+ req.url = req.url.replace(/(\?|&)__reflex_ts=\d+/, "");
115
+ return next();
116
+ }
117
+
118
+ // Only apply this middleware for Safari browsers.
119
+ if (!isSafari(ua)) return next();
120
+
121
+ // Only transform requests that want HTML.
122
+ const header_accept = req.headers["accept"] || "";
123
+ if (
124
+ typeof header_accept !== "string" ||
125
+ !header_accept.includes("text/html")
126
+ ) {
127
+ return next();
128
+ }
129
+
130
+ let buffer = "";
131
+ const _end = res.end.bind(res);
132
+
133
+ res.setHeader("x-modified-by", "vite-plugin-safari-cachebust");
134
+ /**
135
+ * Overridden write method to collect chunks
136
+ * @param {any} chunk - The chunk to write
137
+ * @param {...any} args - Additional arguments
138
+ * @returns {boolean} Result of the write operation
139
+ */
140
+ res.write = function (chunk, ...args) {
141
+ buffer += chunk instanceof Buffer ? chunk.toString("utf-8") : chunk;
142
+ return true;
143
+ };
144
+
145
+ /**
146
+ * Overridden end method to process and send the final response
147
+ * @param {any} chunk - The final chunk to write
148
+ * @param {...any} args - Additional arguments
149
+ * @returns {ServerResponse<IncomingMessage>} The server response
150
+ */
151
+ res.end = function (chunk, ...args) {
152
+ if (chunk) {
153
+ buffer += chunk instanceof Buffer ? chunk.toString("utf-8") : chunk;
154
+ }
155
+ buffer = rewriteModuleImports(buffer);
156
+ return _end(buffer, ...args);
157
+ };
158
+ return next();
159
+ };
160
+ }
@@ -1,9 +1,35 @@
1
1
  import { fileURLToPath, URL } from "url";
2
2
  import { reactRouter } from "@react-router/dev/vite";
3
3
  import { defineConfig } from "vite";
4
+ import safariCacheBustPlugin from "./vite-plugin-safari-cachebust";
5
+
6
+ // Ensure that bun always uses the react-dom/server.node functions.
7
+ function alwaysUseReactDomServerNode() {
8
+ return {
9
+ name: "vite-plugin-always-use-react-dom-server-node",
10
+ enforce: "pre",
11
+
12
+ resolveId(source, importer) {
13
+ if (
14
+ typeof importer === "string" &&
15
+ importer.endsWith("/entry.server.node.tsx") &&
16
+ source.includes("react-dom/server")
17
+ ) {
18
+ return this.resolve("react-dom/server.node", importer, {
19
+ skipSelf: true,
20
+ });
21
+ }
22
+ return null;
23
+ },
24
+ };
25
+ }
4
26
 
5
27
  export default defineConfig((config) => ({
6
- plugins: [reactRouter()],
28
+ plugins: [
29
+ alwaysUseReactDomServerNode(),
30
+ reactRouter(),
31
+ safariCacheBustPlugin(),
32
+ ],
7
33
  build: {
8
34
  rollupOptions: {
9
35
  jsx: {},
@@ -29,10 +55,6 @@ export default defineConfig((config) => ({
29
55
  find: "@",
30
56
  replacement: fileURLToPath(new URL("./public", import.meta.url)),
31
57
  },
32
- ].concat(
33
- config.command === "build"
34
- ? [{ find: "react-dom/server", replacement: "react-dom/server.node" }]
35
- : [],
36
- ),
58
+ ],
37
59
  },
38
60
  }));
reflex/app.py CHANGED
@@ -1741,7 +1741,7 @@ async def process(
1741
1741
  if (path := router_data.get(constants.RouteVar.PATH))
1742
1742
  else "404"
1743
1743
  ).removeprefix("/")
1744
- state.router = RouterData(router_data)
1744
+ state.router = RouterData.from_router_data(router_data)
1745
1745
 
1746
1746
  # Preprocess the event.
1747
1747
  update = await app._preprocess(state, event)
@@ -14,6 +14,7 @@ _SUBMODULES: set[str] = {
14
14
  "plotly",
15
15
  "radix",
16
16
  "react_player",
17
+ "react_router",
17
18
  "sonner",
18
19
  "el",
19
20
  "base",
@@ -15,6 +15,7 @@ from . import (
15
15
  plotly,
16
16
  radix,
17
17
  react_player,
18
+ react_router,
18
19
  recharts,
19
20
  sonner,
20
21
  )
@@ -34,6 +35,7 @@ __all__ = [
34
35
  "plotly",
35
36
  "radix",
36
37
  "react_player",
38
+ "react_router",
37
39
  "recharts",
38
40
  "sonner",
39
41
  ]
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
  import contextlib
6
6
  import copy
7
7
  import dataclasses
8
+ import enum
8
9
  import functools
9
10
  import inspect
10
11
  import typing
@@ -479,6 +480,57 @@ def _components_from(
479
480
  return ()
480
481
 
481
482
 
483
+ def _deterministic_hash(value: object) -> int:
484
+ """Hash a rendered dictionary.
485
+
486
+ Args:
487
+ value: The dictionary to hash.
488
+
489
+ Returns:
490
+ The hash of the dictionary.
491
+
492
+ Raises:
493
+ TypeError: If the value is not hashable.
494
+ """
495
+ if isinstance(value, BaseComponent):
496
+ # If the value is a component, hash its rendered code.
497
+ rendered_code = value.render()
498
+ return _deterministic_hash(rendered_code)
499
+ if isinstance(value, Var):
500
+ return _deterministic_hash((value._js_expr, value._get_all_var_data()))
501
+ if isinstance(value, VarData):
502
+ return _deterministic_hash(dataclasses.asdict(value))
503
+ if isinstance(value, dict):
504
+ # Sort the dictionary to ensure consistent hashing.
505
+ return _deterministic_hash(
506
+ tuple(sorted((k, _deterministic_hash(v)) for k, v in value.items()))
507
+ )
508
+ if isinstance(value, int):
509
+ # Hash numbers and booleans directly.
510
+ return int(value)
511
+ if isinstance(value, float):
512
+ return _deterministic_hash(str(value))
513
+ if isinstance(value, str):
514
+ return int(md5(f'"{value}"'.encode()).hexdigest(), 16)
515
+ if isinstance(value, (tuple, list)):
516
+ # Hash tuples by hashing each element.
517
+ return _deterministic_hash(
518
+ "[" + ",".join(map(str, map(_deterministic_hash, value))) + "]"
519
+ )
520
+ if isinstance(value, enum.Enum):
521
+ # Hash enums by their name.
522
+ return _deterministic_hash(str(value))
523
+ if value is None:
524
+ # Hash None as a special case.
525
+ return _deterministic_hash("None")
526
+
527
+ msg = (
528
+ f"Cannot hash value `{value}` of type `{type(value).__name__}`. "
529
+ "Only BaseComponent, Var, VarData, dict, str, tuple, and enum.Enum are supported."
530
+ )
531
+ raise TypeError(msg)
532
+
533
+
482
534
  DEFAULT_TRIGGERS: Mapping[str, types.ArgsSpec | Sequence[types.ArgsSpec]] = {
483
535
  EventTriggers.ON_FOCUS: no_args_event_spec,
484
536
  EventTriggers.ON_BLUR: no_args_event_spec,
@@ -2430,7 +2482,7 @@ class StatefulComponent(BaseComponent):
2430
2482
  return None
2431
2483
 
2432
2484
  # Compute the hash based on the rendered code.
2433
- code_hash = md5(str(rendered_code).encode("utf-8")).hexdigest()
2485
+ code_hash = _deterministic_hash(rendered_code)
2434
2486
 
2435
2487
  # Format the tag name including the hash.
2436
2488
  return format.format_state_name(
@@ -268,7 +268,9 @@ class WifiOffPulse(Icon):
268
268
  Returns:
269
269
  The icon component with default props applied.
270
270
  """
271
- pulse_var = Var(_js_expr="pulse")
271
+ pulse_var = Var(r"keyframes({ from: { opacity: 0 }, to: { opacity: 1 } })").to(
272
+ str
273
+ )
272
274
  return super().create(
273
275
  "wifi_off",
274
276
  color=props.pop("color", "crimson"),
@@ -289,18 +291,6 @@ class WifiOffPulse(Icon):
289
291
  """
290
292
  return {"@emotion/react": [ImportVar(tag="keyframes")]}
291
293
 
292
- def _get_custom_code(self) -> str | None:
293
- return """
294
- const pulse = keyframes`
295
- 0% {
296
- opacity: 0;
297
- }
298
- 100% {
299
- opacity: 1;
300
- }
301
- `
302
- """
303
-
304
294
 
305
295
  class ConnectionPulser(Div):
306
296
  """A connection pulser component."""
@@ -50,7 +50,7 @@ upload_files_context_var_data: VarData = VarData(
50
50
  )
51
51
 
52
52
 
53
- def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var:
53
+ def upload_file(id_: str | Var[str] = DEFAULT_UPLOAD_ID) -> Var:
54
54
  """Get the file upload drop trigger.
55
55
 
56
56
  This var is passed to the dropzone component to update the file list when a
@@ -62,7 +62,7 @@ def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var:
62
62
  Returns:
63
63
  A var referencing the file upload drop trigger.
64
64
  """
65
- id_var = LiteralStringVar.create(id_)
65
+ id_var = LiteralStringVar.create(id_) if not isinstance(id_, Var) else id_
66
66
  var_name = f"""e => setFilesById(filesById => {{
67
67
  const updatedFilesById = Object.assign({{}}, filesById);
68
68
  updatedFilesById[{id_var!s}] = e;
@@ -79,7 +79,7 @@ def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var:
79
79
  )
80
80
 
81
81
 
82
- def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var:
82
+ def selected_files(id_: str | Var[str] = DEFAULT_UPLOAD_ID) -> Var:
83
83
  """Get the list of selected files.
84
84
 
85
85
  Args:
@@ -88,9 +88,9 @@ def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var:
88
88
  Returns:
89
89
  A var referencing the list of selected file paths.
90
90
  """
91
- id_var = LiteralStringVar.create(id_)
91
+ id_var = LiteralStringVar.create(id_) if not isinstance(id_, Var) else id_
92
92
  return Var(
93
- _js_expr=f"(filesById[{id_var!s}] ? filesById[{id_var!s}].map((f) => (f.path || f.name)) : [])",
93
+ _js_expr=f"(filesById[{id_var!s}] ? filesById[{id_var!s}].map((f) => f.name) : [])",
94
94
  _var_type=list[str],
95
95
  _var_data=VarData.merge(
96
96
  upload_files_context_var_data, id_var._get_all_var_data()
@@ -20,8 +20,8 @@ from reflex.vars.base import Var
20
20
  DEFAULT_UPLOAD_ID: str
21
21
  upload_files_context_var_data: VarData
22
22
 
23
- def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var: ...
24
- def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var: ...
23
+ def upload_file(id_: str | Var[str] = DEFAULT_UPLOAD_ID) -> Var: ...
24
+ def selected_files(id_: str | Var[str] = DEFAULT_UPLOAD_ID) -> Var: ...
25
25
  @CallableEventSpec
26
26
  def clear_selected_files(id_: str = DEFAULT_UPLOAD_ID) -> EventSpec: ...
27
27
  def cancel_upload(upload_id: str) -> EventSpec: ...
@@ -8,11 +8,17 @@ from . import elements
8
8
 
9
9
  _SUBMODULES: set[str] = {"elements"}
10
10
  _SUBMOD_ATTRS: dict[str, list[str]] = {
11
- f"elements.{k}": v for k, v in elements._MAPPING.items()
11
+ # rx.el.a is replaced by React Router's Link.
12
+ f"elements.{k}": [_v for _v in v if _v != "a"]
13
+ for k, v in elements._MAPPING.items()
14
+ }
15
+ _EXTRA_MAPPINGS: dict[str, str] = {
16
+ "a": "reflex.components.react_router.link",
12
17
  }
13
18
 
14
19
  __getattr__, __dir__, __all__ = lazy_loader.attach(
15
20
  __name__,
16
21
  submodules=_SUBMODULES,
17
22
  submod_attrs=_SUBMOD_ATTRS,
23
+ **_EXTRA_MAPPINGS,
18
24
  )
@@ -3,6 +3,8 @@
3
3
  # This file was generated by `reflex/utils/pyi_generator.py`!
4
4
  # ------------------------------------------------------
5
5
 
6
+ from reflex.components.react_router import link as a
7
+
6
8
  from . import elements
7
9
  from .elements.forms import (
8
10
  Button,
@@ -63,7 +65,6 @@ from .elements.inline import (
63
65
  Time,
64
66
  U,
65
67
  Wbr,
66
- a,
67
68
  abbr,
68
69
  b,
69
70
  bdi,
@@ -431,6 +431,14 @@ class AccordionIcon(Icon):
431
431
  return super().create(tag="chevron_down", class_name=cls_name, **props)
432
432
 
433
433
 
434
+ SLIDE_DOWN = Var(
435
+ r'keyframes({ from: { height: 0 }, to: { height: "var(--radix-accordion-content-height)" } })'
436
+ )
437
+ SLIDE_UP = Var(
438
+ r'keyframes({ from: { height: "var(--radix-accordion-content-height)" }, to: { height: 0 } })'
439
+ )
440
+
441
+
434
442
  class AccordionContent(AccordionComponent):
435
443
  """An accordion component."""
436
444
 
@@ -464,44 +472,17 @@ class AccordionContent(AccordionComponent):
464
472
 
465
473
  return super().create(*children, class_name=cls_name, **props)
466
474
 
467
- def add_custom_code(self) -> list[str]:
468
- """Add custom code to the component.
469
-
470
- Returns:
471
- The custom code of the component.
472
- """
473
- return [
474
- """
475
- const slideDown = keyframes`
476
- from {
477
- height: 0;
478
- }
479
- to {
480
- height: var(--radix-accordion-content-height);
481
- }
482
- `
483
- const slideUp = keyframes`
484
- from {
485
- height: var(--radix-accordion-content-height);
486
- }
487
- to {
488
- height: 0;
489
- }
490
- `
491
- """
492
- ]
493
-
494
475
  def add_style(self) -> dict[str, Any] | None:
495
476
  """Add style to the component.
496
477
 
497
478
  Returns:
498
479
  The style of the component.
499
480
  """
500
- slide_down = Var("slideDown").to(str) + Var.create(
481
+ slide_down = SLIDE_DOWN.to(str) + Var.create(
501
482
  " var(--animation-duration) var(--animation-easing)",
502
483
  )
503
484
 
504
- slide_up = Var("slideUp").to(str) + Var.create(
485
+ slide_up = SLIDE_UP.to(str) + Var.create(
505
486
  " var(--animation-duration) var(--animation-easing)",
506
487
  )
507
488
 
@@ -706,6 +706,13 @@ class AccordionIcon(Icon):
706
706
  The Accordion icon Component.
707
707
  """
708
708
 
709
+ SLIDE_DOWN = Var(
710
+ 'keyframes({ from: { height: 0 }, to: { height: "var(--radix-accordion-content-height)" } })'
711
+ )
712
+ SLIDE_UP = Var(
713
+ 'keyframes({ from: { height: "var(--radix-accordion-content-height)" }, to: { height: 0 } })'
714
+ )
715
+
709
716
  class AccordionContent(AccordionComponent):
710
717
  def add_imports(self) -> dict: ...
711
718
  @classmethod
@@ -824,7 +831,6 @@ class AccordionContent(AccordionComponent):
824
831
  The Accordion content Component.
825
832
  """
826
833
 
827
- def add_custom_code(self) -> list[str]: ...
828
834
  def add_style(self) -> dict[str, Any] | None: ...
829
835
 
830
836
  class Accordion(ComponentNamespace):
@@ -14,6 +14,7 @@ from reflex.components.core.cond import cond
14
14
  from reflex.components.el.elements.inline import A
15
15
  from reflex.components.markdown.markdown import MarkdownComponentMap
16
16
  from reflex.components.radix.themes.base import LiteralAccentColor, RadixThemesComponent
17
+ from reflex.components.react_router.dom import ReactRouterLink
17
18
  from reflex.utils.imports import ImportDict, ImportVar
18
19
  from reflex.vars.base import Var
19
20
 
@@ -21,36 +22,6 @@ from .base import LiteralTextSize, LiteralTextTrim, LiteralTextWeight
21
22
 
22
23
  LiteralLinkUnderline = Literal["auto", "hover", "always", "none"]
23
24
 
24
- LiteralLinkDiscover = Literal["none", "render"]
25
-
26
-
27
- class ReactRouterLink(A):
28
- """Links are accessible elements used primarily for navigation. This component is styled to resemble a hyperlink and semantically renders an <a>."""
29
-
30
- library = "react-router"
31
-
32
- tag = "Link"
33
-
34
- alias = "ReactRouterLink"
35
-
36
- # The page to link to.
37
- to: Var[str]
38
-
39
- # Replaces the current entry in the history stack instead of pushing a new one onto it.
40
- replace: Var[bool]
41
-
42
- # Will use document navigation instead of client side routing when the link is clicked: the browser will handle the transition normally (as if it were an <a href>).
43
- reload_document: Var[bool]
44
-
45
- # Prevents the scroll position from being reset to the top of the window when the link is clicked and the app is using ScrollRestoration. This only prevents new locations resetting scroll to the top, scroll position will be restored for back/forward button navigation.
46
- prevent_scroll_reset: Var[bool]
47
-
48
- # Defines the link discovery behavior
49
- discover: Var[LiteralLinkDiscover]
50
-
51
- # Enables a View Transition for this navigation.
52
- view_transition: Var[bool]
53
-
54
25
 
55
26
  _KNOWN_REACT_ROUTER_LINK_PROPS = frozenset(ReactRouterLink.get_props())
56
27