reflex 0.3.9a1__py3-none-any.whl → 0.3.9a2__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/utils.js.jinja2 +1 -1
- reflex/app.py +3 -4
- reflex/components/component.py +3 -1
- reflex/components/core/match.py +8 -4
- reflex/components/markdown/markdown.py +1 -0
- reflex/components/radix/__init__.py +2 -0
- reflex/components/radix/primitives/__init__.py +14 -1
- reflex/components/radix/primitives/accordion.py +426 -69
- reflex/components/radix/primitives/accordion.pyi +41 -11
- reflex/components/radix/primitives/base.py +4 -0
- reflex/components/radix/primitives/base.pyi +81 -0
- reflex/components/radix/primitives/form.py +4 -2
- reflex/components/radix/primitives/form.pyi +2 -2
- reflex/components/radix/primitives/progress.py +4 -2
- reflex/components/radix/primitives/progress.pyi +2 -2
- reflex/components/radix/primitives/slider.py +7 -5
- reflex/components/radix/primitives/slider.pyi +5 -5
- reflex/components/radix/themes/components/__init__.py +6 -2
- reflex/components/radix/themes/components/callout.py +36 -5
- reflex/components/radix/themes/components/callout.pyi +273 -9
- reflex/components/radix/themes/components/checkbox.py +41 -4
- reflex/components/radix/themes/components/checkbox.pyi +231 -8
- reflex/components/radix/themes/components/icons.py +1 -0
- reflex/components/radix/themes/components/radiogroup.py +65 -1
- reflex/components/radix/themes/components/radiogroup.pyi +252 -2
- reflex/components/radix/themes/components/select.py +81 -1
- reflex/components/radix/themes/components/select.pyi +237 -1
- reflex/state.py +6 -3
- reflex/style.py +15 -0
- reflex/utils/prerequisites.py +3 -1
- reflex/utils/types.py +4 -1
- reflex/vars.py +36 -3
- {reflex-0.3.9a1.dist-info → reflex-0.3.9a2.dist-info}/METADATA +1 -1
- {reflex-0.3.9a1.dist-info → reflex-0.3.9a2.dist-info}/RECORD +37 -37
- {reflex-0.3.9a1.dist-info → reflex-0.3.9a2.dist-info}/LICENSE +0 -0
- {reflex-0.3.9a1.dist-info → reflex-0.3.9a2.dist-info}/WHEEL +0 -0
- {reflex-0.3.9a1.dist-info → reflex-0.3.9a2.dist-info}/entry_points.txt +0 -0
|
@@ -1,22 +1,372 @@
|
|
|
1
1
|
"""Radix accordion components."""
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
from typing import Any, Dict, Literal
|
|
6
|
+
|
|
7
|
+
from reflex.components.base.fragment import Fragment
|
|
5
8
|
from reflex.components.component import Component
|
|
9
|
+
from reflex.components.core import cond, match
|
|
6
10
|
from reflex.components.radix.primitives.base import RadixPrimitiveComponent
|
|
7
11
|
from reflex.components.radix.themes.components.icons import Icon
|
|
8
|
-
from reflex.style import
|
|
12
|
+
from reflex.style import (
|
|
13
|
+
Style,
|
|
14
|
+
convert_dict_to_style_and_format_emotion,
|
|
15
|
+
format_as_emotion,
|
|
16
|
+
)
|
|
9
17
|
from reflex.utils import imports
|
|
10
|
-
from reflex.vars import Var
|
|
18
|
+
from reflex.vars import BaseVar, Var
|
|
11
19
|
|
|
12
20
|
LiteralAccordionType = Literal["single", "multiple"]
|
|
13
21
|
LiteralAccordionDir = Literal["ltr", "rtl"]
|
|
14
22
|
LiteralAccordionOrientation = Literal["vertical", "horizontal"]
|
|
15
|
-
|
|
23
|
+
LiteralAccordionRootVariant = Literal["classic", "soft", "surface", "outline", "ghost"]
|
|
24
|
+
LiteralAccordionRootColorScheme = Literal["primary", "accent"]
|
|
16
25
|
|
|
17
26
|
DEFAULT_ANIMATION_DURATION = 250
|
|
18
27
|
|
|
19
28
|
|
|
29
|
+
def get_theme_accordion_root(variant: Var[str], color_scheme: Var[str]) -> BaseVar:
|
|
30
|
+
"""Get the theme for the accordion root component.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
variant: The variant of the accordion.
|
|
34
|
+
color_scheme: The color of the accordion.
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
The theme for the accordion root component.
|
|
38
|
+
"""
|
|
39
|
+
return match( # type: ignore
|
|
40
|
+
variant,
|
|
41
|
+
(
|
|
42
|
+
"soft",
|
|
43
|
+
convert_dict_to_style_and_format_emotion(
|
|
44
|
+
{
|
|
45
|
+
"border_radius": "6px",
|
|
46
|
+
"background_color": cond(
|
|
47
|
+
color_scheme == "primary", "var(--accent-3)", "var(--slate-3)"
|
|
48
|
+
),
|
|
49
|
+
"box_shadow": "0 2px 10px var(--black-a1)",
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
),
|
|
53
|
+
(
|
|
54
|
+
"outline",
|
|
55
|
+
convert_dict_to_style_and_format_emotion(
|
|
56
|
+
{
|
|
57
|
+
"border_radius": "6px",
|
|
58
|
+
"border": cond(
|
|
59
|
+
color_scheme == "primary",
|
|
60
|
+
"1px solid var(--accent-6)",
|
|
61
|
+
"1px solid var(--slate-6)",
|
|
62
|
+
),
|
|
63
|
+
"box_shadow": "0 2px 10px var(--black-a1)",
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
),
|
|
67
|
+
(
|
|
68
|
+
"surface",
|
|
69
|
+
convert_dict_to_style_and_format_emotion(
|
|
70
|
+
{
|
|
71
|
+
"border_radius": "6px",
|
|
72
|
+
"border": cond(
|
|
73
|
+
color_scheme == "primary",
|
|
74
|
+
"1px solid var(--accent-6)",
|
|
75
|
+
"1px solid var(--slate-6)",
|
|
76
|
+
),
|
|
77
|
+
"background_color": cond(
|
|
78
|
+
color_scheme == "primary", "var(--accent-3)", "var(--slate-3)"
|
|
79
|
+
),
|
|
80
|
+
"box_shadow": "0 2px 10px var(--black-a1)",
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
),
|
|
84
|
+
(
|
|
85
|
+
"ghost",
|
|
86
|
+
convert_dict_to_style_and_format_emotion(
|
|
87
|
+
{
|
|
88
|
+
"border_radius": "6px",
|
|
89
|
+
"background_color": "none",
|
|
90
|
+
"box_shadow": "None",
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
),
|
|
94
|
+
convert_dict_to_style_and_format_emotion(
|
|
95
|
+
{
|
|
96
|
+
"border_radius": "6px",
|
|
97
|
+
"background_color": cond(
|
|
98
|
+
color_scheme == "primary", "var(--accent-9)", "var(--slate-9)"
|
|
99
|
+
),
|
|
100
|
+
"box_shadow": "0 2px 10px var(--black-a4)",
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
# defaults to classic
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def get_theme_accordion_item():
|
|
108
|
+
"""Get the theme for the accordion item component.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
The theme for the accordion item component.
|
|
112
|
+
"""
|
|
113
|
+
return convert_dict_to_style_and_format_emotion(
|
|
114
|
+
{
|
|
115
|
+
"overflow": "hidden",
|
|
116
|
+
"width": "100%",
|
|
117
|
+
"margin_top": "1px",
|
|
118
|
+
# "background_color": "var(--accent-3)",
|
|
119
|
+
# "background_color": cond(
|
|
120
|
+
# color_scheme == "primary", "var(--accent-3)", "var(--slate-3)"
|
|
121
|
+
# ),
|
|
122
|
+
"&:first-child": {
|
|
123
|
+
"margin_top": 0,
|
|
124
|
+
"border_top_left_radius": "4px",
|
|
125
|
+
"border_top_right_radius": "4px",
|
|
126
|
+
},
|
|
127
|
+
"&:last-child": {
|
|
128
|
+
"border_bottom_left_radius": "4px",
|
|
129
|
+
"border_bottom_right_radius": "4px",
|
|
130
|
+
},
|
|
131
|
+
"&:focus-within": {
|
|
132
|
+
"position": "relative",
|
|
133
|
+
"z_index": 1,
|
|
134
|
+
},
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def get_theme_accordion_header() -> dict[str, str]:
|
|
140
|
+
"""Get the theme for the accordion header component.
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
The theme for the accordion header component.
|
|
144
|
+
"""
|
|
145
|
+
return {
|
|
146
|
+
"display": "flex",
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def get_theme_accordion_trigger(variant: str | Var, color_scheme: str | Var) -> BaseVar:
|
|
151
|
+
"""Get the theme for the accordion trigger component.
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
variant: The variant of the accordion.
|
|
155
|
+
color_scheme: The color of the accordion.
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
The theme for the accordion trigger component.
|
|
159
|
+
"""
|
|
160
|
+
return match( # type: ignore
|
|
161
|
+
variant,
|
|
162
|
+
(
|
|
163
|
+
"soft",
|
|
164
|
+
convert_dict_to_style_and_format_emotion(
|
|
165
|
+
{
|
|
166
|
+
"color": cond(
|
|
167
|
+
color_scheme == "primary",
|
|
168
|
+
"var(--accent-9-contrast)",
|
|
169
|
+
"var(--slate-9-contrast)",
|
|
170
|
+
),
|
|
171
|
+
"&:hover": {
|
|
172
|
+
"background_color": cond(
|
|
173
|
+
color_scheme == "primary",
|
|
174
|
+
"var(--accent-4)",
|
|
175
|
+
"var(--slate-4)",
|
|
176
|
+
),
|
|
177
|
+
},
|
|
178
|
+
"& > .AccordionChevron": {
|
|
179
|
+
"color": cond(
|
|
180
|
+
color_scheme == "primary",
|
|
181
|
+
"var(--accent-11)",
|
|
182
|
+
"var(--slate-11)",
|
|
183
|
+
),
|
|
184
|
+
"transition": f"transform {DEFAULT_ANIMATION_DURATION}ms cubic-bezier(0.87, 0, 0.13, 1)",
|
|
185
|
+
},
|
|
186
|
+
"&[data-state='open'] > .AccordionChevron": {
|
|
187
|
+
"transform": "rotate(180deg)",
|
|
188
|
+
},
|
|
189
|
+
"font_family": "inherit",
|
|
190
|
+
"width": "100%",
|
|
191
|
+
"padding": "0 20px",
|
|
192
|
+
"height": "45px",
|
|
193
|
+
"flex": 1,
|
|
194
|
+
"display": "flex",
|
|
195
|
+
"align_items": "center",
|
|
196
|
+
"justify_content": "space-between",
|
|
197
|
+
"font_size": "15px",
|
|
198
|
+
"box_shadow": "0 1px 0 var(--accent-6)",
|
|
199
|
+
"line_height": 1,
|
|
200
|
+
}
|
|
201
|
+
),
|
|
202
|
+
),
|
|
203
|
+
(
|
|
204
|
+
"outline",
|
|
205
|
+
"surface",
|
|
206
|
+
"ghost",
|
|
207
|
+
convert_dict_to_style_and_format_emotion(
|
|
208
|
+
{
|
|
209
|
+
"color": cond(
|
|
210
|
+
color_scheme == "primary",
|
|
211
|
+
"var(--accent-11)",
|
|
212
|
+
"var(--slate-11)",
|
|
213
|
+
),
|
|
214
|
+
"&:hover": {
|
|
215
|
+
"background_color": cond(
|
|
216
|
+
color_scheme == "primary",
|
|
217
|
+
"var(--accent-4)",
|
|
218
|
+
"var(--slate-4)",
|
|
219
|
+
),
|
|
220
|
+
},
|
|
221
|
+
"& > .AccordionChevron": {
|
|
222
|
+
"color": cond(
|
|
223
|
+
color_scheme == "primary",
|
|
224
|
+
"var(--accent-11)",
|
|
225
|
+
"var(--slate-11)",
|
|
226
|
+
),
|
|
227
|
+
"transition": f"transform {DEFAULT_ANIMATION_DURATION}ms cubic-bezier(0.87, 0, 0.13, 1)",
|
|
228
|
+
},
|
|
229
|
+
"&[data-state='open'] > .AccordionChevron": {
|
|
230
|
+
"transform": "rotate(180deg)",
|
|
231
|
+
},
|
|
232
|
+
"font_family": "inherit",
|
|
233
|
+
"width": "100%",
|
|
234
|
+
"padding": "0 20px",
|
|
235
|
+
"height": "45px",
|
|
236
|
+
"flex": 1,
|
|
237
|
+
"display": "flex",
|
|
238
|
+
"align_items": "center",
|
|
239
|
+
"justify_content": "space-between",
|
|
240
|
+
"font_size": "15px",
|
|
241
|
+
"box_shadow": "0 1px 0 var(--accent-6)",
|
|
242
|
+
"line_height": 1,
|
|
243
|
+
}
|
|
244
|
+
),
|
|
245
|
+
),
|
|
246
|
+
# defaults to classic
|
|
247
|
+
convert_dict_to_style_and_format_emotion(
|
|
248
|
+
{
|
|
249
|
+
"color": cond(
|
|
250
|
+
color_scheme == "primary",
|
|
251
|
+
"var(--accent-9-contrast)",
|
|
252
|
+
"var(--slate-9-contrast)",
|
|
253
|
+
),
|
|
254
|
+
"box_shadow": "0 1px 0 var(--accent-6)",
|
|
255
|
+
"&:hover": {
|
|
256
|
+
"background_color": cond(
|
|
257
|
+
color_scheme == "primary", "var(--accent-10)", "var(--slate-10)"
|
|
258
|
+
),
|
|
259
|
+
},
|
|
260
|
+
"& > .AccordionChevron": {
|
|
261
|
+
"color": cond(
|
|
262
|
+
color_scheme == "primary",
|
|
263
|
+
"var(--accent-9-contrast)",
|
|
264
|
+
"var(--slate-9-contrast)",
|
|
265
|
+
),
|
|
266
|
+
"transition": f"transform {DEFAULT_ANIMATION_DURATION}ms cubic-bezier(0.87, 0, 0.13, 1)",
|
|
267
|
+
},
|
|
268
|
+
"&[data-state='open'] > .AccordionChevron": {
|
|
269
|
+
"transform": "rotate(180deg)",
|
|
270
|
+
},
|
|
271
|
+
"font_family": "inherit",
|
|
272
|
+
"width": "100%",
|
|
273
|
+
"padding": "0 20px",
|
|
274
|
+
"height": "45px",
|
|
275
|
+
"flex": 1,
|
|
276
|
+
"display": "flex",
|
|
277
|
+
"align_items": "center",
|
|
278
|
+
"justify_content": "space-between",
|
|
279
|
+
"font_size": "15px",
|
|
280
|
+
"line_height": 1,
|
|
281
|
+
}
|
|
282
|
+
),
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def get_theme_accordion_content(variant: str | Var, color_scheme: str | Var) -> BaseVar:
|
|
287
|
+
"""Get the theme for the accordion content component.
|
|
288
|
+
|
|
289
|
+
Args:
|
|
290
|
+
variant: The variant of the accordion.
|
|
291
|
+
color_scheme: The color of the accordion.
|
|
292
|
+
|
|
293
|
+
Returns:
|
|
294
|
+
The theme for the accordion content component.
|
|
295
|
+
"""
|
|
296
|
+
return match( # type: ignore
|
|
297
|
+
variant,
|
|
298
|
+
(
|
|
299
|
+
"outline",
|
|
300
|
+
"ghost",
|
|
301
|
+
convert_dict_to_style_and_format_emotion(
|
|
302
|
+
{
|
|
303
|
+
"overflow": "hidden",
|
|
304
|
+
"font_size": "10px",
|
|
305
|
+
"color": cond(
|
|
306
|
+
color_scheme == "primary",
|
|
307
|
+
"var(--accent-9-contrast)",
|
|
308
|
+
"var(--slate-9-contrast)",
|
|
309
|
+
),
|
|
310
|
+
"background_color": cond(
|
|
311
|
+
color_scheme == "primary", "var(--accent-3)", "var(--slate-3)"
|
|
312
|
+
),
|
|
313
|
+
"padding": "15px, 20px",
|
|
314
|
+
"&[data-state='open']": {
|
|
315
|
+
"animation": Var.create(
|
|
316
|
+
f"${{slideDown}} {DEFAULT_ANIMATION_DURATION}ms cubic-bezier(0.87, 0, 0.13, 1)",
|
|
317
|
+
_var_is_string=True,
|
|
318
|
+
),
|
|
319
|
+
},
|
|
320
|
+
"&[data-state='closed']": {
|
|
321
|
+
"animation": Var.create(
|
|
322
|
+
f"${{slideUp}} {DEFAULT_ANIMATION_DURATION}ms cubic-bezier(0.87, 0, 0.13, 1)",
|
|
323
|
+
_var_is_string=True,
|
|
324
|
+
),
|
|
325
|
+
},
|
|
326
|
+
}
|
|
327
|
+
),
|
|
328
|
+
),
|
|
329
|
+
convert_dict_to_style_and_format_emotion(
|
|
330
|
+
{
|
|
331
|
+
"overflow": "hidden",
|
|
332
|
+
"font_size": "10px",
|
|
333
|
+
"color": cond(
|
|
334
|
+
color_scheme == "primary",
|
|
335
|
+
"var(--accent-9-contrast)",
|
|
336
|
+
"var(--slate-9-contrast)",
|
|
337
|
+
),
|
|
338
|
+
"background_color": match(
|
|
339
|
+
variant,
|
|
340
|
+
(
|
|
341
|
+
"classic",
|
|
342
|
+
cond(
|
|
343
|
+
color_scheme == "primary",
|
|
344
|
+
"var(--accent-9)",
|
|
345
|
+
"var(--slate-9)",
|
|
346
|
+
),
|
|
347
|
+
),
|
|
348
|
+
cond(
|
|
349
|
+
color_scheme == "primary", "var(--accent-3)", "var(--slate-3)"
|
|
350
|
+
),
|
|
351
|
+
),
|
|
352
|
+
"padding": "15px, 20px",
|
|
353
|
+
"&[data-state='open']": {
|
|
354
|
+
"animation": Var.create(
|
|
355
|
+
f"${{slideDown}} {DEFAULT_ANIMATION_DURATION}ms cubic-bezier(0.87, 0, 0.13, 1)",
|
|
356
|
+
_var_is_string=True,
|
|
357
|
+
),
|
|
358
|
+
},
|
|
359
|
+
"&[data-state='closed']": {
|
|
360
|
+
"animation": Var.create(
|
|
361
|
+
f"${{slideUp}} {DEFAULT_ANIMATION_DURATION}ms cubic-bezier(0.87, 0, 0.13, 1)",
|
|
362
|
+
_var_is_string=True,
|
|
363
|
+
),
|
|
364
|
+
},
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
|
|
20
370
|
class AccordionComponent(RadixPrimitiveComponent):
|
|
21
371
|
"""Base class for all @radix-ui/accordion components."""
|
|
22
372
|
|
|
@@ -51,16 +401,78 @@ class AccordionRoot(AccordionComponent):
|
|
|
51
401
|
# The orientation of the accordion.
|
|
52
402
|
orientation: Var[LiteralAccordionOrientation]
|
|
53
403
|
|
|
404
|
+
# The variant of the accordion.
|
|
405
|
+
variant: Var[LiteralAccordionRootVariant] = "classic" # type: ignore
|
|
406
|
+
|
|
407
|
+
# The color scheme of the accordion.
|
|
408
|
+
color_scheme: Var[LiteralAccordionRootColorScheme] = "primary" # type: ignore
|
|
409
|
+
|
|
410
|
+
# dynamic themes of the accordion generated at compile time.
|
|
411
|
+
_dynamic_themes: Var[dict]
|
|
412
|
+
|
|
413
|
+
@classmethod
|
|
414
|
+
def create(cls, *children, **props) -> Component:
|
|
415
|
+
"""Create the Accordion root component.
|
|
416
|
+
|
|
417
|
+
Args:
|
|
418
|
+
*children: The children of the component.
|
|
419
|
+
**props: The properties of the component.
|
|
420
|
+
|
|
421
|
+
Returns:
|
|
422
|
+
The Accordion root Component.
|
|
423
|
+
"""
|
|
424
|
+
comp = super().create(*children, **props)
|
|
425
|
+
|
|
426
|
+
if not comp.color_scheme._var_state: # type: ignore
|
|
427
|
+
# mark the vars of color string literals as strings so they can be formatted properly when performing a var operation.
|
|
428
|
+
comp.color_scheme._var_is_string = True # type: ignore
|
|
429
|
+
|
|
430
|
+
if not comp.variant._var_state: # type: ignore
|
|
431
|
+
# mark the vars of variant string literals as strings so they are formatted properly in the match condition.
|
|
432
|
+
comp.variant._var_is_string = True # type: ignore
|
|
433
|
+
|
|
434
|
+
# remove Fragment and cond wrap workaround when https://github.com/reflex-dev/reflex/issues/2393 is resolved.
|
|
435
|
+
return Fragment.create(comp, cond(True, Fragment.create()))
|
|
436
|
+
|
|
437
|
+
def _get_style(self) -> dict:
|
|
438
|
+
"""Get the style for the component.
|
|
439
|
+
|
|
440
|
+
Returns:
|
|
441
|
+
The dictionary of the component style as value and the style notation as key.
|
|
442
|
+
"""
|
|
443
|
+
return {"css": self._dynamic_themes._merge(format_as_emotion(self.style))} # type: ignore
|
|
444
|
+
|
|
54
445
|
def _apply_theme(self, theme: Component):
|
|
55
|
-
self.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
446
|
+
self._dynamic_themes = Var.create( # type: ignore
|
|
447
|
+
convert_dict_to_style_and_format_emotion(
|
|
448
|
+
{
|
|
449
|
+
"& .AccordionItem": get_theme_accordion_item(),
|
|
450
|
+
"& .AccordionHeader": get_theme_accordion_header(),
|
|
451
|
+
"& .AccordionTrigger": get_theme_accordion_trigger(
|
|
452
|
+
variant=self.variant, color_scheme=self.color_scheme
|
|
453
|
+
),
|
|
454
|
+
"& .AccordionContent": get_theme_accordion_content(
|
|
455
|
+
variant=self.variant, color_scheme=self.color_scheme
|
|
456
|
+
),
|
|
457
|
+
}
|
|
458
|
+
)
|
|
459
|
+
)._merge( # type: ignore
|
|
460
|
+
get_theme_accordion_root(
|
|
461
|
+
variant=self.variant, color_scheme=self.color_scheme
|
|
462
|
+
)
|
|
62
463
|
)
|
|
63
464
|
|
|
465
|
+
def get_event_triggers(self) -> Dict[str, Any]:
|
|
466
|
+
"""Get the events triggers signatures for the component.
|
|
467
|
+
|
|
468
|
+
Returns:
|
|
469
|
+
The signatures of the event triggers.
|
|
470
|
+
"""
|
|
471
|
+
return {
|
|
472
|
+
**super().get_event_triggers(),
|
|
473
|
+
"on_value_change": lambda e0: [e0],
|
|
474
|
+
}
|
|
475
|
+
|
|
64
476
|
|
|
65
477
|
class AccordionItem(AccordionComponent):
|
|
66
478
|
"""An accordion component."""
|
|
@@ -78,22 +490,6 @@ class AccordionItem(AccordionComponent):
|
|
|
78
490
|
def _apply_theme(self, theme: Component):
|
|
79
491
|
self.style = Style(
|
|
80
492
|
{
|
|
81
|
-
"overflow": "hidden",
|
|
82
|
-
"margin_top": "1px",
|
|
83
|
-
"&:first-child": {
|
|
84
|
-
"margin_top": 0,
|
|
85
|
-
"border_top_left_radius": "4px",
|
|
86
|
-
"border_top_right_radius": "4px",
|
|
87
|
-
},
|
|
88
|
-
"&:last-child": {
|
|
89
|
-
"border_bottom_left_radius": "4px",
|
|
90
|
-
"border_bottom_right_radius": "4px",
|
|
91
|
-
},
|
|
92
|
-
"&:focus-within": {
|
|
93
|
-
"position": "relative",
|
|
94
|
-
"z_index": 1,
|
|
95
|
-
"box_shadow": "0 0 0 2px var(--accent-7)",
|
|
96
|
-
},
|
|
97
493
|
**self.style,
|
|
98
494
|
}
|
|
99
495
|
)
|
|
@@ -109,7 +505,6 @@ class AccordionHeader(AccordionComponent):
|
|
|
109
505
|
def _apply_theme(self, theme: Component):
|
|
110
506
|
self.style = Style(
|
|
111
507
|
{
|
|
112
|
-
"display": "flex",
|
|
113
508
|
**self.style,
|
|
114
509
|
}
|
|
115
510
|
)
|
|
@@ -125,27 +520,6 @@ class AccordionTrigger(AccordionComponent):
|
|
|
125
520
|
def _apply_theme(self, theme: Component):
|
|
126
521
|
self.style = Style(
|
|
127
522
|
{
|
|
128
|
-
"font_family": "inherit",
|
|
129
|
-
"padding": "0 20px",
|
|
130
|
-
"height": "45px",
|
|
131
|
-
"flex": 1,
|
|
132
|
-
"display": "flex",
|
|
133
|
-
"align_items": "center",
|
|
134
|
-
"justify_content": "space-between",
|
|
135
|
-
"font_size": "15px",
|
|
136
|
-
"line_height": 1,
|
|
137
|
-
"color": "var(--accent-11)",
|
|
138
|
-
"box_shadow": "0 1px 0 var(--accent-6)",
|
|
139
|
-
"&:hover": {
|
|
140
|
-
"background_color": "var(--gray-2)",
|
|
141
|
-
},
|
|
142
|
-
"& > .AccordionChevron": {
|
|
143
|
-
"color": "var(--accent-10)",
|
|
144
|
-
"transition": f"transform {DEFAULT_ANIMATION_DURATION}ms cubic-bezier(0.87, 0, 0.13, 1)",
|
|
145
|
-
},
|
|
146
|
-
"&[data-state='open'] > .AccordionChevron": {
|
|
147
|
-
"transform": "rotate(180deg)",
|
|
148
|
-
},
|
|
149
523
|
**self.style,
|
|
150
524
|
}
|
|
151
525
|
)
|
|
@@ -161,23 +535,6 @@ class AccordionContent(AccordionComponent):
|
|
|
161
535
|
def _apply_theme(self, theme: Component):
|
|
162
536
|
self.style = Style(
|
|
163
537
|
{
|
|
164
|
-
"overflow": "hidden",
|
|
165
|
-
"fontSize": "15px",
|
|
166
|
-
"color": "var(--accent-11)",
|
|
167
|
-
"backgroundColor": "var(--accent-2)",
|
|
168
|
-
"padding": "15px, 20px",
|
|
169
|
-
"&[data-state='open']": {
|
|
170
|
-
"animation": Var.create(
|
|
171
|
-
f"${{slideDown}} {DEFAULT_ANIMATION_DURATION}ms cubic-bezier(0.87, 0, 0.13, 1)",
|
|
172
|
-
_var_is_string=True,
|
|
173
|
-
),
|
|
174
|
-
},
|
|
175
|
-
"&[data-state='closed']": {
|
|
176
|
-
"animation": Var.create(
|
|
177
|
-
f"${{slideUp}} {DEFAULT_ANIMATION_DURATION}ms cubic-bezier(0.87, 0, 0.13, 1)",
|
|
178
|
-
_var_is_string=True,
|
|
179
|
-
),
|
|
180
|
-
},
|
|
181
538
|
**self.style,
|
|
182
539
|
}
|
|
183
540
|
)
|
|
@@ -231,14 +588,14 @@ def accordion_item(header: Component, content: Component, **props) -> Component:
|
|
|
231
588
|
tag="chevron_down",
|
|
232
589
|
class_name="AccordionChevron",
|
|
233
590
|
),
|
|
591
|
+
class_name="AccordionTrigger",
|
|
234
592
|
),
|
|
235
593
|
),
|
|
236
594
|
AccordionContent.create(
|
|
237
595
|
content,
|
|
596
|
+
class_name="AccordionContent",
|
|
238
597
|
),
|
|
239
598
|
value=value,
|
|
240
599
|
**props,
|
|
600
|
+
class_name="AccordionItem",
|
|
241
601
|
)
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
accordion = AccordionRoot.create
|
|
@@ -7,19 +7,37 @@ 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 Literal
|
|
10
|
+
from typing import Any, Dict, Literal
|
|
11
|
+
from reflex.components.base.fragment import Fragment
|
|
11
12
|
from reflex.components.component import Component
|
|
13
|
+
from reflex.components.core import cond, match
|
|
12
14
|
from reflex.components.radix.primitives.base import RadixPrimitiveComponent
|
|
13
15
|
from reflex.components.radix.themes.components.icons import Icon
|
|
14
|
-
from reflex.style import
|
|
16
|
+
from reflex.style import (
|
|
17
|
+
Style,
|
|
18
|
+
convert_dict_to_style_and_format_emotion,
|
|
19
|
+
format_as_emotion,
|
|
20
|
+
)
|
|
15
21
|
from reflex.utils import imports
|
|
16
|
-
from reflex.vars import Var
|
|
22
|
+
from reflex.vars import BaseVar, Var
|
|
17
23
|
|
|
18
24
|
LiteralAccordionType = Literal["single", "multiple"]
|
|
19
25
|
LiteralAccordionDir = Literal["ltr", "rtl"]
|
|
20
26
|
LiteralAccordionOrientation = Literal["vertical", "horizontal"]
|
|
27
|
+
LiteralAccordionRootVariant = Literal["classic", "soft", "surface", "outline", "ghost"]
|
|
28
|
+
LiteralAccordionRootColorScheme = Literal["primary", "accent"]
|
|
21
29
|
DEFAULT_ANIMATION_DURATION = 250
|
|
22
30
|
|
|
31
|
+
def get_theme_accordion_root(variant: Var[str], color_scheme: Var[str]) -> BaseVar: ...
|
|
32
|
+
def get_theme_accordion_item(): ...
|
|
33
|
+
def get_theme_accordion_header() -> dict[str, str]: ...
|
|
34
|
+
def get_theme_accordion_trigger(
|
|
35
|
+
variant: str | Var, color_scheme: str | Var
|
|
36
|
+
) -> BaseVar: ...
|
|
37
|
+
def get_theme_accordion_content(
|
|
38
|
+
variant: str | Var, color_scheme: str | Var
|
|
39
|
+
) -> BaseVar: ...
|
|
40
|
+
|
|
23
41
|
class AccordionComponent(RadixPrimitiveComponent):
|
|
24
42
|
@overload
|
|
25
43
|
@classmethod
|
|
@@ -121,6 +139,16 @@ class AccordionRoot(AccordionComponent):
|
|
|
121
139
|
Literal["vertical", "horizontal"],
|
|
122
140
|
]
|
|
123
141
|
] = None,
|
|
142
|
+
variant: Optional[
|
|
143
|
+
Union[
|
|
144
|
+
Var[Literal["classic", "soft", "surface", "outline", "ghost"]],
|
|
145
|
+
Literal["classic", "soft", "surface", "outline", "ghost"],
|
|
146
|
+
]
|
|
147
|
+
] = None,
|
|
148
|
+
color_scheme: Optional[
|
|
149
|
+
Union[Var[Literal["primary", "accent"]], Literal["primary", "accent"]]
|
|
150
|
+
] = None,
|
|
151
|
+
_dynamic_themes: Optional[Union[Var[dict], dict]] = None,
|
|
124
152
|
as_child: Optional[Union[Var[bool], bool]] = None,
|
|
125
153
|
style: Optional[Style] = None,
|
|
126
154
|
key: Optional[Any] = None,
|
|
@@ -173,9 +201,12 @@ class AccordionRoot(AccordionComponent):
|
|
|
173
201
|
on_unmount: Optional[
|
|
174
202
|
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
175
203
|
] = None,
|
|
204
|
+
on_value_change: Optional[
|
|
205
|
+
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
206
|
+
] = None,
|
|
176
207
|
**props
|
|
177
208
|
) -> "AccordionRoot":
|
|
178
|
-
"""Create the component.
|
|
209
|
+
"""Create the Accordion root component.
|
|
179
210
|
|
|
180
211
|
Args:
|
|
181
212
|
*children: The children of the component.
|
|
@@ -186,6 +217,9 @@ class AccordionRoot(AccordionComponent):
|
|
|
186
217
|
disabled: Whether or not the accordion is disabled.
|
|
187
218
|
dir: The reading direction of the accordion when applicable.
|
|
188
219
|
orientation: The orientation of the accordion.
|
|
220
|
+
variant: The variant of the accordion.
|
|
221
|
+
color_scheme: The color scheme of the accordion.
|
|
222
|
+
_dynamic_themes: dynamic themes of the accordion generated at compile time.
|
|
189
223
|
as_child: Change the default rendered element for the one passed as a child.
|
|
190
224
|
style: The style of the component.
|
|
191
225
|
key: A unique key for the component.
|
|
@@ -193,15 +227,13 @@ class AccordionRoot(AccordionComponent):
|
|
|
193
227
|
class_name: The class name for the component.
|
|
194
228
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
195
229
|
custom_attrs: custom attribute
|
|
196
|
-
**props: The
|
|
230
|
+
**props: The properties of the component.
|
|
197
231
|
|
|
198
232
|
Returns:
|
|
199
|
-
The
|
|
200
|
-
|
|
201
|
-
Raises:
|
|
202
|
-
TypeError: If an invalid child is passed.
|
|
233
|
+
The Accordion root Component.
|
|
203
234
|
"""
|
|
204
235
|
...
|
|
236
|
+
def get_event_triggers(self) -> Dict[str, Any]: ...
|
|
205
237
|
|
|
206
238
|
class AccordionItem(AccordionComponent):
|
|
207
239
|
@overload
|
|
@@ -532,5 +564,3 @@ class AccordionContent(AccordionComponent):
|
|
|
532
564
|
...
|
|
533
565
|
|
|
534
566
|
def accordion_item(header: Component, content: Component, **props) -> Component: ...
|
|
535
|
-
|
|
536
|
-
accordion = AccordionRoot.create
|
|
@@ -15,6 +15,10 @@ class RadixPrimitiveComponent(Component):
|
|
|
15
15
|
|
|
16
16
|
lib_dependencies: List[str] = ["@emotion/react@^11.11.1"]
|
|
17
17
|
|
|
18
|
+
|
|
19
|
+
class RadixPrimitiveComponentWithClassName(RadixPrimitiveComponent):
|
|
20
|
+
"""Basic component for radix Primitives with a class name prop."""
|
|
21
|
+
|
|
18
22
|
def _render(self) -> Tag:
|
|
19
23
|
return (
|
|
20
24
|
super()
|