reflex 0.5.9.dev1__py3-none-any.whl → 0.5.10__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/web/utils/client_side_routing.js +6 -1
- reflex/__init__.py +21 -2
- reflex/__init__.pyi +0 -1
- reflex/app.py +1 -1
- reflex/components/__init__.py +0 -1
- reflex/components/__init__.pyi +0 -1
- reflex/components/markdown/markdown.py +1 -1
- reflex/components/recharts/cartesian.py +3 -0
- reflex/components/recharts/cartesian.pyi +2 -0
- reflex/components/sonner/toast.py +27 -1
- reflex/components/sonner/toast.pyi +5 -0
- reflex/constants/base.py +2 -0
- reflex/constants/installer.py +2 -0
- reflex/experimental/hooks.py +1 -1
- reflex/reflex.py +0 -15
- reflex/state.py +22 -22
- reflex/testing.py +8 -3
- reflex/utils/net.py +43 -0
- reflex/utils/prerequisites.py +27 -126
- reflex/utils/registry.py +48 -0
- reflex/utils/types.py +1 -1
- reflex/vars.py +4 -2
- {reflex-0.5.9.dev1.dist-info → reflex-0.5.10.dist-info}/METADATA +2 -1
- {reflex-0.5.9.dev1.dist-info → reflex-0.5.10.dist-info}/RECORD +27 -168
- reflex/components/chakra/__init__.py +0 -204
- reflex/components/chakra/base.py +0 -210
- reflex/components/chakra/base.pyi +0 -319
- reflex/components/chakra/datadisplay/__init__.py +0 -10
- reflex/components/chakra/datadisplay/badge.py +0 -16
- reflex/components/chakra/datadisplay/badge.pyi +0 -96
- reflex/components/chakra/datadisplay/code.py +0 -11
- reflex/components/chakra/datadisplay/code.pyi +0 -87
- reflex/components/chakra/datadisplay/divider.py +0 -20
- reflex/components/chakra/datadisplay/divider.pyi +0 -100
- reflex/components/chakra/datadisplay/keyboard_key.py +0 -9
- reflex/components/chakra/datadisplay/keyboard_key.pyi +0 -87
- reflex/components/chakra/datadisplay/list.py +0 -60
- reflex/components/chakra/datadisplay/list.pyi +0 -339
- reflex/components/chakra/datadisplay/stat.py +0 -80
- reflex/components/chakra/datadisplay/stat.pyi +0 -477
- reflex/components/chakra/datadisplay/table.py +0 -305
- reflex/components/chakra/datadisplay/table.pyi +0 -737
- reflex/components/chakra/datadisplay/tag.py +0 -85
- reflex/components/chakra/datadisplay/tag.pyi +0 -433
- reflex/components/chakra/disclosure/__init__.py +0 -14
- reflex/components/chakra/disclosure/accordion.py +0 -110
- reflex/components/chakra/disclosure/accordion.pyi +0 -411
- reflex/components/chakra/disclosure/tabs.py +0 -117
- reflex/components/chakra/disclosure/tabs.pyi +0 -496
- reflex/components/chakra/disclosure/transition.py +0 -73
- reflex/components/chakra/disclosure/transition.pyi +0 -509
- reflex/components/chakra/disclosure/visuallyhidden.py +0 -9
- reflex/components/chakra/disclosure/visuallyhidden.pyi +0 -87
- reflex/components/chakra/feedback/__init__.py +0 -7
- reflex/components/chakra/feedback/alert.py +0 -68
- reflex/components/chakra/feedback/alert.pyi +0 -335
- reflex/components/chakra/feedback/circularprogress.py +0 -68
- reflex/components/chakra/feedback/circularprogress.pyi +0 -185
- reflex/components/chakra/feedback/progress.py +0 -33
- reflex/components/chakra/feedback/progress.pyi +0 -101
- reflex/components/chakra/feedback/skeleton.py +0 -70
- reflex/components/chakra/feedback/skeleton.pyi +0 -271
- reflex/components/chakra/feedback/spinner.py +0 -25
- reflex/components/chakra/feedback/spinner.pyi +0 -102
- reflex/components/chakra/forms/__init__.py +0 -49
- reflex/components/chakra/forms/button.py +0 -83
- reflex/components/chakra/forms/button.pyi +0 -262
- reflex/components/chakra/forms/checkbox.py +0 -77
- reflex/components/chakra/forms/checkbox.pyi +0 -247
- reflex/components/chakra/forms/colormodeswitch.py +0 -104
- reflex/components/chakra/forms/colormodeswitch.pyi +0 -473
- reflex/components/chakra/forms/date_picker.py +0 -11
- reflex/components/chakra/forms/date_picker.pyi +0 -129
- reflex/components/chakra/forms/date_time_picker.py +0 -11
- reflex/components/chakra/forms/date_time_picker.pyi +0 -129
- reflex/components/chakra/forms/editable.py +0 -67
- reflex/components/chakra/forms/editable.pyi +0 -343
- reflex/components/chakra/forms/email.py +0 -11
- reflex/components/chakra/forms/email.pyi +0 -129
- reflex/components/chakra/forms/form.py +0 -103
- reflex/components/chakra/forms/form.pyi +0 -484
- reflex/components/chakra/forms/iconbutton.py +0 -38
- reflex/components/chakra/forms/iconbutton.pyi +0 -108
- reflex/components/chakra/forms/input.py +0 -130
- reflex/components/chakra/forms/input.pyi +0 -566
- reflex/components/chakra/forms/multiselect.py +0 -355
- reflex/components/chakra/forms/numberinput.py +0 -128
- reflex/components/chakra/forms/numberinput.pyi +0 -442
- reflex/components/chakra/forms/password.py +0 -11
- reflex/components/chakra/forms/password.pyi +0 -129
- reflex/components/chakra/forms/pininput.py +0 -201
- reflex/components/chakra/forms/pininput.pyi +0 -215
- reflex/components/chakra/forms/radio.py +0 -101
- reflex/components/chakra/forms/radio.pyi +0 -197
- reflex/components/chakra/forms/rangeslider.py +0 -149
- reflex/components/chakra/forms/rangeslider.pyi +0 -354
- reflex/components/chakra/forms/select.py +0 -103
- reflex/components/chakra/forms/select.pyi +0 -204
- reflex/components/chakra/forms/slider.py +0 -130
- reflex/components/chakra/forms/slider.pyi +0 -449
- reflex/components/chakra/forms/switch.py +0 -49
- reflex/components/chakra/forms/switch.pyi +0 -159
- reflex/components/chakra/forms/textarea.py +0 -79
- reflex/components/chakra/forms/textarea.pyi +0 -123
- reflex/components/chakra/forms/time_picker.py +0 -11
- reflex/components/chakra/forms/time_picker.pyi +0 -129
- reflex/components/chakra/layout/__init__.py +0 -14
- reflex/components/chakra/layout/aspect_ratio.py +0 -13
- reflex/components/chakra/layout/aspect_ratio.pyi +0 -89
- reflex/components/chakra/layout/box.py +0 -31
- reflex/components/chakra/layout/box.pyi +0 -93
- reflex/components/chakra/layout/card.py +0 -100
- reflex/components/chakra/layout/card.pyi +0 -379
- reflex/components/chakra/layout/center.py +0 -21
- reflex/components/chakra/layout/center.pyi +0 -239
- reflex/components/chakra/layout/container.py +0 -13
- reflex/components/chakra/layout/container.pyi +0 -89
- reflex/components/chakra/layout/flex.py +0 -33
- reflex/components/chakra/layout/flex.pyi +0 -101
- reflex/components/chakra/layout/grid.py +0 -125
- reflex/components/chakra/layout/grid.pyi +0 -293
- reflex/components/chakra/layout/spacer.py +0 -9
- reflex/components/chakra/layout/spacer.pyi +0 -87
- reflex/components/chakra/layout/stack.py +0 -48
- reflex/components/chakra/layout/stack.pyi +0 -305
- reflex/components/chakra/layout/wrap.py +0 -57
- reflex/components/chakra/layout/wrap.pyi +0 -179
- reflex/components/chakra/media/__init__.py +0 -7
- reflex/components/chakra/media/avatar.py +0 -58
- reflex/components/chakra/media/avatar.pyi +0 -267
- reflex/components/chakra/media/icon.py +0 -111
- reflex/components/chakra/media/icon.pyi +0 -171
- reflex/components/chakra/media/image.py +0 -74
- reflex/components/chakra/media/image.pyi +0 -118
- reflex/components/chakra/navigation/__init__.py +0 -18
- reflex/components/chakra/navigation/breadcrumb.py +0 -98
- reflex/components/chakra/navigation/breadcrumb.pyi +0 -351
- reflex/components/chakra/navigation/link.py +0 -62
- reflex/components/chakra/navigation/link.pyi +0 -105
- reflex/components/chakra/navigation/linkoverlay.py +0 -22
- reflex/components/chakra/navigation/linkoverlay.pyi +0 -167
- reflex/components/chakra/navigation/stepper.py +0 -113
- reflex/components/chakra/navigation/stepper.pyi +0 -762
- reflex/components/chakra/overlay/__init__.py +0 -50
- reflex/components/chakra/overlay/alertdialog.py +0 -153
- reflex/components/chakra/overlay/alertdialog.pyi +0 -612
- reflex/components/chakra/overlay/drawer.py +0 -168
- reflex/components/chakra/overlay/drawer.pyi +0 -652
- reflex/components/chakra/overlay/menu.py +0 -225
- reflex/components/chakra/overlay/menu.pyi +0 -708
- reflex/components/chakra/overlay/modal.py +0 -166
- reflex/components/chakra/overlay/modal.pyi +0 -600
- reflex/components/chakra/overlay/popover.py +0 -183
- reflex/components/chakra/overlay/popover.pyi +0 -757
- reflex/components/chakra/overlay/tooltip.py +0 -70
- reflex/components/chakra/overlay/tooltip.pyi +0 -129
- reflex/components/chakra/typography/__init__.py +0 -10
- reflex/components/chakra/typography/heading.py +0 -16
- reflex/components/chakra/typography/heading.pyi +0 -96
- reflex/components/chakra/typography/highlight.py +0 -23
- reflex/components/chakra/typography/highlight.pyi +0 -91
- reflex/components/chakra/typography/span.py +0 -15
- reflex/components/chakra/typography/span.pyi +0 -89
- reflex/components/chakra/typography/text.py +0 -18
- reflex/components/chakra/typography/text.pyi +0 -91
- reflex/components/media/__init__.py +0 -1
- reflex/components/media/icon.py +0 -3
- {reflex-0.5.9.dev1.dist-info → reflex-0.5.10.dist-info}/LICENSE +0 -0
- {reflex-0.5.9.dev1.dist-info → reflex-0.5.10.dist-info}/WHEEL +0 -0
- {reflex-0.5.9.dev1.dist-info → reflex-0.5.10.dist-info}/entry_points.txt +0 -0
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
"""Provides a feature-rich Select and some (not all) related components."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
from typing import Any, Dict, List, Optional, Set, Union
|
|
6
|
-
|
|
7
|
-
from reflex.base import Base
|
|
8
|
-
from reflex.components.component import Component
|
|
9
|
-
from reflex.constants import EventTriggers
|
|
10
|
-
from reflex.vars import Var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class Option(Base):
|
|
14
|
-
"""An option component for the chakra-react-select Select."""
|
|
15
|
-
|
|
16
|
-
# What is displayed to the user
|
|
17
|
-
label: str
|
|
18
|
-
|
|
19
|
-
# The value of the option, must be serializable
|
|
20
|
-
value: Any
|
|
21
|
-
|
|
22
|
-
# the variant of the option tag
|
|
23
|
-
variant: Optional[str] = None
|
|
24
|
-
|
|
25
|
-
# [not working yet]
|
|
26
|
-
# Whether the option is disabled
|
|
27
|
-
# is_disabled: Optional[bool] = None
|
|
28
|
-
|
|
29
|
-
# [not working yet]
|
|
30
|
-
# The visual color appearance of the component
|
|
31
|
-
# options: "whiteAlpha" | "blackAlpha" | "gray" | "red" |
|
|
32
|
-
# "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" |
|
|
33
|
-
# "purple" | "pink" | "linkedin" | "facebook" | "messenger" |
|
|
34
|
-
# "whatsapp" | "twitter" | "telegram"
|
|
35
|
-
# default: "gray"
|
|
36
|
-
# color_scheme: Optional[str] = None
|
|
37
|
-
|
|
38
|
-
# [not working yet]
|
|
39
|
-
# The icon of the option tag
|
|
40
|
-
# icon: Optional[str] = None
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class Select(Component):
|
|
44
|
-
"""The default chakra-react-select Select component.
|
|
45
|
-
Not every available prop is listed here,
|
|
46
|
-
for a complete overview check the react-select/chakra-react-select docs.
|
|
47
|
-
Props added by chakra-react-select are marked with "[chakra]".
|
|
48
|
-
"""
|
|
49
|
-
|
|
50
|
-
library = "chakra-react-select@4.7.5"
|
|
51
|
-
tag = "Select"
|
|
52
|
-
alias = "MultiSelect"
|
|
53
|
-
|
|
54
|
-
# Focus the control when it is mounted
|
|
55
|
-
auto_focus: Var[bool]
|
|
56
|
-
|
|
57
|
-
# Remove the currently focused option when the user presses backspace
|
|
58
|
-
# when Select isClearable or isMulti
|
|
59
|
-
backspace_removes_value: Var[bool]
|
|
60
|
-
|
|
61
|
-
# Remove focus from the input when the user selects an option
|
|
62
|
-
# (handy for dismissing the keyboard on touch devices)
|
|
63
|
-
blur_input_on_select: Var[bool]
|
|
64
|
-
|
|
65
|
-
# When the user reaches the top/bottom of the menu,
|
|
66
|
-
# prevent scroll on the scroll-parent
|
|
67
|
-
capture_menu_scroll: Var[bool]
|
|
68
|
-
|
|
69
|
-
# [chakra]
|
|
70
|
-
# To use the chakraStyles prop, first,
|
|
71
|
-
# check the documentation for the original styles prop from the react-select docs.
|
|
72
|
-
# This package offers an identical API for the chakraStyles prop, however,
|
|
73
|
-
# the provided and output style objects use Chakra's sx prop
|
|
74
|
-
# instead of the default emotion styles the original package offers.
|
|
75
|
-
# This allows you to both use the shorthand styling props you'd normally use
|
|
76
|
-
# to style Chakra components, as well as tokens from your theme such as named colors.
|
|
77
|
-
# All of the style keys offered in the original package can be used in the chakraStyles prop
|
|
78
|
-
# except for menuPortal. Along with some other caveats, this is explained below.
|
|
79
|
-
# Most of the components rendered by this package use the basic Chakra <Box /> component with a few exceptions.
|
|
80
|
-
# Here are the style keys offered and the corresponding Chakra component that is rendered:
|
|
81
|
-
# - clearIndicator - Box (uses theme styles for Chakra's CloseButton)
|
|
82
|
-
# - container - Box
|
|
83
|
-
# - control - Box (uses theme styles for Chakra's Input)
|
|
84
|
-
# - dropdownIndicator - Box (uses theme styles for Chrakra's InputRightAddon)
|
|
85
|
-
# - downChevron - Icon
|
|
86
|
-
# - crossIcon - Icon
|
|
87
|
-
# - group - Box
|
|
88
|
-
# - groupHeading - Box (uses theme styles for Chakra's Menu group title)
|
|
89
|
-
# - indicatorsContainer - Box
|
|
90
|
-
# - indicatorSeparator - Divider
|
|
91
|
-
# - input - chakra.input (wrapped in a Box)
|
|
92
|
-
# - inputContainer - Box
|
|
93
|
-
# - loadingIndicator - Spinner
|
|
94
|
-
# - loadingMessage - Box
|
|
95
|
-
# - menu - Box
|
|
96
|
-
# - menuList - Box (uses theme styles for Chakra's Menu)
|
|
97
|
-
# - multiValue - chakra.span (uses theme styles for Chakra's Tag)
|
|
98
|
-
# - multiValueLabel - chakra.span (uses theme styles for Chakra's TagLabel)
|
|
99
|
-
# - multiValueRemove - Box (uses theme styles for Chakra's TagCloseButton)
|
|
100
|
-
# - noOptionsMessage - Box
|
|
101
|
-
# - option - Box (uses theme styles for Chakra's MenuItem)
|
|
102
|
-
# - placeholder - Box
|
|
103
|
-
# - singleValue - Box
|
|
104
|
-
# - valueContainer - Box
|
|
105
|
-
chakra_styles: Var[str]
|
|
106
|
-
|
|
107
|
-
# Close the select menu when the user selects an option
|
|
108
|
-
close_menu_on_select: Var[bool]
|
|
109
|
-
|
|
110
|
-
# If true, close the select menu when the user scrolls the document/body.
|
|
111
|
-
close_menu_on_scroll: Var[bool]
|
|
112
|
-
|
|
113
|
-
# [chakra]
|
|
114
|
-
# The visual color appearance of the component
|
|
115
|
-
# options: "whiteAlpha" | "blackAlpha" | "gray" | "red" |
|
|
116
|
-
# "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" |
|
|
117
|
-
# "purple" | "pink" | "linkedin" | "facebook" | "messenger" |
|
|
118
|
-
# "whatsapp" | "twitter" | "telegram"
|
|
119
|
-
# default: "gray"
|
|
120
|
-
color_scheme: Var[str]
|
|
121
|
-
|
|
122
|
-
# This complex object includes all the compositional components
|
|
123
|
-
# that are used in react-select. If you wish to overwrite a component,
|
|
124
|
-
# pass in an object with the appropriate namespace.
|
|
125
|
-
# If you only wish to restyle a component,
|
|
126
|
-
# we recommend using the styles prop instead.
|
|
127
|
-
components: Var[Dict[str, Component]]
|
|
128
|
-
|
|
129
|
-
# Whether the value of the select, e.g. SingleValue,
|
|
130
|
-
# should be displayed in the control.
|
|
131
|
-
control_should_render_value: Var[bool]
|
|
132
|
-
|
|
133
|
-
# Delimiter used to join multiple values into a single HTML Input value
|
|
134
|
-
delimiter: Var[str]
|
|
135
|
-
|
|
136
|
-
# [chakra]
|
|
137
|
-
# Colors the component border with the given chakra color string on error state
|
|
138
|
-
# default: "red.500"
|
|
139
|
-
error_border_color: Var[str]
|
|
140
|
-
|
|
141
|
-
# Clear all values when the user presses escape AND the menu is closed
|
|
142
|
-
escape_clears_value: Var[bool]
|
|
143
|
-
|
|
144
|
-
# [chakra]
|
|
145
|
-
# Colors the component border with the given chakra color string on focus
|
|
146
|
-
# default: "blue.500"
|
|
147
|
-
focus_border_color: Var[str]
|
|
148
|
-
|
|
149
|
-
# Sets the form attribute on the input
|
|
150
|
-
form: Var[str]
|
|
151
|
-
|
|
152
|
-
# Hide the selected option from the menu
|
|
153
|
-
hide_selected_options: Var[bool]
|
|
154
|
-
|
|
155
|
-
# The id to set on the SelectContainer component.
|
|
156
|
-
# id: Var[str]
|
|
157
|
-
|
|
158
|
-
# The value of the search input
|
|
159
|
-
input_value: Var[str]
|
|
160
|
-
|
|
161
|
-
# The id of the search input
|
|
162
|
-
input_id: Var[str]
|
|
163
|
-
|
|
164
|
-
# Is the select value clearable
|
|
165
|
-
is_clearable: Var[bool]
|
|
166
|
-
|
|
167
|
-
# Is the select disabled
|
|
168
|
-
is_disabled: Var[bool]
|
|
169
|
-
|
|
170
|
-
# [chakra]
|
|
171
|
-
# Style component in the chakra invalid style
|
|
172
|
-
# default: False
|
|
173
|
-
is_invalid: Var[bool]
|
|
174
|
-
|
|
175
|
-
# Support multiple selected options
|
|
176
|
-
is_multi: Var[bool]
|
|
177
|
-
|
|
178
|
-
# [chakra]
|
|
179
|
-
# Style component as disabled (chakra style)
|
|
180
|
-
# default: False
|
|
181
|
-
is_read_only: Var[bool]
|
|
182
|
-
|
|
183
|
-
# Is the select direction right-to-left
|
|
184
|
-
is_rtl: Var[bool]
|
|
185
|
-
|
|
186
|
-
# Whether to enable search functionality
|
|
187
|
-
is_searchable: Var[bool]
|
|
188
|
-
|
|
189
|
-
# Minimum height of the menu before flipping
|
|
190
|
-
min_menu_height: Var[int]
|
|
191
|
-
|
|
192
|
-
# Maximum height of the menu before scrolling
|
|
193
|
-
max_menu_height: Var[int]
|
|
194
|
-
|
|
195
|
-
# Default placement of the menu in relation to the control.
|
|
196
|
-
# 'auto' will flip when there isn't enough space below the control.
|
|
197
|
-
# options: "bottom" | "auto" | "top"
|
|
198
|
-
menu_placement: Var[str]
|
|
199
|
-
|
|
200
|
-
# The CSS position value of the menu,
|
|
201
|
-
# when "fixed" extra layout management is required
|
|
202
|
-
# options: "absolute" | "fixed"
|
|
203
|
-
menu_position: Var[str]
|
|
204
|
-
|
|
205
|
-
# Whether to block scroll events when the menu is open
|
|
206
|
-
menu_should_block_scroll: Var[bool]
|
|
207
|
-
|
|
208
|
-
# Whether the menu should be scrolled into view when it opens
|
|
209
|
-
menu_should_scroll_into_view: Var[bool]
|
|
210
|
-
|
|
211
|
-
# Name of the HTML Input (optional - without this, no input will be rendered)
|
|
212
|
-
name: Var[str]
|
|
213
|
-
|
|
214
|
-
# Allows control of whether the menu is opened when the Select is focused
|
|
215
|
-
open_menu_on_focus: Var[bool]
|
|
216
|
-
|
|
217
|
-
# Allows control of whether the menu is opened when the Select is clicked
|
|
218
|
-
open_menu_on_click: Var[bool]
|
|
219
|
-
|
|
220
|
-
# Array of options that populate the select menu
|
|
221
|
-
options: Var[List[Dict]]
|
|
222
|
-
|
|
223
|
-
# Number of options to jump in menu when page{up|down} keys are used
|
|
224
|
-
page_size: Var[int]
|
|
225
|
-
|
|
226
|
-
# Placeholder for the select value
|
|
227
|
-
placeholder: Var[Optional[str]]
|
|
228
|
-
|
|
229
|
-
# Marks the value-holding input as required for form validation
|
|
230
|
-
required: Var[bool]
|
|
231
|
-
|
|
232
|
-
# [chakra]
|
|
233
|
-
# If you choose to stick with the default selectedOptionStyle="color",
|
|
234
|
-
# you have one additional styling option.
|
|
235
|
-
# If you do not like the default of blue for the highlight color,
|
|
236
|
-
# you can pass the selectedOptionColorScheme prop to change it.
|
|
237
|
-
# This prop will accept any named color from your theme's color palette,
|
|
238
|
-
# and it will use the 500 value in light mode or the 300 value in dark mode.
|
|
239
|
-
# This prop can only be used for named colors from your theme, not arbitrary hex/rgb colors.
|
|
240
|
-
# If you would like to use a specific color for the background that's not a part of your theme,
|
|
241
|
-
# use the chakraStyles prop to customize it.
|
|
242
|
-
# default: "blue"
|
|
243
|
-
selected_option_color_scheme: Var[str]
|
|
244
|
-
|
|
245
|
-
# [chakra]
|
|
246
|
-
# The default option "color" will style a selected option
|
|
247
|
-
# similar to how react-select does it,
|
|
248
|
-
# by highlighting the selected option in the color blue.
|
|
249
|
-
# Alternatively, if you pass "check" for the value,
|
|
250
|
-
# the selected option will be styled like the Chakra UI Menu component
|
|
251
|
-
# and include a check icon next to the selected option(s).
|
|
252
|
-
# If is_multi and selected_option_style="check" are passed,
|
|
253
|
-
# space will only be added for the check marks
|
|
254
|
-
# if hide_selected_options=False is also passed.
|
|
255
|
-
# options: "color" | "check"
|
|
256
|
-
# default: "color"
|
|
257
|
-
selected_option_style: Var[str]
|
|
258
|
-
|
|
259
|
-
# [chakra]
|
|
260
|
-
# The size of the component.
|
|
261
|
-
# options: "sm" | "md" | "lg"
|
|
262
|
-
# default: "md"
|
|
263
|
-
size: Var[str]
|
|
264
|
-
|
|
265
|
-
# Sets the tabIndex attribute on the input
|
|
266
|
-
tab_index: Var[int]
|
|
267
|
-
|
|
268
|
-
# Select the currently focused option when the user presses tab
|
|
269
|
-
tab_selects_value: Var[bool]
|
|
270
|
-
|
|
271
|
-
# [chakra]
|
|
272
|
-
# Variant of multi-select tags
|
|
273
|
-
# options: "subtle" | "solid" | "outline"
|
|
274
|
-
# default: "subtle"
|
|
275
|
-
tag_variant: Var[str]
|
|
276
|
-
|
|
277
|
-
# Remove all non-essential styles
|
|
278
|
-
unstyled: Var[bool]
|
|
279
|
-
|
|
280
|
-
# [chakra]
|
|
281
|
-
# If this prop is passed,
|
|
282
|
-
# the dropdown indicator at the right of the component will be styled
|
|
283
|
-
# in the same way the original Chakra Select component is styled,
|
|
284
|
-
# instead of being styled as an InputRightAddon.
|
|
285
|
-
# The original purpose of styling it as an addon
|
|
286
|
-
# was to create a visual separation between the dropdown indicator
|
|
287
|
-
# and the button for clearing the selected options.
|
|
288
|
-
# However, as this button only appears when isMulti is passed,
|
|
289
|
-
# using this style could make more sense for a single select.
|
|
290
|
-
# default: False
|
|
291
|
-
use_basic_style: Var[bool]
|
|
292
|
-
|
|
293
|
-
# [chakra]
|
|
294
|
-
# The variant of the Select. If no variant is passed,
|
|
295
|
-
# it will default to defaultProps.variant from the theme for Chakra's Input component.
|
|
296
|
-
# If your component theme for Input is not modified, it will be outline.
|
|
297
|
-
# options: "outline" | "filled" | "flushed" | "unstyled"
|
|
298
|
-
# default: "outline"
|
|
299
|
-
variant: Var[str]
|
|
300
|
-
|
|
301
|
-
# How the options should be displayed in the menu.
|
|
302
|
-
menu_position: Var[str] = "fixed" # type: ignore
|
|
303
|
-
|
|
304
|
-
def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
|
|
305
|
-
"""Get the event triggers that pass the component's value to the handler.
|
|
306
|
-
|
|
307
|
-
Returns:
|
|
308
|
-
A dict mapping the event trigger to the var that is passed to the handler.
|
|
309
|
-
"""
|
|
310
|
-
return {
|
|
311
|
-
**super().get_event_triggers(),
|
|
312
|
-
EventTriggers.ON_CHANGE: (
|
|
313
|
-
lambda e0: [
|
|
314
|
-
Var.create_safe(f"{e0}.map(e => e.value)", _var_is_local=True)
|
|
315
|
-
]
|
|
316
|
-
if self.is_multi.equals(Var.create_safe(True))
|
|
317
|
-
else lambda e0: [e0]
|
|
318
|
-
),
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
@classmethod
|
|
322
|
-
def get_initial_props(cls) -> Set[str]:
|
|
323
|
-
"""Get the initial props to set for the component.
|
|
324
|
-
|
|
325
|
-
Returns:
|
|
326
|
-
The initial props to set.
|
|
327
|
-
"""
|
|
328
|
-
return super().get_initial_props() | {"is_multi"}
|
|
329
|
-
|
|
330
|
-
@classmethod
|
|
331
|
-
def create(
|
|
332
|
-
cls, options: List[Union[Option, str, int, float, bool]], **props
|
|
333
|
-
) -> Component:
|
|
334
|
-
"""Takes a list of options and additional properties, checks if each option is an
|
|
335
|
-
instance of Option, and returns a Select component with the given options and
|
|
336
|
-
properties. No children allowed.
|
|
337
|
-
|
|
338
|
-
Args:
|
|
339
|
-
options (List[Option | str | int | float | bool]): A list of values.
|
|
340
|
-
**props: Additional properties to be passed to the Select component.
|
|
341
|
-
|
|
342
|
-
Returns:
|
|
343
|
-
The `create` method is returning an instance of the `Select` class.
|
|
344
|
-
"""
|
|
345
|
-
converted_options: List[Option] = []
|
|
346
|
-
if not isinstance(options, Var):
|
|
347
|
-
for option in options:
|
|
348
|
-
if not isinstance(option, Option):
|
|
349
|
-
converted_options.append(Option(label=str(option), value=option))
|
|
350
|
-
else:
|
|
351
|
-
converted_options.append(option)
|
|
352
|
-
props["options"] = [o.dict() for o in converted_options]
|
|
353
|
-
else:
|
|
354
|
-
props["options"] = options
|
|
355
|
-
return super().create(*[], **props)
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"""A number input component."""
|
|
2
|
-
|
|
3
|
-
from numbers import Number
|
|
4
|
-
|
|
5
|
-
from reflex.components.chakra import (
|
|
6
|
-
ChakraComponent,
|
|
7
|
-
LiteralButtonSize,
|
|
8
|
-
LiteralInputVariant,
|
|
9
|
-
)
|
|
10
|
-
from reflex.components.component import Component
|
|
11
|
-
from reflex.event import EventHandler
|
|
12
|
-
from reflex.vars import Var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class NumberInput(ChakraComponent):
|
|
16
|
-
"""The wrapper that provides context and logic to the components."""
|
|
17
|
-
|
|
18
|
-
tag = "NumberInput"
|
|
19
|
-
|
|
20
|
-
# State var to bind the input.
|
|
21
|
-
value: Var[Number]
|
|
22
|
-
|
|
23
|
-
# If true, the input's value will change based on mouse wheel.
|
|
24
|
-
allow_mouse_wheel: Var[bool]
|
|
25
|
-
|
|
26
|
-
# This controls the value update when you blur out of the input. - If true and the value is greater than max, the value will be reset to max - Else, the value remains the same.
|
|
27
|
-
clamped_value_on_blur: Var[bool]
|
|
28
|
-
|
|
29
|
-
# The initial value of the counter. Should be less than max and greater than min
|
|
30
|
-
default_value: Var[Number]
|
|
31
|
-
|
|
32
|
-
# The border color when the input is invalid.
|
|
33
|
-
error_border_color: Var[str]
|
|
34
|
-
|
|
35
|
-
# The border color when the input is focused.
|
|
36
|
-
focus_border_color: Var[str]
|
|
37
|
-
|
|
38
|
-
# If true, the input will be focused as you increment or decrement the value with the stepper
|
|
39
|
-
focus_input_on_change: Var[bool]
|
|
40
|
-
|
|
41
|
-
# Hints at the type of data that might be entered by the user. It also determines the type of keyboard shown to the user on mobile devices ("text" | "search" | "none" | "tel" | "url" | "email" | "numeric" | "decimal")
|
|
42
|
-
# input_mode: Var[LiteralInputNumberMode]
|
|
43
|
-
|
|
44
|
-
# Whether the input should be disabled.
|
|
45
|
-
is_disabled: Var[bool]
|
|
46
|
-
|
|
47
|
-
# If true, the input will have `aria-invalid` set to true
|
|
48
|
-
is_invalid: Var[bool]
|
|
49
|
-
|
|
50
|
-
# If true, the input will be in readonly mode
|
|
51
|
-
is_read_only: Var[bool]
|
|
52
|
-
|
|
53
|
-
# Whether the input is required
|
|
54
|
-
is_required: Var[bool]
|
|
55
|
-
|
|
56
|
-
# Whether the pressed key should be allowed in the input. The default behavior is to allow DOM floating point characters defined by /^[Ee0-9+\-.]$/
|
|
57
|
-
is_valid_character: Var[str]
|
|
58
|
-
|
|
59
|
-
# This controls the value update behavior in general. - If true and you use the stepper or up/down arrow keys, the value will not exceed the max or go lower than min - If false, the value will be allowed to go out of range.
|
|
60
|
-
keep_within_range: Var[bool]
|
|
61
|
-
|
|
62
|
-
# The maximum value of the counter
|
|
63
|
-
max_: Var[Number]
|
|
64
|
-
|
|
65
|
-
# The minimum value of the counter
|
|
66
|
-
min_: Var[Number]
|
|
67
|
-
|
|
68
|
-
# "outline" | "filled" | "flushed" | "unstyled"
|
|
69
|
-
variant: Var[LiteralInputVariant]
|
|
70
|
-
|
|
71
|
-
# "lg" | "md" | "sm" | "xs"
|
|
72
|
-
size: Var[LiteralButtonSize]
|
|
73
|
-
|
|
74
|
-
# The name of the form field
|
|
75
|
-
name: Var[str]
|
|
76
|
-
|
|
77
|
-
# Fired when the input value changes.
|
|
78
|
-
on_change: EventHandler[lambda e0: [e0]]
|
|
79
|
-
|
|
80
|
-
@classmethod
|
|
81
|
-
def create(cls, *children, **props) -> Component:
|
|
82
|
-
"""Create a number input component.
|
|
83
|
-
|
|
84
|
-
If no children are provided, a default stepper will be used.
|
|
85
|
-
|
|
86
|
-
Args:
|
|
87
|
-
*children: The children of the component.
|
|
88
|
-
**props: The props of the component.
|
|
89
|
-
|
|
90
|
-
Returns:
|
|
91
|
-
The component.
|
|
92
|
-
"""
|
|
93
|
-
if len(children) == 0:
|
|
94
|
-
_id = props.pop("id", None)
|
|
95
|
-
children = [
|
|
96
|
-
NumberInputField.create(id=_id)
|
|
97
|
-
if _id is not None
|
|
98
|
-
else NumberInputField.create(),
|
|
99
|
-
NumberInputStepper.create(
|
|
100
|
-
NumberIncrementStepper.create(),
|
|
101
|
-
NumberDecrementStepper.create(),
|
|
102
|
-
),
|
|
103
|
-
]
|
|
104
|
-
return super().create(*children, **props)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
class NumberInputField(ChakraComponent):
|
|
108
|
-
"""The input field itself."""
|
|
109
|
-
|
|
110
|
-
tag = "NumberInputField"
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
class NumberInputStepper(ChakraComponent):
|
|
114
|
-
"""The wrapper for the input's stepper buttons."""
|
|
115
|
-
|
|
116
|
-
tag = "NumberInputStepper"
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
class NumberIncrementStepper(ChakraComponent):
|
|
120
|
-
"""The button to increment the value of the input."""
|
|
121
|
-
|
|
122
|
-
tag = "NumberIncrementStepper"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
class NumberDecrementStepper(ChakraComponent):
|
|
126
|
-
"""The button to decrement the value of the input."""
|
|
127
|
-
|
|
128
|
-
tag = "NumberDecrementStepper"
|