reflex 0.4.9a2__py3-none-any.whl → 0.5.0a1__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/apps/blank/code/blank.py +19 -16
- reflex/.templates/apps/demo/code/pages/datatable.py +4 -4
- reflex/.templates/apps/demo/code/pages/forms.py +2 -2
- reflex/.templates/web/utils/helpers/debounce.js +17 -0
- reflex/.templates/web/utils/helpers/throttle.js +22 -0
- reflex/.templates/web/utils/state.js +21 -3
- reflex/__init__.py +6 -1
- reflex/__init__.pyi +4 -1
- reflex/app.py +157 -140
- reflex/app_module_for_backend.py +1 -1
- reflex/base.py +13 -15
- reflex/compiler/compiler.py +10 -1
- reflex/compiler/utils.py +3 -30
- reflex/components/__init__.py +1 -0
- reflex/components/chakra/datadisplay/list.py +1 -3
- reflex/components/chakra/datadisplay/list.pyi +3 -3
- reflex/components/chakra/disclosure/accordion.py +1 -1
- reflex/components/chakra/forms/pininput.pyi +1 -1
- reflex/components/chakra/media/icon.py +2 -2
- reflex/components/component.py +279 -32
- reflex/components/core/__init__.py +2 -2
- reflex/components/core/cond.py +1 -10
- reflex/components/core/debounce.py +5 -2
- reflex/components/core/debounce.pyi +4 -2
- reflex/components/core/foreach.py +1 -16
- reflex/components/core/html.py +6 -0
- reflex/components/core/match.py +2 -17
- reflex/components/core/upload.py +42 -1
- reflex/components/core/upload.pyi +199 -1
- reflex/components/datadisplay/code.py +7 -3
- reflex/components/datadisplay/code.pyi +3 -1
- reflex/components/el/elements/forms.py +1 -1
- reflex/components/el/elements/forms.pyi +1 -1
- reflex/components/lucide/icon.py +5 -13
- reflex/components/lucide/icon.pyi +0 -1
- reflex/components/markdown/markdown.py +5 -23
- reflex/components/markdown/markdown.pyi +1 -4
- reflex/components/radix/primitives/accordion.py +227 -406
- reflex/components/radix/primitives/accordion.pyi +369 -28
- reflex/components/radix/primitives/form.py +33 -29
- reflex/components/radix/primitives/form.pyi +7 -2
- reflex/components/radix/primitives/progress.py +17 -9
- reflex/components/radix/primitives/progress.pyi +2 -0
- reflex/components/radix/primitives/slider.py +30 -18
- reflex/components/radix/primitives/slider.pyi +4 -0
- reflex/components/radix/themes/base.py +8 -1
- reflex/components/radix/themes/base.pyi +79 -1
- reflex/components/radix/themes/color_mode.py +74 -30
- reflex/components/radix/themes/color_mode.pyi +26 -185
- reflex/components/radix/themes/components/__init__.py +17 -0
- reflex/components/radix/themes/components/badge.py +2 -1
- reflex/components/radix/themes/components/badge.pyi +3 -1
- reflex/components/radix/themes/components/button.py +3 -1
- reflex/components/radix/themes/components/button.pyi +4 -1
- reflex/components/radix/themes/components/checkbox_cards.py +48 -0
- reflex/components/radix/themes/components/checkbox_cards.pyi +264 -0
- reflex/components/radix/themes/components/checkbox_group.py +42 -0
- reflex/components/radix/themes/components/checkbox_group.pyi +253 -0
- reflex/components/radix/themes/components/data_list.py +63 -0
- reflex/components/radix/themes/components/data_list.pyi +426 -0
- reflex/components/radix/themes/components/icon_button.py +20 -17
- reflex/components/radix/themes/components/icon_button.pyi +5 -1
- reflex/components/radix/themes/components/progress.py +55 -0
- reflex/components/radix/themes/components/progress.pyi +180 -0
- reflex/components/radix/themes/components/radio.py +31 -0
- reflex/components/radix/themes/components/radio.pyi +169 -0
- reflex/components/radix/themes/components/radio_cards.py +48 -0
- reflex/components/radix/themes/components/radio_cards.pyi +264 -0
- reflex/components/radix/themes/components/radio_group.py +2 -4
- reflex/components/radix/themes/components/segmented_control.py +48 -0
- reflex/components/radix/themes/components/segmented_control.pyi +262 -0
- reflex/components/radix/themes/components/skeleton.py +32 -0
- reflex/components/radix/themes/components/skeleton.pyi +106 -0
- reflex/components/radix/themes/components/spinner.py +26 -0
- reflex/components/radix/themes/components/spinner.pyi +101 -0
- reflex/components/radix/themes/components/tabs.py +26 -1
- reflex/components/radix/themes/components/tabs.pyi +69 -9
- reflex/components/radix/themes/components/text_field.py +101 -71
- reflex/components/radix/themes/components/text_field.pyi +81 -499
- reflex/components/radix/themes/layout/base.py +2 -2
- reflex/components/radix/themes/layout/base.pyi +4 -4
- reflex/components/radix/themes/layout/center.py +8 -3
- reflex/components/radix/themes/layout/center.pyi +2 -1
- reflex/components/radix/themes/layout/container.py +30 -2
- reflex/components/radix/themes/layout/container.pyi +9 -30
- reflex/components/radix/themes/layout/list.py +10 -5
- reflex/components/radix/themes/layout/list.pyi +5 -21
- reflex/components/radix/themes/layout/spacer.py +8 -3
- reflex/components/radix/themes/layout/spacer.pyi +2 -1
- reflex/components/radix/themes/layout/stack.py +7 -1
- reflex/components/radix/themes/layout/stack.pyi +3 -3
- reflex/components/radix/themes/typography/link.py +10 -2
- reflex/components/radix/themes/typography/link.pyi +5 -4
- reflex/components/sonner/__init__.py +3 -0
- reflex/components/sonner/toast.py +267 -0
- reflex/components/sonner/toast.pyi +205 -0
- reflex/components/tags/iter_tag.py +9 -6
- reflex/config.py +30 -54
- reflex/constants/__init__.py +0 -2
- reflex/constants/base.py +0 -5
- reflex/constants/colors.py +2 -0
- reflex/constants/installer.py +5 -1
- reflex/constants/route.py +4 -0
- reflex/custom_components/custom_components.py +22 -1
- reflex/event.py +75 -30
- reflex/experimental/__init__.py +5 -0
- reflex/experimental/layout.py +24 -6
- reflex/model.py +2 -1
- reflex/page.py +7 -4
- reflex/reflex.py +8 -3
- reflex/route.py +39 -0
- reflex/state.py +128 -131
- reflex/style.py +20 -1
- reflex/testing.py +10 -6
- reflex/utils/console.py +3 -1
- reflex/utils/exec.py +20 -7
- reflex/utils/format.py +1 -1
- reflex/utils/imports.py +3 -1
- reflex/utils/prerequisites.py +141 -20
- reflex/utils/processes.py +21 -1
- reflex/utils/pyi_generator.py +95 -5
- reflex/utils/serializers.py +1 -1
- reflex/utils/telemetry.py +26 -4
- reflex/utils/types.py +62 -18
- reflex/vars.py +11 -5
- {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/METADATA +16 -4
- {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/RECORD +130 -108
- {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/WHEEL +1 -1
- reflex/app.pyi +0 -149
- {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/LICENSE +0 -0
- {reflex-0.4.9a2.dist-info → reflex-0.5.0a1.dist-info}/entry_points.txt +0 -0
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
"""Welcome to Reflex! This file outlines the steps to create a basic app."""
|
|
2
2
|
|
|
3
|
-
from rxconfig import config
|
|
4
|
-
|
|
5
3
|
import reflex as rx
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
filename = f"{config.app_name}/{config.app_name}.py"
|
|
5
|
+
from rxconfig import config
|
|
9
6
|
|
|
10
7
|
|
|
11
8
|
class State(rx.State):
|
|
12
9
|
"""The app state."""
|
|
13
10
|
|
|
11
|
+
...
|
|
12
|
+
|
|
14
13
|
|
|
15
14
|
def index() -> rx.Component:
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
# Welcome Page (Index)
|
|
16
|
+
return rx.container(
|
|
17
|
+
rx.color_mode.button(position="top-right"),
|
|
18
18
|
rx.vstack(
|
|
19
19
|
rx.heading("Welcome to Reflex!", size="9"),
|
|
20
|
-
rx.text(
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
rx.text(
|
|
21
|
+
"Get started by editing ",
|
|
22
|
+
rx.code(f"{config.app_name}/{config.app_name}.py"),
|
|
23
|
+
size="5",
|
|
24
|
+
),
|
|
25
|
+
rx.link(
|
|
26
|
+
rx.button("Check out our docs!"),
|
|
27
|
+
href="https://reflex.dev/docs/getting-started/introduction/",
|
|
28
|
+
is_external=True,
|
|
25
29
|
),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
font_size="2em",
|
|
30
|
+
spacing="5",
|
|
31
|
+
justify="center",
|
|
32
|
+
min_height="85vh",
|
|
30
33
|
),
|
|
31
|
-
|
|
34
|
+
rx.logo(),
|
|
32
35
|
)
|
|
33
36
|
|
|
34
37
|
|
|
@@ -201,10 +201,10 @@ state_show = """class DataTableState(State):
|
|
|
201
201
|
data_show = """[
|
|
202
202
|
["1", "Harry James Potter", "31 July 1980", True, "Gryffindor", "11' Holly phoenix feather", "Stag", "Half-blood"],
|
|
203
203
|
["2", "Ronald Bilius Weasley", "1 March 1980", True,"Gryffindor", "12' Ash unicorn tail hair", "Jack Russell terrier", "Pure-blood"],
|
|
204
|
-
["3", "Hermione Jean Granger", "19 September, 1979", True, "Gryffindor", "10¾' vine wood dragon heartstring", "Otter", "Muggle-born"],
|
|
205
|
-
["4", "Albus Percival Wulfric Brian Dumbledore", "Late August 1881", True, "Gryffindor", "15' Elder Thestral tail hair core", "Phoenix", "Half-blood"],
|
|
206
|
-
["5", "Rubeus Hagrid", "6 December 1928", False, "Gryffindor", "16' Oak unknown core", "None", "Part-Human (Half-giant)"],
|
|
207
|
-
["6", "Fred Weasley", "1 April, 1978", True, "Gryffindor", "Unknown", "Unknown", "Pure-blood"],
|
|
204
|
+
["3", "Hermione Jean Granger", "19 September, 1979", True, "Gryffindor", "10¾' vine wood dragon heartstring", "Otter", "Muggle-born"],
|
|
205
|
+
["4", "Albus Percival Wulfric Brian Dumbledore", "Late August 1881", True, "Gryffindor", "15' Elder Thestral tail hair core", "Phoenix", "Half-blood"],
|
|
206
|
+
["5", "Rubeus Hagrid", "6 December 1928", False, "Gryffindor", "16' Oak unknown core", "None", "Part-Human (Half-giant)"],
|
|
207
|
+
["6", "Fred Weasley", "1 April, 1978", True, "Gryffindor", "Unknown", "Unknown", "Pure-blood"],
|
|
208
208
|
["7", "George Weasley", "1 April, 1978", True, "Gryffindor", "Unknown", "Unknown", "Pure-blood"],
|
|
209
209
|
]"""
|
|
210
210
|
|
|
@@ -18,8 +18,8 @@ forms_1_code = """rx.chakra.vstack(
|
|
|
18
18
|
rx.chakra.checkbox("Checked", id="check"),
|
|
19
19
|
rx.chakra.switch("Switched", id="switch"),
|
|
20
20
|
),
|
|
21
|
-
rx.chakra.button("Submit",
|
|
22
|
-
type_="submit",
|
|
21
|
+
rx.chakra.button("Submit",
|
|
22
|
+
type_="submit",
|
|
23
23
|
bg="#ecfdf5",
|
|
24
24
|
color="#047857",
|
|
25
25
|
border_radius="lg",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const debounce_timeout_id = {};
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generic debounce helper
|
|
5
|
+
*
|
|
6
|
+
* @param {string} name - the name of the event to debounce
|
|
7
|
+
* @param {function} func - the function to call after debouncing
|
|
8
|
+
* @param {number} delay - the time in milliseconds to wait before calling the function
|
|
9
|
+
*/
|
|
10
|
+
export default function debounce(name, func, delay) {
|
|
11
|
+
const key = `${name}__${delay}`;
|
|
12
|
+
clearTimeout(debounce_timeout_id[key]);
|
|
13
|
+
debounce_timeout_id[key] = setTimeout(() => {
|
|
14
|
+
func();
|
|
15
|
+
delete debounce_timeout_id[key];
|
|
16
|
+
}, delay);
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const in_throttle = {};
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generic throttle helper
|
|
5
|
+
*
|
|
6
|
+
* @param {string} name - the name of the event to throttle
|
|
7
|
+
* @param {number} limit - time in milliseconds between events
|
|
8
|
+
* @returns true if the event is allowed to execute, false if it is throttled
|
|
9
|
+
*/
|
|
10
|
+
export default function throttle(name, limit) {
|
|
11
|
+
const key = `${name}__${limit}`;
|
|
12
|
+
if (!in_throttle[key]) {
|
|
13
|
+
in_throttle[key] = true;
|
|
14
|
+
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
delete in_throttle[key];
|
|
17
|
+
}, limit);
|
|
18
|
+
// function was not throttled, so allow execution
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
onLoadInternalEvent,
|
|
13
13
|
state_name,
|
|
14
14
|
} from "utils/context.js";
|
|
15
|
+
import debounce from "/utils/helpers/debounce";
|
|
16
|
+
import throttle from "/utils/helpers/throttle";
|
|
15
17
|
|
|
16
18
|
// Endpoint URLs.
|
|
17
19
|
const EVENTURL = env.EVENT;
|
|
@@ -571,7 +573,23 @@ export const useEventLoop = (
|
|
|
571
573
|
if (event_actions?.stopPropagation && _e?.stopPropagation) {
|
|
572
574
|
_e.stopPropagation();
|
|
573
575
|
}
|
|
574
|
-
|
|
576
|
+
const combined_name = events.map((e) => e.name).join("+++");
|
|
577
|
+
if (event_actions?.throttle) {
|
|
578
|
+
// If throttle returns false, the events are not added to the queue.
|
|
579
|
+
if (!throttle(combined_name, event_actions.throttle)) {
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
if (event_actions?.debounce) {
|
|
584
|
+
// If debounce is used, queue the events after some delay
|
|
585
|
+
debounce(
|
|
586
|
+
combined_name,
|
|
587
|
+
() => queueEvents(events, socket),
|
|
588
|
+
event_actions.debounce,
|
|
589
|
+
);
|
|
590
|
+
} else {
|
|
591
|
+
queueEvents(events, socket);
|
|
592
|
+
}
|
|
575
593
|
};
|
|
576
594
|
|
|
577
595
|
const sentHydrate = useRef(false); // Avoid double-hydrate due to React strict-mode
|
|
@@ -691,8 +709,8 @@ export const getRefValue = (ref) => {
|
|
|
691
709
|
if (ref.current.type == "checkbox") {
|
|
692
710
|
return ref.current.checked; // chakra
|
|
693
711
|
} else if (
|
|
694
|
-
ref.current.className?.includes("rt-
|
|
695
|
-
ref.current.className?.includes("rt-
|
|
712
|
+
ref.current.className?.includes("rt-CheckboxRoot") ||
|
|
713
|
+
ref.current.className?.includes("rt-SwitchRoot")
|
|
696
714
|
) {
|
|
697
715
|
return ref.current.ariaChecked == "true"; // radix
|
|
698
716
|
} else if (ref.current.className?.includes("rt-SliderRoot")) {
|
reflex/__init__.py
CHANGED
|
@@ -59,6 +59,7 @@ _ALL_COMPONENTS = [
|
|
|
59
59
|
"code",
|
|
60
60
|
"container",
|
|
61
61
|
"context_menu",
|
|
62
|
+
"data_list",
|
|
62
63
|
"dialog",
|
|
63
64
|
"divider",
|
|
64
65
|
"drawer",
|
|
@@ -79,8 +80,10 @@ _ALL_COMPONENTS = [
|
|
|
79
80
|
"scroll_area",
|
|
80
81
|
"section",
|
|
81
82
|
"select",
|
|
83
|
+
"skeleton",
|
|
82
84
|
"slider",
|
|
83
85
|
"spacer",
|
|
86
|
+
"spinner",
|
|
84
87
|
"stack",
|
|
85
88
|
"switch",
|
|
86
89
|
"table",
|
|
@@ -110,6 +113,8 @@ _ALL_COMPONENTS = [
|
|
|
110
113
|
"ordered_list",
|
|
111
114
|
"moment",
|
|
112
115
|
"logo",
|
|
116
|
+
# Toast is in experimental namespace initially
|
|
117
|
+
# "toast",
|
|
113
118
|
]
|
|
114
119
|
|
|
115
120
|
_MAPPING = {
|
|
@@ -118,7 +123,6 @@ _MAPPING = {
|
|
|
118
123
|
"reflex.app": ["app", "App", "UploadFile"],
|
|
119
124
|
"reflex.base": ["base", "Base"],
|
|
120
125
|
"reflex.compiler": ["compiler"],
|
|
121
|
-
"reflex.compiler.utils": ["get_asset_path"],
|
|
122
126
|
"reflex.components": _ALL_COMPONENTS,
|
|
123
127
|
"reflex.components.component": ["Component", "NoSSRComponent", "memo"],
|
|
124
128
|
"reflex.components.chakra": ["chakra"],
|
|
@@ -166,6 +170,7 @@ _MAPPING = {
|
|
|
166
170
|
"reflex.style": ["style", "toggle_color_mode"],
|
|
167
171
|
"reflex.testing": ["testing"],
|
|
168
172
|
"reflex.utils": ["utils"],
|
|
173
|
+
"reflex.utils.imports": ["ImportVar"],
|
|
169
174
|
"reflex.vars": ["vars", "cached_var", "Var"],
|
|
170
175
|
}
|
|
171
176
|
|
reflex/__init__.pyi
CHANGED
|
@@ -7,7 +7,6 @@ from reflex.app import UploadFile as UploadFile
|
|
|
7
7
|
from reflex import base as base
|
|
8
8
|
from reflex.base import Base as Base
|
|
9
9
|
from reflex import compiler as compiler
|
|
10
|
-
from reflex.compiler.utils import get_asset_path as get_asset_path
|
|
11
10
|
from reflex.components import color as color
|
|
12
11
|
from reflex.components import cond as cond
|
|
13
12
|
from reflex.components import foreach as foreach
|
|
@@ -47,6 +46,7 @@ from reflex.components import checkbox as checkbox
|
|
|
47
46
|
from reflex.components import code as code
|
|
48
47
|
from reflex.components import container as container
|
|
49
48
|
from reflex.components import context_menu as context_menu
|
|
49
|
+
from reflex.components import data_list as data_list
|
|
50
50
|
from reflex.components import dialog as dialog
|
|
51
51
|
from reflex.components import divider as divider
|
|
52
52
|
from reflex.components import drawer as drawer
|
|
@@ -67,8 +67,10 @@ from reflex.components import radio as radio
|
|
|
67
67
|
from reflex.components import scroll_area as scroll_area
|
|
68
68
|
from reflex.components import section as section
|
|
69
69
|
from reflex.components import select as select
|
|
70
|
+
from reflex.components import skeleton as skeleton
|
|
70
71
|
from reflex.components import slider as slider
|
|
71
72
|
from reflex.components import spacer as spacer
|
|
73
|
+
from reflex.components import spinner as spinner
|
|
72
74
|
from reflex.components import stack as stack
|
|
73
75
|
from reflex.components import switch as switch
|
|
74
76
|
from reflex.components import table as table
|
|
@@ -149,6 +151,7 @@ from reflex import style as style
|
|
|
149
151
|
from reflex.style import toggle_color_mode as toggle_color_mode
|
|
150
152
|
from reflex import testing as testing
|
|
151
153
|
from reflex import utils as utils
|
|
154
|
+
from reflex.utils.imports import ImportVar as ImportVar
|
|
152
155
|
from reflex import vars as vars
|
|
153
156
|
from reflex.vars import cached_var as cached_var
|
|
154
157
|
from reflex.vars import Var as Var
|