-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathevent.py
More file actions
105 lines (85 loc) · 2.91 KB
/
Copy pathevent.py
File metadata and controls
105 lines (85 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""Event-related constants."""
from enum import Enum
from types import SimpleNamespace
# The name of the setvar event handler.
SETVAR = "setvar"
class Endpoint(Enum):
"""Endpoints for the reflex backend API."""
PING = "ping"
EVENT = "_event"
UPLOAD = "_upload"
AUTH_CODESPACE = "auth-codespace"
HEALTH = "_health"
ALL_ROUTES = "_all_routes"
def __str__(self) -> str:
"""Get the string representation of the endpoint.
Returns:
The path for the endpoint.
"""
return f"/{self.value}"
def get_url(self) -> str:
"""Get the URL for the endpoint.
Returns:
The full URL for the endpoint.
"""
# Import here to avoid circular imports.
from reflex_base.config import get_config
# Get the API URL from the config.
config = get_config()
url = "".join([config.api_url, config.prepend_backend_path(str(self))])
# The event endpoint is a websocket.
if self == Endpoint.EVENT:
# Replace the protocol with ws.
url = url.replace("https://", "wss://").replace("http://", "ws://")
# Return the url.
return url
class SocketEvent(SimpleNamespace):
"""Socket events sent by the reflex backend API."""
PING = "ping"
EVENT = "event"
def __str__(self) -> str:
"""Get the string representation of the event name.
Returns:
The event name string.
"""
return str(self.value)
class EventTriggers(SimpleNamespace):
"""All trigger names used in Reflex."""
ON_FOCUS = "on_focus"
ON_BLUR = "on_blur"
ON_CANCEL = "on_cancel"
ON_CLICK = "on_click"
ON_CHANGE = "on_change"
ON_CHANGE_END = "on_change_end"
ON_CHANGE_START = "on_change_start"
ON_COMPLETE = "on_complete"
ON_CONTEXT_MENU = "on_context_menu"
ON_DOUBLE_CLICK = "on_double_click"
ON_DROP = "on_drop"
ON_EDIT = "on_edit"
ON_KEY_DOWN = "on_key_down"
ON_KEY_UP = "on_key_up"
ON_MOUSE_DOWN = "on_mouse_down"
ON_MOUSE_ENTER = "on_mouse_enter"
ON_MOUSE_LEAVE = "on_mouse_leave"
ON_MOUSE_MOVE = "on_mouse_move"
ON_MOUSE_OUT = "on_mouse_out"
ON_MOUSE_OVER = "on_mouse_over"
ON_MOUSE_UP = "on_mouse_up"
ON_OPEN_CHANGE = "on_open_change"
ON_OPEN_AUTO_FOCUS = "on_open_auto_focus"
ON_CLOSE_AUTO_FOCUS = "on_close_auto_focus"
ON_FOCUS_OUTSIDE = "on_focus_outside"
ON_ESCAPE_KEY_DOWN = "on_escape_key_down"
ON_POINTER_DOWN_OUTSIDE = "on_pointer_down_outside"
ON_INTERACT_OUTSIDE = "on_interact_outside"
ON_SCROLL = "on_scroll"
ON_SCROLL_END = "on_scroll_end"
ON_SUBMIT = "on_submit"
ON_MOUNT = "on_mount"
ON_UNMOUNT = "on_unmount"
ON_CLEAR_SERVER_ERRORS = "on_clear_server_errors"
ON_VALUE_COMMIT = "on_value_commit"
ON_SELECT = "on_select"
ON_ANIMATION_START = "on_animation_start"
ON_ANIMATION_END = "on_animation_end"