reflex 0.5.1a3__py3-none-any.whl → 0.5.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/app.py +47 -2
- reflex/components/datadisplay/code.py +1 -1
- reflex/components/datadisplay/code.pyi +1 -1
- reflex/components/radix/primitives/accordion.py +74 -80
- reflex/components/radix/primitives/accordion.pyi +5 -5
- reflex/components/radix/primitives/form.py +8 -9
- reflex/components/radix/primitives/form.pyi +4 -5
- reflex/components/radix/primitives/progress.py +22 -27
- reflex/components/radix/primitives/progress.pyi +3 -4
- reflex/components/radix/primitives/slider.py +47 -56
- reflex/components/radix/primitives/slider.pyi +4 -5
- reflex/components/radix/themes/components/tabs.py +46 -0
- reflex/components/radix/themes/components/tabs.pyi +7 -0
- reflex/components/radix/themes/layout/center.py +7 -9
- reflex/components/radix/themes/layout/center.pyi +2 -2
- reflex/components/radix/themes/layout/list.py +6 -9
- reflex/components/radix/themes/layout/list.pyi +2 -3
- reflex/components/radix/themes/layout/spacer.py +7 -9
- reflex/components/radix/themes/layout/spacer.pyi +2 -2
- reflex/config.py +3 -0
- reflex/config.pyi +2 -0
- reflex/custom_components/custom_components.py +39 -14
- reflex/event.py +2 -1
- reflex/experimental/layout.py +3 -1
- reflex/state.py +5 -5
- reflex/style.py +2 -0
- reflex/testing.py +2 -0
- reflex/utils/exec.py +5 -1
- reflex/vars.py +22 -9
- {reflex-0.5.1a3.dist-info → reflex-0.5.2a1.dist-info}/METADATA +10 -9
- {reflex-0.5.1a3.dist-info → reflex-0.5.2a1.dist-info}/RECORD +34 -34
- {reflex-0.5.1a3.dist-info → reflex-0.5.2a1.dist-info}/LICENSE +0 -0
- {reflex-0.5.1a3.dist-info → reflex-0.5.2a1.dist-info}/WHEEL +0 -0
- {reflex-0.5.1a3.dist-info → reflex-0.5.2a1.dist-info}/entry_points.txt +0 -0
reflex/app.py
CHANGED
|
@@ -7,10 +7,12 @@ import concurrent.futures
|
|
|
7
7
|
import contextlib
|
|
8
8
|
import copy
|
|
9
9
|
import functools
|
|
10
|
+
import inspect
|
|
10
11
|
import io
|
|
11
12
|
import multiprocessing
|
|
12
13
|
import os
|
|
13
14
|
import platform
|
|
15
|
+
import sys
|
|
14
16
|
from typing import (
|
|
15
17
|
Any,
|
|
16
18
|
AsyncIterator,
|
|
@@ -100,7 +102,50 @@ class OverlayFragment(Fragment):
|
|
|
100
102
|
pass
|
|
101
103
|
|
|
102
104
|
|
|
103
|
-
class
|
|
105
|
+
class LifespanMixin(Base):
|
|
106
|
+
"""A Mixin that allow tasks to run during the whole app lifespan."""
|
|
107
|
+
|
|
108
|
+
# Lifespan tasks that are planned to run.
|
|
109
|
+
lifespan_tasks: Set[Union[asyncio.Task, Callable]] = set()
|
|
110
|
+
|
|
111
|
+
@contextlib.asynccontextmanager
|
|
112
|
+
async def _run_lifespan_tasks(self, app: FastAPI):
|
|
113
|
+
running_tasks = []
|
|
114
|
+
try:
|
|
115
|
+
async with contextlib.AsyncExitStack() as stack:
|
|
116
|
+
for task in self.lifespan_tasks:
|
|
117
|
+
if isinstance(task, asyncio.Task):
|
|
118
|
+
running_tasks.append(task)
|
|
119
|
+
else:
|
|
120
|
+
signature = inspect.signature(task)
|
|
121
|
+
if "app" in signature.parameters:
|
|
122
|
+
task = functools.partial(task, app=app)
|
|
123
|
+
_t = task()
|
|
124
|
+
if isinstance(_t, contextlib._AsyncGeneratorContextManager):
|
|
125
|
+
await stack.enter_async_context(_t)
|
|
126
|
+
elif isinstance(_t, Coroutine):
|
|
127
|
+
running_tasks.append(asyncio.create_task(_t))
|
|
128
|
+
yield
|
|
129
|
+
finally:
|
|
130
|
+
cancel_kwargs = (
|
|
131
|
+
{"msg": "lifespan_cleanup"} if sys.version_info >= (3, 9) else {}
|
|
132
|
+
)
|
|
133
|
+
for task in running_tasks:
|
|
134
|
+
task.cancel(**cancel_kwargs)
|
|
135
|
+
|
|
136
|
+
def register_lifespan_task(self, task: Callable | asyncio.Task, **task_kwargs):
|
|
137
|
+
"""Register a task to run during the lifespan of the app.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
task: The task to register.
|
|
141
|
+
task_kwargs: The kwargs of the task.
|
|
142
|
+
"""
|
|
143
|
+
if task_kwargs:
|
|
144
|
+
task = functools.partial(task, **task_kwargs) # type: ignore
|
|
145
|
+
self.lifespan_tasks.add(task) # type: ignore
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class App(LifespanMixin, Base):
|
|
104
149
|
"""The main Reflex app that encapsulates the backend and frontend.
|
|
105
150
|
|
|
106
151
|
Every Reflex app needs an app defined in its main module.
|
|
@@ -203,7 +248,7 @@ class App(Base):
|
|
|
203
248
|
self.middleware.append(HydrateMiddleware())
|
|
204
249
|
|
|
205
250
|
# Set up the API.
|
|
206
|
-
self.api = FastAPI()
|
|
251
|
+
self.api = FastAPI(lifespan=self._run_lifespan_tasks)
|
|
207
252
|
self._add_cors()
|
|
208
253
|
self._add_default_endpoints()
|
|
209
254
|
|
|
@@ -59,7 +59,7 @@ class AccordionComponent(RadixPrimitiveComponent):
|
|
|
59
59
|
# The variant of the component.
|
|
60
60
|
variant: Var[LiteralAccordionVariant]
|
|
61
61
|
|
|
62
|
-
def add_style(self)
|
|
62
|
+
def add_style(self):
|
|
63
63
|
"""Add style to the component."""
|
|
64
64
|
if self.color_scheme is not None:
|
|
65
65
|
self.custom_attrs["data-accent-color"] = self.color_scheme
|
|
@@ -250,43 +250,41 @@ class AccordionItem(AccordionComponent):
|
|
|
250
250
|
|
|
251
251
|
return super().create(*children, value=value, **props, class_name=cls_name)
|
|
252
252
|
|
|
253
|
-
def add_style(self) ->
|
|
253
|
+
def add_style(self) -> dict[str, Any] | None:
|
|
254
254
|
"""Add style to the component.
|
|
255
255
|
|
|
256
256
|
Returns:
|
|
257
257
|
The style of the component.
|
|
258
258
|
"""
|
|
259
259
|
divider_style = f"var(--divider-px) solid {color('gray', 6, alpha=True)}"
|
|
260
|
-
return
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
260
|
+
return {
|
|
261
|
+
"overflow": "hidden",
|
|
262
|
+
"width": "100%",
|
|
263
|
+
"margin_top": "1px",
|
|
264
|
+
"border_top": divider_style,
|
|
265
|
+
"&:first-child": {
|
|
266
|
+
"margin_top": 0,
|
|
267
|
+
"border_top": 0,
|
|
268
|
+
"border_top_left_radius": "var(--radius-4)",
|
|
269
|
+
"border_top_right_radius": "var(--radius-4)",
|
|
270
|
+
},
|
|
271
|
+
"&:last-child": {
|
|
272
|
+
"border_bottom_left_radius": "var(--radius-4)",
|
|
273
|
+
"border_bottom_right_radius": "var(--radius-4)",
|
|
274
|
+
},
|
|
275
|
+
"&:focus-within": {
|
|
276
|
+
"position": "relative",
|
|
277
|
+
"z_index": 1,
|
|
278
|
+
},
|
|
279
|
+
_inherited_variant_selector("ghost", "&:first-child"): {
|
|
280
|
+
"border_radius": 0,
|
|
265
281
|
"border_top": divider_style,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
"&:last-child": {
|
|
273
|
-
"border_bottom_left_radius": "var(--radius-4)",
|
|
274
|
-
"border_bottom_right_radius": "var(--radius-4)",
|
|
275
|
-
},
|
|
276
|
-
"&:focus-within": {
|
|
277
|
-
"position": "relative",
|
|
278
|
-
"z_index": 1,
|
|
279
|
-
},
|
|
280
|
-
_inherited_variant_selector("ghost", "&:first-child"): {
|
|
281
|
-
"border_radius": 0,
|
|
282
|
-
"border_top": divider_style,
|
|
283
|
-
},
|
|
284
|
-
_inherited_variant_selector("ghost", "&:last-child"): {
|
|
285
|
-
"border_radius": 0,
|
|
286
|
-
"border_bottom": divider_style,
|
|
287
|
-
},
|
|
288
|
-
}
|
|
289
|
-
)
|
|
282
|
+
},
|
|
283
|
+
_inherited_variant_selector("ghost", "&:last-child"): {
|
|
284
|
+
"border_radius": 0,
|
|
285
|
+
"border_bottom": divider_style,
|
|
286
|
+
},
|
|
287
|
+
}
|
|
290
288
|
|
|
291
289
|
|
|
292
290
|
class AccordionHeader(AccordionComponent):
|
|
@@ -314,13 +312,13 @@ class AccordionHeader(AccordionComponent):
|
|
|
314
312
|
|
|
315
313
|
return super().create(*children, class_name=cls_name, **props)
|
|
316
314
|
|
|
317
|
-
def add_style(self) ->
|
|
315
|
+
def add_style(self) -> dict[str, Any] | None:
|
|
318
316
|
"""Add style to the component.
|
|
319
317
|
|
|
320
318
|
Returns:
|
|
321
319
|
The style of the component.
|
|
322
320
|
"""
|
|
323
|
-
return
|
|
321
|
+
return {"display": "flex"}
|
|
324
322
|
|
|
325
323
|
|
|
326
324
|
class AccordionTrigger(AccordionComponent):
|
|
@@ -348,44 +346,42 @@ class AccordionTrigger(AccordionComponent):
|
|
|
348
346
|
|
|
349
347
|
return super().create(*children, class_name=cls_name, **props)
|
|
350
348
|
|
|
351
|
-
def add_style(self) ->
|
|
349
|
+
def add_style(self) -> dict[str, Any] | None:
|
|
352
350
|
"""Add style to the component.
|
|
353
351
|
|
|
354
352
|
Returns:
|
|
355
353
|
The style of the component.
|
|
356
354
|
"""
|
|
357
|
-
return
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
"
|
|
370
|
-
|
|
371
|
-
|
|
355
|
+
return {
|
|
356
|
+
"color": color("accent", 11),
|
|
357
|
+
"font_size": "1.1em",
|
|
358
|
+
"line_height": 1,
|
|
359
|
+
"justify_content": "space-between",
|
|
360
|
+
"align_items": "center",
|
|
361
|
+
"flex": 1,
|
|
362
|
+
"display": "flex",
|
|
363
|
+
"padding": "var(--space-3) var(--space-4)",
|
|
364
|
+
"width": "100%",
|
|
365
|
+
"box_shadow": f"0 var(--divider-px) 0 {color('gray', 6, alpha=True)}",
|
|
366
|
+
"&[data-state='open'] > .AccordionChevron": {
|
|
367
|
+
"transform": "rotate(180deg)",
|
|
368
|
+
},
|
|
369
|
+
"&:hover": {
|
|
370
|
+
"background_color": color("accent", 4),
|
|
371
|
+
},
|
|
372
|
+
"& > .AccordionChevron": {
|
|
373
|
+
"transition": f"transform var(--animation-duration) var(--animation-easing)",
|
|
374
|
+
},
|
|
375
|
+
_inherited_variant_selector("classic"): {
|
|
376
|
+
"color": "var(--accent-contrast)",
|
|
372
377
|
"&:hover": {
|
|
373
|
-
"background_color": color("accent",
|
|
378
|
+
"background_color": color("accent", 10),
|
|
374
379
|
},
|
|
375
380
|
"& > .AccordionChevron": {
|
|
376
|
-
"transition": f"transform var(--animation-duration) var(--animation-easing)",
|
|
377
|
-
},
|
|
378
|
-
_inherited_variant_selector("classic"): {
|
|
379
381
|
"color": "var(--accent-contrast)",
|
|
380
|
-
"&:hover": {
|
|
381
|
-
"background_color": color("accent", 10),
|
|
382
|
-
},
|
|
383
|
-
"& > .AccordionChevron": {
|
|
384
|
-
"color": "var(--accent-contrast)",
|
|
385
|
-
},
|
|
386
382
|
},
|
|
387
|
-
}
|
|
388
|
-
|
|
383
|
+
},
|
|
384
|
+
}
|
|
389
385
|
|
|
390
386
|
|
|
391
387
|
class AccordionIcon(Icon):
|
|
@@ -470,7 +466,7 @@ to {
|
|
|
470
466
|
"""
|
|
471
467
|
]
|
|
472
468
|
|
|
473
|
-
def add_style(self) ->
|
|
469
|
+
def add_style(self) -> dict[str, Any] | None:
|
|
474
470
|
"""Add style to the component.
|
|
475
471
|
|
|
476
472
|
Returns:
|
|
@@ -486,24 +482,22 @@ to {
|
|
|
486
482
|
_var_is_string=True,
|
|
487
483
|
)
|
|
488
484
|
|
|
489
|
-
return
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
"
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
)
|
|
485
|
+
return {
|
|
486
|
+
"overflow": "hidden",
|
|
487
|
+
"color": color("accent", 11),
|
|
488
|
+
"padding_x": "var(--space-4)",
|
|
489
|
+
# Apply before and after content to avoid height animation jank.
|
|
490
|
+
"&:before, &:after": {
|
|
491
|
+
"content": "' '",
|
|
492
|
+
"display": "block",
|
|
493
|
+
"height": "var(--space-3)",
|
|
494
|
+
},
|
|
495
|
+
"&[data-state='open']": {"animation": slideDown},
|
|
496
|
+
"&[data-state='closed']": {"animation": slideUp},
|
|
497
|
+
_inherited_variant_selector("classic"): {
|
|
498
|
+
"color": "var(--accent-contrast)",
|
|
499
|
+
},
|
|
500
|
+
}
|
|
507
501
|
|
|
508
502
|
|
|
509
503
|
class Accordion(ComponentNamespace):
|
|
@@ -26,7 +26,7 @@ DEFAULT_ANIMATION_DURATION = 250
|
|
|
26
26
|
DEFAULT_ANIMATION_EASING = "cubic-bezier(0.87, 0, 0.13, 1)"
|
|
27
27
|
|
|
28
28
|
class AccordionComponent(RadixPrimitiveComponent):
|
|
29
|
-
def add_style(self)
|
|
29
|
+
def add_style(self): ...
|
|
30
30
|
@overload
|
|
31
31
|
@classmethod
|
|
32
32
|
def create( # type: ignore
|
|
@@ -520,7 +520,7 @@ class AccordionItem(AccordionComponent):
|
|
|
520
520
|
The accordion item.
|
|
521
521
|
"""
|
|
522
522
|
...
|
|
523
|
-
def add_style(self) ->
|
|
523
|
+
def add_style(self) -> dict[str, Any] | None: ...
|
|
524
524
|
|
|
525
525
|
class AccordionHeader(AccordionComponent):
|
|
526
526
|
@overload
|
|
@@ -669,7 +669,7 @@ class AccordionHeader(AccordionComponent):
|
|
|
669
669
|
The Accordion header Component.
|
|
670
670
|
"""
|
|
671
671
|
...
|
|
672
|
-
def add_style(self) ->
|
|
672
|
+
def add_style(self) -> dict[str, Any] | None: ...
|
|
673
673
|
|
|
674
674
|
class AccordionTrigger(AccordionComponent):
|
|
675
675
|
@overload
|
|
@@ -818,7 +818,7 @@ class AccordionTrigger(AccordionComponent):
|
|
|
818
818
|
The Accordion trigger Component.
|
|
819
819
|
"""
|
|
820
820
|
...
|
|
821
|
-
def add_style(self) ->
|
|
821
|
+
def add_style(self) -> dict[str, Any] | None: ...
|
|
822
822
|
|
|
823
823
|
class AccordionIcon(Icon):
|
|
824
824
|
@overload
|
|
@@ -1047,7 +1047,7 @@ class AccordionContent(AccordionComponent):
|
|
|
1047
1047
|
"""
|
|
1048
1048
|
...
|
|
1049
1049
|
def add_custom_code(self) -> list[str]: ...
|
|
1050
|
-
def add_style(self) ->
|
|
1050
|
+
def add_style(self) -> dict[str, Any] | None: ...
|
|
1051
1051
|
|
|
1052
1052
|
class Accordion(ComponentNamespace):
|
|
1053
1053
|
content = staticmethod(AccordionContent.create)
|
|
@@ -8,7 +8,6 @@ from reflex.components.component import ComponentNamespace
|
|
|
8
8
|
from reflex.components.el.elements.forms import Form as HTMLForm
|
|
9
9
|
from reflex.components.radix.themes.components.text_field import TextFieldRoot
|
|
10
10
|
from reflex.constants.event import EventTriggers
|
|
11
|
-
from reflex.style import Style
|
|
12
11
|
from reflex.vars import Var
|
|
13
12
|
|
|
14
13
|
from .base import RadixPrimitiveComponentWithClassName
|
|
@@ -38,13 +37,13 @@ class FormRoot(FormComponent, HTMLForm):
|
|
|
38
37
|
EventTriggers.ON_CLEAR_SERVER_ERRORS: lambda: [],
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
def add_style(self) ->
|
|
40
|
+
def add_style(self) -> dict[str, Any] | None:
|
|
42
41
|
"""Add style to the component.
|
|
43
42
|
|
|
44
43
|
Returns:
|
|
45
44
|
The style of the component.
|
|
46
45
|
"""
|
|
47
|
-
return
|
|
46
|
+
return {"width": "100%"}
|
|
48
47
|
|
|
49
48
|
|
|
50
49
|
class FormField(FormComponent):
|
|
@@ -60,13 +59,13 @@ class FormField(FormComponent):
|
|
|
60
59
|
# Flag to mark the form field as invalid, for server side validation.
|
|
61
60
|
server_invalid: Var[bool]
|
|
62
61
|
|
|
63
|
-
def add_style(self) ->
|
|
62
|
+
def add_style(self) -> dict[str, Any] | None:
|
|
64
63
|
"""Add style to the component.
|
|
65
64
|
|
|
66
65
|
Returns:
|
|
67
66
|
The style of the component.
|
|
68
67
|
"""
|
|
69
|
-
return
|
|
68
|
+
return {"display": "grid", "margin_bottom": "10px"}
|
|
70
69
|
|
|
71
70
|
|
|
72
71
|
class FormLabel(FormComponent):
|
|
@@ -76,13 +75,13 @@ class FormLabel(FormComponent):
|
|
|
76
75
|
|
|
77
76
|
alias = "RadixFormLabel"
|
|
78
77
|
|
|
79
|
-
def add_style(self) ->
|
|
78
|
+
def add_style(self) -> dict[str, Any] | None:
|
|
80
79
|
"""Add style to the component.
|
|
81
80
|
|
|
82
81
|
Returns:
|
|
83
82
|
The style of the component.
|
|
84
83
|
"""
|
|
85
|
-
return
|
|
84
|
+
return {"font_size": "15px", "font_weight": "500", "line_height": "35px"}
|
|
86
85
|
|
|
87
86
|
|
|
88
87
|
class FormControl(FormComponent):
|
|
@@ -149,13 +148,13 @@ class FormMessage(FormComponent):
|
|
|
149
148
|
# Forces the message to be shown. This is useful when using server-side validation.
|
|
150
149
|
force_match: Var[bool]
|
|
151
150
|
|
|
152
|
-
def add_style(self) ->
|
|
151
|
+
def add_style(self) -> dict[str, Any] | None:
|
|
153
152
|
"""Add style to the component.
|
|
154
153
|
|
|
155
154
|
Returns:
|
|
156
155
|
The style of the component.
|
|
157
156
|
"""
|
|
158
|
-
return
|
|
157
|
+
return {"font_size": "13px", "opacity": "0.8", "color": "white"}
|
|
159
158
|
|
|
160
159
|
|
|
161
160
|
class FormValidityState(FormComponent):
|
|
@@ -12,7 +12,6 @@ from reflex.components.component import ComponentNamespace
|
|
|
12
12
|
from reflex.components.el.elements.forms import Form as HTMLForm
|
|
13
13
|
from reflex.components.radix.themes.components.text_field import TextFieldRoot
|
|
14
14
|
from reflex.constants.event import EventTriggers
|
|
15
|
-
from reflex.style import Style
|
|
16
15
|
from reflex.vars import Var
|
|
17
16
|
from .base import RadixPrimitiveComponentWithClassName
|
|
18
17
|
|
|
@@ -96,7 +95,7 @@ class FormComponent(RadixPrimitiveComponentWithClassName):
|
|
|
96
95
|
|
|
97
96
|
class FormRoot(FormComponent, HTMLForm):
|
|
98
97
|
def get_event_triggers(self) -> Dict[str, Any]: ...
|
|
99
|
-
def add_style(self) ->
|
|
98
|
+
def add_style(self) -> dict[str, Any] | None: ...
|
|
100
99
|
@overload
|
|
101
100
|
@classmethod
|
|
102
101
|
def create( # type: ignore
|
|
@@ -275,7 +274,7 @@ class FormRoot(FormComponent, HTMLForm):
|
|
|
275
274
|
...
|
|
276
275
|
|
|
277
276
|
class FormField(FormComponent):
|
|
278
|
-
def add_style(self) ->
|
|
277
|
+
def add_style(self) -> dict[str, Any] | None: ...
|
|
279
278
|
@overload
|
|
280
279
|
@classmethod
|
|
281
280
|
def create( # type: ignore
|
|
@@ -358,7 +357,7 @@ class FormField(FormComponent):
|
|
|
358
357
|
...
|
|
359
358
|
|
|
360
359
|
class FormLabel(FormComponent):
|
|
361
|
-
def add_style(self) ->
|
|
360
|
+
def add_style(self) -> dict[str, Any] | None: ...
|
|
362
361
|
@overload
|
|
363
362
|
@classmethod
|
|
364
363
|
def create( # type: ignore
|
|
@@ -532,7 +531,7 @@ LiteralMatcher = Literal[
|
|
|
532
531
|
]
|
|
533
532
|
|
|
534
533
|
class FormMessage(FormComponent):
|
|
535
|
-
def add_style(self) ->
|
|
534
|
+
def add_style(self) -> dict[str, Any] | None: ...
|
|
536
535
|
@overload
|
|
537
536
|
@classmethod
|
|
538
537
|
def create( # type: ignore
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import Optional
|
|
5
|
+
from typing import Any, Optional
|
|
6
6
|
|
|
7
7
|
from reflex.components.component import Component, ComponentNamespace
|
|
8
8
|
from reflex.components.core.colors import color
|
|
9
9
|
from reflex.components.radix.primitives.accordion import DEFAULT_ANIMATION_DURATION
|
|
10
10
|
from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName
|
|
11
11
|
from reflex.components.radix.themes.base import LiteralAccentColor, LiteralRadius
|
|
12
|
-
from reflex.style import Style
|
|
13
12
|
from reflex.vars import Var
|
|
14
13
|
|
|
15
14
|
|
|
@@ -28,7 +27,7 @@ class ProgressRoot(ProgressComponent):
|
|
|
28
27
|
# Override theme radius for progress bar: "none" | "small" | "medium" | "large" | "full"
|
|
29
28
|
radius: Var[LiteralRadius]
|
|
30
29
|
|
|
31
|
-
def add_style(self) ->
|
|
30
|
+
def add_style(self) -> dict[str, Any] | None:
|
|
32
31
|
"""Add style to the component.
|
|
33
32
|
|
|
34
33
|
Returns:
|
|
@@ -37,17 +36,15 @@ class ProgressRoot(ProgressComponent):
|
|
|
37
36
|
if self.radius is not None:
|
|
38
37
|
self.custom_attrs["data-radius"] = self.radius
|
|
39
38
|
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
)
|
|
39
|
+
return {
|
|
40
|
+
"position": "relative",
|
|
41
|
+
"overflow": "hidden",
|
|
42
|
+
"background": color("gray", 3, alpha=True),
|
|
43
|
+
"border_radius": "max(var(--radius-2), var(--radius-full))",
|
|
44
|
+
"width": "100%",
|
|
45
|
+
"height": "20px",
|
|
46
|
+
"boxShadow": f"inset 0 0 0 1px {color('gray', 5, alpha=True)}",
|
|
47
|
+
}
|
|
51
48
|
|
|
52
49
|
def _exclude_props(self) -> list[str]:
|
|
53
50
|
return ["radius"]
|
|
@@ -69,7 +66,7 @@ class ProgressIndicator(ProgressComponent):
|
|
|
69
66
|
# The color scheme of the progress indicator.
|
|
70
67
|
color_scheme: Var[LiteralAccentColor]
|
|
71
68
|
|
|
72
|
-
def add_style(self) ->
|
|
69
|
+
def add_style(self) -> dict[str, Any] | None:
|
|
73
70
|
"""Add style to the component.
|
|
74
71
|
|
|
75
72
|
Returns:
|
|
@@ -78,19 +75,17 @@ class ProgressIndicator(ProgressComponent):
|
|
|
78
75
|
if self.color_scheme is not None:
|
|
79
76
|
self.custom_attrs["data-accent-color"] = self.color_scheme
|
|
80
77
|
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
return {
|
|
79
|
+
"background_color": color("accent", 9),
|
|
80
|
+
"width": "100%",
|
|
81
|
+
"height": "100%",
|
|
82
|
+
"transition": f"transform {DEFAULT_ANIMATION_DURATION}ms linear",
|
|
83
|
+
"&[data_state='loading']": {
|
|
86
84
|
"transition": f"transform {DEFAULT_ANIMATION_DURATION}ms linear",
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"boxShadow": "inset 0 0 0 1px var(--gray-a5)",
|
|
92
|
-
}
|
|
93
|
-
)
|
|
85
|
+
},
|
|
86
|
+
"transform": f"translateX(calc(-100% + ({self.value} / {self.max} * 100%)))", # type: ignore
|
|
87
|
+
"boxShadow": "inset 0 0 0 1px var(--gray-a5)",
|
|
88
|
+
}
|
|
94
89
|
|
|
95
90
|
def _exclude_props(self) -> list[str]:
|
|
96
91
|
return ["color_scheme"]
|
|
@@ -7,13 +7,12 @@ from typing import Any, Dict, Literal, Optional, Union, overload
|
|
|
7
7
|
from reflex.vars import Var, BaseVar, ComputedVar
|
|
8
8
|
from reflex.event import EventChain, EventHandler, EventSpec
|
|
9
9
|
from reflex.style import Style
|
|
10
|
-
from typing import Optional
|
|
10
|
+
from typing import Any, Optional
|
|
11
11
|
from reflex.components.component import Component, ComponentNamespace
|
|
12
12
|
from reflex.components.core.colors import color
|
|
13
13
|
from reflex.components.radix.primitives.accordion import DEFAULT_ANIMATION_DURATION
|
|
14
14
|
from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName
|
|
15
15
|
from reflex.components.radix.themes.base import LiteralAccentColor, LiteralRadius
|
|
16
|
-
from reflex.style import Style
|
|
17
16
|
from reflex.vars import Var
|
|
18
17
|
|
|
19
18
|
class ProgressComponent(RadixPrimitiveComponentWithClassName):
|
|
@@ -95,7 +94,7 @@ class ProgressComponent(RadixPrimitiveComponentWithClassName):
|
|
|
95
94
|
...
|
|
96
95
|
|
|
97
96
|
class ProgressRoot(ProgressComponent):
|
|
98
|
-
def add_style(self) ->
|
|
97
|
+
def add_style(self) -> dict[str, Any] | None: ...
|
|
99
98
|
@overload
|
|
100
99
|
@classmethod
|
|
101
100
|
def create( # type: ignore
|
|
@@ -181,7 +180,7 @@ class ProgressRoot(ProgressComponent):
|
|
|
181
180
|
...
|
|
182
181
|
|
|
183
182
|
class ProgressIndicator(ProgressComponent):
|
|
184
|
-
def add_style(self) ->
|
|
183
|
+
def add_style(self) -> dict[str, Any] | None: ...
|
|
185
184
|
@overload
|
|
186
185
|
@classmethod
|
|
187
186
|
def create( # type: ignore
|