reflex 0.6.1a2__py3-none-any.whl → 0.6.2a1__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.
- reflex/.templates/jinja/web/pages/_app.js.jinja2 +6 -8
- reflex/.templates/web/utils/state.js +17 -5
- reflex/app.py +3 -14
- reflex/compiler/compiler.py +25 -1
- reflex/compiler/utils.py +4 -5
- reflex/components/component.py +32 -18
- reflex/components/dynamic.py +39 -9
- reflex/components/el/elements/media.py +89 -0
- reflex/components/el/elements/media.pyi +480 -0
- reflex/config.py +3 -2
- reflex/constants/base.py +22 -12
- reflex/constants/config.py +3 -4
- reflex/constants/custom_components.py +4 -3
- reflex/constants/installer.py +14 -15
- reflex/custom_components/custom_components.py +31 -40
- reflex/event.py +199 -4
- reflex/istate/data.py +126 -0
- reflex/model.py +2 -3
- reflex/reflex.py +5 -14
- reflex/state.py +88 -154
- reflex/utils/build.py +21 -16
- reflex/utils/compat.py +18 -0
- reflex/utils/exceptions.py +12 -0
- reflex/utils/exec.py +2 -2
- reflex/utils/format.py +1 -13
- reflex/utils/path_ops.py +3 -3
- reflex/utils/prerequisites.py +49 -88
- reflex/utils/processes.py +2 -2
- reflex/vars/base.py +44 -37
- {reflex-0.6.1a2.dist-info → reflex-0.6.2a1.dist-info}/METADATA +1 -2
- {reflex-0.6.1a2.dist-info → reflex-0.6.2a1.dist-info}/RECORD +34 -33
- {reflex-0.6.1a2.dist-info → reflex-0.6.2a1.dist-info}/LICENSE +0 -0
- {reflex-0.6.1a2.dist-info → reflex-0.6.2a1.dist-info}/WHEEL +0 -0
- {reflex-0.6.1a2.dist-info → reflex-0.6.2a1.dist-info}/entry_points.txt +0 -0
|
@@ -7,10 +7,9 @@ import '/styles/styles.css'
|
|
|
7
7
|
{% block declaration %}
|
|
8
8
|
import { EventLoopProvider, StateProvider, defaultColorMode } from "/utils/context.js";
|
|
9
9
|
import { ThemeProvider } from 'next-themes'
|
|
10
|
-
|
|
11
|
-
import * as
|
|
12
|
-
|
|
13
|
-
import * as radix from "@radix-ui/themes";
|
|
10
|
+
{% for library_alias, library_path in window_libraries %}
|
|
11
|
+
import * as {{library_alias}} from "{{library_path}}";
|
|
12
|
+
{% endfor %}
|
|
14
13
|
|
|
15
14
|
{% for custom_code in custom_codes %}
|
|
16
15
|
{{custom_code}}
|
|
@@ -33,10 +32,9 @@ export default function MyApp({ Component, pageProps }) {
|
|
|
33
32
|
React.useEffect(() => {
|
|
34
33
|
// Make contexts and state objects available globally for dynamic eval'd components
|
|
35
34
|
let windowImports = {
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
"/utils/state": utils_state,
|
|
35
|
+
{% for library_alias, library_path in window_libraries %}
|
|
36
|
+
"{{library_path}}": {{library_alias}},
|
|
37
|
+
{% endfor %}
|
|
40
38
|
};
|
|
41
39
|
window["__reflex"] = windowImports;
|
|
42
40
|
}, []);
|
|
@@ -544,13 +544,19 @@ export const uploadFiles = async (
|
|
|
544
544
|
|
|
545
545
|
/**
|
|
546
546
|
* Create an event object.
|
|
547
|
-
* @param name The name of the event.
|
|
548
|
-
* @param payload The payload of the event.
|
|
549
|
-
* @param
|
|
547
|
+
* @param {string} name The name of the event.
|
|
548
|
+
* @param {Object.<string, Any>} payload The payload of the event.
|
|
549
|
+
* @param {Object.<string, (number|boolean)>} event_actions The actions to take on the event.
|
|
550
|
+
* @param {string} handler The client handler to process event.
|
|
550
551
|
* @returns The event object.
|
|
551
552
|
*/
|
|
552
|
-
export const Event = (
|
|
553
|
-
|
|
553
|
+
export const Event = (
|
|
554
|
+
name,
|
|
555
|
+
payload = {},
|
|
556
|
+
event_actions = {},
|
|
557
|
+
handler = null
|
|
558
|
+
) => {
|
|
559
|
+
return { name, payload, handler, event_actions };
|
|
554
560
|
};
|
|
555
561
|
|
|
556
562
|
/**
|
|
@@ -676,6 +682,12 @@ export const useEventLoop = (
|
|
|
676
682
|
if (!(args instanceof Array)) {
|
|
677
683
|
args = [args];
|
|
678
684
|
}
|
|
685
|
+
|
|
686
|
+
event_actions = events.reduce(
|
|
687
|
+
(acc, e) => ({ ...acc, ...e.event_actions }),
|
|
688
|
+
event_actions ?? {}
|
|
689
|
+
);
|
|
690
|
+
|
|
679
691
|
const _e = args.filter((o) => o?.preventDefault !== undefined)[0];
|
|
680
692
|
|
|
681
693
|
if (event_actions?.preventDefault && _e?.preventDefault) {
|
reflex/app.py
CHANGED
|
@@ -431,25 +431,12 @@ class App(MiddlewareMixin, LifespanMixin, Base):
|
|
|
431
431
|
The generated component.
|
|
432
432
|
|
|
433
433
|
Raises:
|
|
434
|
-
VarOperationTypeError: When an invalid component var related function is passed.
|
|
435
|
-
TypeError: When an invalid component function is passed.
|
|
436
434
|
exceptions.MatchTypeError: If the return types of match cases in rx.match are different.
|
|
437
435
|
"""
|
|
438
|
-
from reflex.utils.exceptions import VarOperationTypeError
|
|
439
|
-
|
|
440
436
|
try:
|
|
441
437
|
return component if isinstance(component, Component) else component()
|
|
442
438
|
except exceptions.MatchTypeError:
|
|
443
439
|
raise
|
|
444
|
-
except TypeError as e:
|
|
445
|
-
message = str(e)
|
|
446
|
-
if "Var" in message:
|
|
447
|
-
raise VarOperationTypeError(
|
|
448
|
-
"You may be trying to use an invalid Python function on a state var. "
|
|
449
|
-
"When referencing a var inside your render code, only limited var operations are supported. "
|
|
450
|
-
"See the var operation docs here: https://reflex.dev/docs/vars/var-operations/"
|
|
451
|
-
) from e
|
|
452
|
-
raise e
|
|
453
440
|
|
|
454
441
|
def add_page(
|
|
455
442
|
self,
|
|
@@ -1536,7 +1523,9 @@ class EventNamespace(AsyncNamespace):
|
|
|
1536
1523
|
"""
|
|
1537
1524
|
fields = json.loads(data)
|
|
1538
1525
|
# Get the event.
|
|
1539
|
-
event = Event(
|
|
1526
|
+
event = Event(
|
|
1527
|
+
**{k: v for k, v in fields.items() if k not in ("handler", "event_actions")}
|
|
1528
|
+
)
|
|
1540
1529
|
|
|
1541
1530
|
self.token_to_sid[event.token] = sid
|
|
1542
1531
|
self.sid_to_token[sid] = event.token
|
reflex/compiler/compiler.py
CHANGED
|
@@ -40,6 +40,20 @@ def _compile_document_root(root: Component) -> str:
|
|
|
40
40
|
)
|
|
41
41
|
|
|
42
42
|
|
|
43
|
+
def _normalize_library_name(lib: str) -> str:
|
|
44
|
+
"""Normalize the library name.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
lib: The library name to normalize.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
The normalized library name.
|
|
51
|
+
"""
|
|
52
|
+
if lib == "react":
|
|
53
|
+
return "React"
|
|
54
|
+
return lib.replace("@", "").replace("/", "_").replace("-", "_")
|
|
55
|
+
|
|
56
|
+
|
|
43
57
|
def _compile_app(app_root: Component) -> str:
|
|
44
58
|
"""Compile the app template component.
|
|
45
59
|
|
|
@@ -49,10 +63,20 @@ def _compile_app(app_root: Component) -> str:
|
|
|
49
63
|
Returns:
|
|
50
64
|
The compiled app.
|
|
51
65
|
"""
|
|
66
|
+
from reflex.components.dynamic import bundled_libraries
|
|
67
|
+
|
|
68
|
+
window_libraries = [
|
|
69
|
+
(_normalize_library_name(name), name) for name in bundled_libraries
|
|
70
|
+
] + [
|
|
71
|
+
("utils_context", f"/{constants.Dirs.UTILS}/context"),
|
|
72
|
+
("utils_state", f"/{constants.Dirs.UTILS}/state"),
|
|
73
|
+
]
|
|
74
|
+
|
|
52
75
|
return templates.APP_ROOT.render(
|
|
53
76
|
imports=utils.compile_imports(app_root._get_all_imports()),
|
|
54
77
|
custom_codes=app_root._get_all_custom_code(),
|
|
55
78
|
hooks={**app_root._get_all_hooks_internal(), **app_root._get_all_hooks()},
|
|
79
|
+
window_libraries=window_libraries,
|
|
56
80
|
render=app_root.render(),
|
|
57
81
|
)
|
|
58
82
|
|
|
@@ -171,7 +195,7 @@ def _compile_root_stylesheet(stylesheets: list[str]) -> str:
|
|
|
171
195
|
stylesheet_full_path = (
|
|
172
196
|
Path.cwd() / constants.Dirs.APP_ASSETS / stylesheet.strip("/")
|
|
173
197
|
)
|
|
174
|
-
if not
|
|
198
|
+
if not stylesheet_full_path.exists():
|
|
175
199
|
raise FileNotFoundError(
|
|
176
200
|
f"The stylesheet file {stylesheet_full_path} does not exist."
|
|
177
201
|
)
|
reflex/compiler/utils.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import os
|
|
6
5
|
from pathlib import Path
|
|
7
6
|
from typing import Any, Callable, Dict, Optional, Type, Union
|
|
8
7
|
from urllib.parse import urlparse
|
|
@@ -457,16 +456,16 @@ def add_meta(
|
|
|
457
456
|
return page
|
|
458
457
|
|
|
459
458
|
|
|
460
|
-
def write_page(path: str, code: str):
|
|
459
|
+
def write_page(path: str | Path, code: str):
|
|
461
460
|
"""Write the given code to the given path.
|
|
462
461
|
|
|
463
462
|
Args:
|
|
464
463
|
path: The path to write the code to.
|
|
465
464
|
code: The code to write.
|
|
466
465
|
"""
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
466
|
+
path = Path(path)
|
|
467
|
+
path_ops.mkdir(path.parent)
|
|
468
|
+
path.write_text(code, encoding="utf-8")
|
|
470
469
|
|
|
471
470
|
|
|
472
471
|
def empty_dir(path: str | Path, keep_files: list[str] | None = None):
|
reflex/components/component.py
CHANGED
|
@@ -38,8 +38,10 @@ from reflex.constants import (
|
|
|
38
38
|
)
|
|
39
39
|
from reflex.event import (
|
|
40
40
|
EventChain,
|
|
41
|
+
EventChainVar,
|
|
41
42
|
EventHandler,
|
|
42
43
|
EventSpec,
|
|
44
|
+
EventVar,
|
|
43
45
|
call_event_fn,
|
|
44
46
|
call_event_handler,
|
|
45
47
|
get_handler_args,
|
|
@@ -514,7 +516,7 @@ class Component(BaseComponent, ABC):
|
|
|
514
516
|
Var,
|
|
515
517
|
EventHandler,
|
|
516
518
|
EventSpec,
|
|
517
|
-
List[Union[EventHandler, EventSpec]],
|
|
519
|
+
List[Union[EventHandler, EventSpec, EventVar]],
|
|
518
520
|
Callable,
|
|
519
521
|
],
|
|
520
522
|
) -> Union[EventChain, Var]:
|
|
@@ -532,11 +534,16 @@ class Component(BaseComponent, ABC):
|
|
|
532
534
|
"""
|
|
533
535
|
# If it's an event chain var, return it.
|
|
534
536
|
if isinstance(value, Var):
|
|
535
|
-
if value
|
|
537
|
+
if isinstance(value, EventChainVar):
|
|
538
|
+
return value
|
|
539
|
+
elif isinstance(value, EventVar):
|
|
540
|
+
value = [value]
|
|
541
|
+
elif issubclass(value._var_type, (EventChain, EventSpec)):
|
|
542
|
+
return self._create_event_chain(args_spec, value.guess_type())
|
|
543
|
+
else:
|
|
536
544
|
raise ValueError(
|
|
537
|
-
f"Invalid event chain: {
|
|
545
|
+
f"Invalid event chain: {str(value)} of type {value._var_type}"
|
|
538
546
|
)
|
|
539
|
-
return value
|
|
540
547
|
elif isinstance(value, EventChain):
|
|
541
548
|
# Trust that the caller knows what they're doing passing an EventChain directly
|
|
542
549
|
return value
|
|
@@ -547,7 +554,7 @@ class Component(BaseComponent, ABC):
|
|
|
547
554
|
|
|
548
555
|
# If the input is a list of event handlers, create an event chain.
|
|
549
556
|
if isinstance(value, List):
|
|
550
|
-
events:
|
|
557
|
+
events: List[Union[EventSpec, EventVar]] = []
|
|
551
558
|
for v in value:
|
|
552
559
|
if isinstance(v, (EventHandler, EventSpec)):
|
|
553
560
|
# Call the event handler to get the event.
|
|
@@ -561,6 +568,8 @@ class Component(BaseComponent, ABC):
|
|
|
561
568
|
"lambda inside an EventChain list."
|
|
562
569
|
)
|
|
563
570
|
events.extend(result)
|
|
571
|
+
elif isinstance(v, EventVar):
|
|
572
|
+
events.append(v)
|
|
564
573
|
else:
|
|
565
574
|
raise ValueError(f"Invalid event: {v}")
|
|
566
575
|
|
|
@@ -570,32 +579,30 @@ class Component(BaseComponent, ABC):
|
|
|
570
579
|
if isinstance(result, Var):
|
|
571
580
|
# Recursively call this function if the lambda returned an EventChain Var.
|
|
572
581
|
return self._create_event_chain(args_spec, result)
|
|
573
|
-
events = result
|
|
582
|
+
events = [*result]
|
|
574
583
|
|
|
575
584
|
# Otherwise, raise an error.
|
|
576
585
|
else:
|
|
577
586
|
raise ValueError(f"Invalid event chain: {value}")
|
|
578
587
|
|
|
579
588
|
# Add args to the event specs if necessary.
|
|
580
|
-
events = [
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
for e in events:
|
|
585
|
-
event_actions.update(e.event_actions)
|
|
589
|
+
events = [
|
|
590
|
+
(e.with_args(get_handler_args(e)) if isinstance(e, EventSpec) else e)
|
|
591
|
+
for e in events
|
|
592
|
+
]
|
|
586
593
|
|
|
587
594
|
# Return the event chain.
|
|
588
595
|
if isinstance(args_spec, Var):
|
|
589
596
|
return EventChain(
|
|
590
597
|
events=events,
|
|
591
598
|
args_spec=None,
|
|
592
|
-
event_actions=
|
|
599
|
+
event_actions={},
|
|
593
600
|
)
|
|
594
601
|
else:
|
|
595
602
|
return EventChain(
|
|
596
603
|
events=events,
|
|
597
604
|
args_spec=args_spec,
|
|
598
|
-
event_actions=
|
|
605
|
+
event_actions={},
|
|
599
606
|
)
|
|
600
607
|
|
|
601
608
|
def get_event_triggers(self) -> Dict[str, Any]:
|
|
@@ -1030,8 +1037,11 @@ class Component(BaseComponent, ABC):
|
|
|
1030
1037
|
elif isinstance(event, EventChain):
|
|
1031
1038
|
event_args = []
|
|
1032
1039
|
for spec in event.events:
|
|
1033
|
-
|
|
1034
|
-
|
|
1040
|
+
if isinstance(spec, EventSpec):
|
|
1041
|
+
for args in spec.args:
|
|
1042
|
+
event_args.extend(args)
|
|
1043
|
+
else:
|
|
1044
|
+
event_args.append(spec)
|
|
1035
1045
|
yield event_trigger, event_args
|
|
1036
1046
|
|
|
1037
1047
|
def _get_vars(self, include_children: bool = False) -> list[Var]:
|
|
@@ -1105,8 +1115,12 @@ class Component(BaseComponent, ABC):
|
|
|
1105
1115
|
for trigger in self.event_triggers.values():
|
|
1106
1116
|
if isinstance(trigger, EventChain):
|
|
1107
1117
|
for event in trigger.events:
|
|
1108
|
-
if event
|
|
1109
|
-
|
|
1118
|
+
if isinstance(event, EventSpec):
|
|
1119
|
+
if event.handler.state_full_name:
|
|
1120
|
+
return True
|
|
1121
|
+
else:
|
|
1122
|
+
if event._var_state:
|
|
1123
|
+
return True
|
|
1110
1124
|
elif isinstance(trigger, Var) and trigger._var_state:
|
|
1111
1125
|
return True
|
|
1112
1126
|
return False
|
reflex/components/dynamic.py
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
"""Components that are dynamically generated on the backend."""
|
|
2
2
|
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
3
5
|
from reflex import constants
|
|
4
6
|
from reflex.utils import imports
|
|
7
|
+
from reflex.utils.exceptions import DynamicComponentMissingLibrary
|
|
8
|
+
from reflex.utils.format import format_library_name
|
|
5
9
|
from reflex.utils.serializers import serializer
|
|
6
10
|
from reflex.vars import Var, get_unique_variable_name
|
|
7
11
|
from reflex.vars.base import VarData, transform
|
|
8
12
|
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from reflex.components.component import Component
|
|
15
|
+
|
|
9
16
|
|
|
10
17
|
def get_cdn_url(lib: str) -> str:
|
|
11
18
|
"""Get the CDN URL for a library.
|
|
@@ -19,6 +26,27 @@ def get_cdn_url(lib: str) -> str:
|
|
|
19
26
|
return f"https://cdn.jsdelivr.net/npm/{lib}" + "/+esm"
|
|
20
27
|
|
|
21
28
|
|
|
29
|
+
bundled_libraries = {
|
|
30
|
+
"react",
|
|
31
|
+
"@radix-ui/themes",
|
|
32
|
+
"@emotion/react",
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def bundle_library(component: "Component"):
|
|
37
|
+
"""Bundle a library with the component.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
component: The component to bundle the library with.
|
|
41
|
+
|
|
42
|
+
Raises:
|
|
43
|
+
DynamicComponentMissingLibrary: Raised when a dynamic component is missing a library.
|
|
44
|
+
"""
|
|
45
|
+
if component.library is None:
|
|
46
|
+
raise DynamicComponentMissingLibrary("Component must have a library to bundle.")
|
|
47
|
+
bundled_libraries.add(format_library_name(component.library))
|
|
48
|
+
|
|
49
|
+
|
|
22
50
|
def load_dynamic_serializer():
|
|
23
51
|
"""Load the serializer for dynamic components."""
|
|
24
52
|
# Causes a circular import, so we import here.
|
|
@@ -57,20 +85,15 @@ def load_dynamic_serializer():
|
|
|
57
85
|
)
|
|
58
86
|
] = None
|
|
59
87
|
|
|
60
|
-
libs_in_window =
|
|
61
|
-
"react",
|
|
62
|
-
"@radix-ui/themes",
|
|
63
|
-
]
|
|
88
|
+
libs_in_window = bundled_libraries
|
|
64
89
|
|
|
65
90
|
imports = {}
|
|
66
91
|
for lib, names in component._get_all_imports().items():
|
|
92
|
+
formatted_lib_name = format_library_name(lib)
|
|
67
93
|
if (
|
|
68
94
|
not lib.startswith((".", "/"))
|
|
69
95
|
and not lib.startswith("http")
|
|
70
|
-
and
|
|
71
|
-
not lib.startswith(lib_in_window)
|
|
72
|
-
for lib_in_window in libs_in_window
|
|
73
|
-
)
|
|
96
|
+
and formatted_lib_name not in libs_in_window
|
|
74
97
|
):
|
|
75
98
|
imports[get_cdn_url(lib)] = names
|
|
76
99
|
else:
|
|
@@ -108,7 +131,14 @@ def load_dynamic_serializer():
|
|
|
108
131
|
|
|
109
132
|
module_code_lines.insert(0, "const React = window.__reflex.react;")
|
|
110
133
|
|
|
111
|
-
return "
|
|
134
|
+
return "\n".join(
|
|
135
|
+
[
|
|
136
|
+
"//__reflex_evaluate",
|
|
137
|
+
"/** @jsx jsx */",
|
|
138
|
+
"const { jsx } = window.__reflex['@emotion/react']",
|
|
139
|
+
*module_code_lines,
|
|
140
|
+
]
|
|
141
|
+
)
|
|
112
142
|
|
|
113
143
|
@transform
|
|
114
144
|
def evaluate_component(js_string: Var[str]) -> Var[Component]:
|
|
@@ -317,6 +317,42 @@ class Svg(BaseHTML):
|
|
|
317
317
|
xmlns: Var[str]
|
|
318
318
|
|
|
319
319
|
|
|
320
|
+
class Text(BaseHTML):
|
|
321
|
+
"""The SVG text component."""
|
|
322
|
+
|
|
323
|
+
tag = "text"
|
|
324
|
+
# The x coordinate of the starting point of the text baseline.
|
|
325
|
+
x: Var[Union[str, int]]
|
|
326
|
+
# The y coordinate of the starting point of the text baseline.
|
|
327
|
+
y: Var[Union[str, int]]
|
|
328
|
+
# Shifts the text position horizontally from a previous text element.
|
|
329
|
+
dx: Var[Union[str, int]]
|
|
330
|
+
# Shifts the text position vertically from a previous text element.
|
|
331
|
+
dy: Var[Union[str, int]]
|
|
332
|
+
# Rotates orientation of each individual glyph.
|
|
333
|
+
rotate: Var[Union[str, int]]
|
|
334
|
+
# How the text is stretched or compressed to fit the width defined by the text_length attribute.
|
|
335
|
+
length_adjust: Var[str]
|
|
336
|
+
# A width that the text should be scaled to fit.
|
|
337
|
+
text_length: Var[Union[str, int]]
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
class Line(BaseHTML):
|
|
341
|
+
"""The SVG line component."""
|
|
342
|
+
|
|
343
|
+
tag = "line"
|
|
344
|
+
# The x-axis coordinate of the line starting point.
|
|
345
|
+
x1: Var[Union[str, int]]
|
|
346
|
+
# The x-axis coordinate of the the line ending point.
|
|
347
|
+
x2: Var[Union[str, int]]
|
|
348
|
+
# The y-axis coordinate of the line starting point.
|
|
349
|
+
y1: Var[Union[str, int]]
|
|
350
|
+
# The y-axis coordinate of the the line ending point.
|
|
351
|
+
y2: Var[Union[str, int]]
|
|
352
|
+
# The total path length, in user units.
|
|
353
|
+
path_length: Var[int]
|
|
354
|
+
|
|
355
|
+
|
|
320
356
|
class Circle(BaseHTML):
|
|
321
357
|
"""The SVG circle component."""
|
|
322
358
|
|
|
@@ -331,6 +367,22 @@ class Circle(BaseHTML):
|
|
|
331
367
|
path_length: Var[int]
|
|
332
368
|
|
|
333
369
|
|
|
370
|
+
class Ellipse(BaseHTML):
|
|
371
|
+
"""The SVG ellipse component."""
|
|
372
|
+
|
|
373
|
+
tag = "ellipse"
|
|
374
|
+
# The x position of the center of the ellipse.
|
|
375
|
+
cx: Var[Union[str, int]]
|
|
376
|
+
# The y position of the center of the ellipse.
|
|
377
|
+
cy: Var[Union[str, int]]
|
|
378
|
+
# The radius of the ellipse on the x axis.
|
|
379
|
+
rx: Var[Union[str, int]]
|
|
380
|
+
# The radius of the ellipse on the y axis.
|
|
381
|
+
ry: Var[Union[str, int]]
|
|
382
|
+
# The total length for the ellipse's circumference, in user units.
|
|
383
|
+
path_length: Var[int]
|
|
384
|
+
|
|
385
|
+
|
|
334
386
|
class Rect(BaseHTML):
|
|
335
387
|
"""The SVG rect component."""
|
|
336
388
|
|
|
@@ -394,6 +446,39 @@ class LinearGradient(BaseHTML):
|
|
|
394
446
|
y2: Var[Union[str, int, bool]]
|
|
395
447
|
|
|
396
448
|
|
|
449
|
+
class RadialGradient(BaseHTML):
|
|
450
|
+
"""Display the radialGradient element."""
|
|
451
|
+
|
|
452
|
+
tag = "radialGradient"
|
|
453
|
+
|
|
454
|
+
# The x coordinate of the end circle of the radial gradient.
|
|
455
|
+
cx: Var[Union[str, int, bool]]
|
|
456
|
+
|
|
457
|
+
# The y coordinate of the end circle of the radial gradient.
|
|
458
|
+
cy: Var[Union[str, int, bool]]
|
|
459
|
+
|
|
460
|
+
# The radius of the start circle of the radial gradient.
|
|
461
|
+
fr: Var[Union[str, int, bool]]
|
|
462
|
+
|
|
463
|
+
# The x coordinate of the start circle of the radial gradient.
|
|
464
|
+
fx: Var[Union[str, int, bool]]
|
|
465
|
+
|
|
466
|
+
# The y coordinate of the start circle of the radial gradient.
|
|
467
|
+
fy: Var[Union[str, int, bool]]
|
|
468
|
+
|
|
469
|
+
# Units for the gradient.
|
|
470
|
+
gradient_units: Var[Union[str, bool]]
|
|
471
|
+
|
|
472
|
+
# Transform applied to the gradient.
|
|
473
|
+
gradient_transform: Var[Union[str, bool]]
|
|
474
|
+
|
|
475
|
+
# The radius of the end circle of the radial gradient.
|
|
476
|
+
r: Var[Union[str, int, bool]]
|
|
477
|
+
|
|
478
|
+
# Method used to spread the gradient.
|
|
479
|
+
spread_method: Var[Union[str, bool]]
|
|
480
|
+
|
|
481
|
+
|
|
397
482
|
class Stop(BaseHTML):
|
|
398
483
|
"""Display the stop element."""
|
|
399
484
|
|
|
@@ -421,12 +506,16 @@ class Path(BaseHTML):
|
|
|
421
506
|
class SVG(ComponentNamespace):
|
|
422
507
|
"""SVG component namespace."""
|
|
423
508
|
|
|
509
|
+
text = staticmethod(Text.create)
|
|
510
|
+
line = staticmethod(Line.create)
|
|
424
511
|
circle = staticmethod(Circle.create)
|
|
512
|
+
ellipse = staticmethod(Ellipse.create)
|
|
425
513
|
rect = staticmethod(Rect.create)
|
|
426
514
|
polygon = staticmethod(Polygon.create)
|
|
427
515
|
path = staticmethod(Path.create)
|
|
428
516
|
stop = staticmethod(Stop.create)
|
|
429
517
|
linear_gradient = staticmethod(LinearGradient.create)
|
|
518
|
+
radial_gradient = staticmethod(RadialGradient.create)
|
|
430
519
|
defs = staticmethod(Defs.create)
|
|
431
520
|
__call__ = staticmethod(Svg.create)
|
|
432
521
|
|