streamlit 1.48.0__py3-none-any.whl → 1.49.0__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.
- streamlit/__init__.py +3 -10
- streamlit/commands/logo.py +4 -3
- streamlit/commands/navigation.py +1 -1
- streamlit/commands/page_config.py +4 -1
- streamlit/components/v1/custom_component.py +2 -2
- streamlit/config.py +82 -1
- streamlit/connections/snowflake_connection.py +3 -1
- streamlit/delta_generator.py +3 -0
- streamlit/elements/arrow.py +155 -70
- streamlit/elements/bokeh_chart.py +13 -3
- streamlit/elements/deck_gl_json_chart.py +0 -1
- streamlit/elements/dialog_decorator.py +7 -59
- streamlit/elements/form.py +10 -1
- streamlit/elements/graphviz_chart.py +57 -6
- streamlit/elements/heading.py +17 -16
- streamlit/elements/iframe.py +13 -22
- streamlit/elements/image.py +64 -37
- streamlit/elements/layouts.py +2 -2
- streamlit/elements/lib/built_in_chart_utils.py +2 -5
- streamlit/elements/lib/column_config_utils.py +18 -4
- streamlit/elements/lib/column_types.py +75 -30
- streamlit/elements/lib/dialog.py +3 -3
- streamlit/elements/lib/image_utils.py +19 -11
- streamlit/elements/lib/layout_utils.py +15 -2
- streamlit/elements/lib/utils.py +20 -41
- streamlit/elements/markdown.py +7 -6
- streamlit/elements/media.py +6 -13
- streamlit/elements/metric.py +78 -1
- streamlit/elements/pdf.py +192 -0
- streamlit/elements/plotly_chart.py +3 -2
- streamlit/elements/pyplot.py +53 -11
- streamlit/elements/toast.py +81 -5
- streamlit/elements/vega_charts.py +3 -8
- streamlit/elements/widgets/audio_input.py +0 -1
- streamlit/elements/widgets/button.py +0 -4
- streamlit/elements/widgets/button_group.py +5 -4
- streamlit/elements/widgets/camera_input.py +0 -1
- streamlit/elements/widgets/chat.py +11 -13
- streamlit/elements/widgets/checkbox.py +0 -1
- streamlit/elements/widgets/color_picker.py +0 -1
- streamlit/elements/widgets/data_editor.py +142 -62
- streamlit/elements/widgets/file_uploader.py +74 -37
- streamlit/elements/widgets/multiselect.py +0 -1
- streamlit/elements/widgets/number_input.py +0 -1
- streamlit/elements/widgets/radio.py +0 -1
- streamlit/elements/widgets/select_slider.py +0 -1
- streamlit/elements/widgets/selectbox.py +0 -1
- streamlit/elements/widgets/slider.py +0 -1
- streamlit/elements/widgets/text_widgets.py +0 -2
- streamlit/elements/widgets/time_widgets.py +0 -2
- streamlit/errors.py +11 -0
- streamlit/material_icon_names.py +1 -1
- streamlit/proto/Arrow_pb2.py +14 -8
- streamlit/proto/Arrow_pb2.pyi +11 -3
- streamlit/proto/Block_pb2.py +16 -16
- streamlit/proto/Block_pb2.pyi +2 -0
- streamlit/proto/ChatInput_pb2.py +3 -3
- streamlit/proto/ChatInput_pb2.pyi +2 -0
- streamlit/proto/FileUploader_pb2.py +2 -2
- streamlit/proto/FileUploader_pb2.pyi +5 -1
- streamlit/proto/GraphVizChart_pb2.py +4 -2
- streamlit/proto/GraphVizChart_pb2.pyi +1 -1
- streamlit/proto/IFrame_pb2.py +8 -2
- streamlit/proto/IFrame_pb2.pyi +3 -0
- streamlit/proto/Image_pb2.py +4 -2
- streamlit/proto/Image_pb2.pyi +1 -10
- streamlit/proto/Metric_pb2.py +8 -6
- streamlit/proto/Metric_pb2.pyi +34 -10
- streamlit/proto/Toast_pb2.py +2 -2
- streamlit/proto/Toast_pb2.pyi +10 -1
- streamlit/runtime/caching/__init__.py +14 -2
- streamlit/runtime/caching/cache_data_api.py +0 -17
- streamlit/runtime/caching/cache_resource_api.py +0 -16
- streamlit/runtime/caching/cached_message_replay.py +8 -20
- streamlit/runtime/caching/hashing.py +31 -1
- streamlit/runtime/credentials.py +4 -4
- streamlit/runtime/fragment.py +0 -42
- streamlit/runtime/websocket_session_manager.py +1 -1
- streamlit/static/index.html +2 -2
- streamlit/static/manifest.json +224 -252
- streamlit/static/static/css/{index.CJVRHjQZ.css → index.C8X8rNzw.css} +1 -1
- streamlit/static/static/css/index.COe1010n.css +1 -0
- streamlit/static/static/js/{ErrorOutline.esm.D_4oFNKB.js → ErrorOutline.esm.u9XvzxL8.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.NPgaLlUE.js → FileDownload.esm.CaRyZ-b2.js} +1 -1
- streamlit/static/static/js/FileHelper.Dk2SwIi3.js +5 -0
- streamlit/static/static/js/FormClearHelper.l_UPPvkg.js +1 -0
- streamlit/static/static/js/{Hooks.BGm9sd4U.js → Hooks.BxrVEftw.js} +1 -1
- streamlit/static/static/js/InputInstructions.C254RU9X.js +1 -0
- streamlit/static/static/js/Particles.DkY6FDnc.js +1 -0
- streamlit/static/static/js/ProgressBar.BPtSM82n.js +2 -0
- streamlit/static/static/js/Toolbar.BO_3WBaS.js +1 -0
- streamlit/static/static/js/{base-input.DeBqm5mN.js → base-input.egUI4LjJ.js} +4 -4
- streamlit/static/static/js/{checkbox.C0odQfKb.js → checkbox.ButpszcE.js} +2 -2
- streamlit/static/static/js/createSuper.DYJA5xa6.js +1 -0
- streamlit/static/static/js/data-grid-overlay-editor.C9gQLEnU.js +1 -0
- streamlit/static/static/js/{downloader.Bx1D0jhz.js → downloader.B3TjsSPZ.js} +1 -1
- streamlit/static/static/js/es6.BYSNuG4D.js +2 -0
- streamlit/static/static/js/iframeResizer.contentWindow.CNPHJsF2.js +1 -0
- streamlit/static/static/js/index.0tDq1WXk.js +1 -0
- streamlit/static/static/js/index.BBnWuh07.js +976 -0
- streamlit/static/static/js/index.BDZorv41.js +1 -0
- streamlit/static/static/js/{index.DwaoC4Zp.js → index.BH79B25f.js} +3 -3
- streamlit/static/static/js/index.BeTC4Yl-.js +197 -0
- streamlit/static/static/js/index.BnOd05Ko.js +2 -0
- streamlit/static/static/js/index.BoJaJReB.js +1 -0
- streamlit/static/static/js/index.Bp1Of6L8.js +1 -0
- streamlit/static/static/js/index.Bpe4-O2W.js +1 -0
- streamlit/static/static/js/index.BrD9sbpx.js +1 -0
- streamlit/static/static/js/index.C1qCS-sd.js +1 -0
- streamlit/static/static/js/index.C3EXAI-u.js +1 -0
- streamlit/static/static/js/index.C77g9sAQ.js +3 -0
- streamlit/static/static/js/{index.PyIqRRSR.js → index.CFePF7s4.js} +1 -1
- streamlit/static/static/js/index.CFjU0x00.js +1 -0
- streamlit/static/static/js/index.Ca3y4ztK.js +1 -0
- streamlit/static/static/js/{index.ClRTsv8m.js → index.Cb9gN2T2.js} +2 -2
- streamlit/static/static/js/{index.wDYef4mQ.js → index.CbwuUwu4.js} +9 -9
- streamlit/static/static/js/index.CeXLlclc.js +1 -0
- streamlit/static/static/js/index.CfiZGqj3.js +3 -0
- streamlit/static/static/js/index.CjQnYKID.js +1 -0
- streamlit/static/static/js/index.Cl_966eE.js +3858 -0
- streamlit/static/static/js/{index.DCpyIFTV.js → index.CqSRo6zQ.js} +1 -1
- streamlit/static/static/js/index.CuEFSQ-o.js +1 -0
- streamlit/static/static/js/index.D4jR1m1z.js +1 -0
- streamlit/static/static/js/index.DGcW849X.js +1 -0
- streamlit/static/static/js/index.DKb-BAE2.js +1 -0
- streamlit/static/static/js/index.DP1rDFP0.js +1 -0
- streamlit/static/static/js/{index.HeVbRh9H.js → index.DStzYLqM.js} +2 -2
- streamlit/static/static/js/index.DVKQKDLu.js +1 -0
- streamlit/static/static/js/index.DWedOrkQ.js +1 -0
- streamlit/static/static/js/index.DYbRPmVF.js +1 -0
- streamlit/static/static/js/index.DgpIMUsr.js +1 -0
- streamlit/static/static/js/index.DtwkPJs5.js +5367 -0
- streamlit/static/static/js/{index.CnfWsQzS.js → index.MQLQLR5Z.js} +1 -1
- streamlit/static/static/js/index.uInpwWAP.js +1 -0
- streamlit/static/static/js/index.z992t-BQ.js +7 -0
- streamlit/static/static/js/{input.BL2buuce.js → input.CbP5ZuQ7.js} +2 -2
- streamlit/static/static/js/{memory.CUxjUWS7.js → memory.BuacVo2L.js} +1 -1
- streamlit/static/static/js/number-overlay-editor.BZb9zRl_.js +9 -0
- streamlit/static/static/js/{possibleConstructorReturn.DbvQboK3.js → possibleConstructorReturn.DSM84rOS.js} +1 -1
- streamlit/static/static/js/{sandbox.6lnFVWhX.js → sandbox.C480llMG.js} +1 -1
- streamlit/static/static/js/{timepicker.Bg4xAK95.js → timepicker.BunxCVp7.js} +4 -4
- streamlit/static/static/js/{toConsumableArray.D9x7Ktv4.js → toConsumableArray.B4o8rEx1.js} +3 -3
- streamlit/static/static/js/uniqueId.tii0yosY.js +1 -0
- streamlit/static/static/js/{useBasicWidgetState.CUSYQZpm.js → useBasicWidgetState.Bnm4FD6K.js} +1 -1
- streamlit/static/static/js/useTextInputAutoExpand.Dgtwc1m0.js +2 -0
- streamlit/static/static/js/useUpdateUiValue.DjXdMFGw.js +1 -0
- streamlit/static/static/js/withFullScreenWrapper.0cy2pVf5.js +1 -0
- streamlit/static/static/media/MaterialSymbols-Rounded.CBxVaFdk.woff2 +0 -0
- streamlit/user_info.py +16 -13
- streamlit/web/server/browser_websocket_handler.py +15 -0
- streamlit/web/server/oauth_authlib_routes.py +3 -59
- {streamlit-1.48.0.dist-info → streamlit-1.49.0.dist-info}/METADATA +4 -2
- {streamlit-1.48.0.dist-info → streamlit-1.49.0.dist-info}/RECORD +157 -160
- streamlit/static/static/css/index.CQt5TjGB.css +0 -1
- streamlit/static/static/js/FileHelper.B2t9ikoS.js +0 -5
- streamlit/static/static/js/FormClearHelper.BLEIUk6L.js +0 -1
- streamlit/static/static/js/InputInstructions.DtUxCBS8.js +0 -1
- streamlit/static/static/js/Particles.BDRPO7r3.js +0 -1
- streamlit/static/static/js/ProgressBar.B64DUUqp.js +0 -2
- streamlit/static/static/js/Toolbar.B3FquPk5.js +0 -1
- streamlit/static/static/js/createSuper.DqQ5L3XG.js +0 -1
- streamlit/static/static/js/data-grid-overlay-editor.DbNsQa8Y.js +0 -1
- streamlit/static/static/js/es6.CbPK4m0H.js +0 -2
- streamlit/static/static/js/iframeResizer.contentWindow.CfLKrptA.js +0 -1
- streamlit/static/static/js/index.0XDwe9RV.js +0 -203
- streamlit/static/static/js/index.4lI9TuZm.js +0 -3
- streamlit/static/static/js/index.6s0nVIis.js +0 -3855
- streamlit/static/static/js/index.9E7bRUBU.js +0 -1
- streamlit/static/static/js/index.B9PgeLrZ.js +0 -1
- streamlit/static/static/js/index.B9vzGbOt.js +0 -1
- streamlit/static/static/js/index.BDrQKMCm.js +0 -1
- streamlit/static/static/js/index.BPsoiGgP.js +0 -1
- streamlit/static/static/js/index.CJzdLAun.js +0 -1
- streamlit/static/static/js/index.CNNlC1NL.js +0 -1
- streamlit/static/static/js/index.CO1sClzJ.js +0 -2
- streamlit/static/static/js/index.CZnagxXD.js +0 -1
- streamlit/static/static/js/index.Cb0xSF7V.js +0 -5366
- streamlit/static/static/js/index.CgUt3tz_.js +0 -1
- streamlit/static/static/js/index.CjImmcsV.js +0 -1
- streamlit/static/static/js/index.CrJ1XD_V.js +0 -1
- streamlit/static/static/js/index.CtiKsjSC.js +0 -1
- streamlit/static/static/js/index.CwAuytgV.js +0 -1
- streamlit/static/static/js/index.D7GB-kly.js +0 -1
- streamlit/static/static/js/index.DA5wU0mQ.js +0 -1
- streamlit/static/static/js/index.DE9wNOje.js +0 -1
- streamlit/static/static/js/index.DHnB-C8A.js +0 -1
- streamlit/static/static/js/index.DRTn9zvD.js +0 -1
- streamlit/static/static/js/index.DjMjyJl9.js +0 -7
- streamlit/static/static/js/index.DvRPFfw6.js +0 -781
- streamlit/static/static/js/index.F9tSej94.js +0 -1
- streamlit/static/static/js/index.J2D_m7LY.js +0 -197
- streamlit/static/static/js/index.dfivzJNz.js +0 -1
- streamlit/static/static/js/index.mRztGO69.js +0 -3
- streamlit/static/static/js/index.tB1kn_7z.js +0 -1
- streamlit/static/static/js/mergeWith.C1kp1zIi.js +0 -1
- streamlit/static/static/js/number-overlay-editor.WpheGpmR.js +0 -9
- streamlit/static/static/js/threshold.DjX0wlsa.js +0 -1
- streamlit/static/static/js/timer.CAwTRJ_g.js +0 -1
- streamlit/static/static/js/uniqueId.Bm8FHN92.js +0 -1
- streamlit/static/static/js/useTextInputAutoExpand.Bf2egQOG.js +0 -2
- streamlit/static/static/js/useUpdateUiValue.lE5xnYWF.js +0 -1
- streamlit/static/static/js/value.CgPGBV_l.js +0 -1
- streamlit/static/static/js/withFullScreenWrapper.CCOXR7N6.js +0 -1
- streamlit/static/static/media/MaterialSymbols-Rounded.DsbC8sYI.woff2 +0 -0
- {streamlit-1.48.0.data → streamlit-1.49.0.data}/scripts/streamlit.cmd +0 -0
- {streamlit-1.48.0.dist-info → streamlit-1.49.0.dist-info}/WHEEL +0 -0
- {streamlit-1.48.0.dist-info → streamlit-1.49.0.dist-info}/entry_points.txt +0 -0
- {streamlit-1.48.0.dist-info → streamlit-1.49.0.dist-info}/top_level.txt +0 -0
streamlit/elements/toast.py
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import TYPE_CHECKING, cast
|
|
17
|
+
from typing import TYPE_CHECKING, Literal, cast
|
|
18
18
|
|
|
19
|
-
from streamlit.errors import StreamlitAPIException
|
|
19
|
+
from streamlit.errors import StreamlitAPIException, StreamlitValueError
|
|
20
20
|
from streamlit.proto.Toast_pb2 import Toast as ToastProto
|
|
21
21
|
from streamlit.runtime.metrics_util import gather_metrics
|
|
22
22
|
from streamlit.string_util import clean_text, validate_icon_or_emoji
|
|
@@ -41,6 +41,7 @@ class ToastMixin:
|
|
|
41
41
|
body: SupportsStr,
|
|
42
42
|
*, # keyword-only args:
|
|
43
43
|
icon: str | None = None,
|
|
44
|
+
duration: Literal["short", "long", "infinite"] | int = "short",
|
|
44
45
|
) -> DeltaGenerator:
|
|
45
46
|
"""Display a short message, known as a notification "toast".
|
|
46
47
|
The toast appears in the app's top-right corner and disappears after four seconds.
|
|
@@ -79,16 +80,91 @@ class ToastMixin:
|
|
|
79
80
|
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
|
|
80
81
|
font library.
|
|
81
82
|
|
|
83
|
+
duration : "short", "long", "infinite", or int
|
|
84
|
+
The time to display the toast message. This can be one of the
|
|
85
|
+
following:
|
|
82
86
|
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
- ``"short"`` (default): Displays for 4 seconds.
|
|
88
|
+
- ``"long"``: Displays for 10 seconds.
|
|
89
|
+
- ``"infinite"``: Shows the toast until the user dismisses it.
|
|
90
|
+
- An integer: Displays for the specified number of seconds.
|
|
91
|
+
|
|
92
|
+
Examples
|
|
93
|
+
--------
|
|
94
|
+
**Example 1: Show a toast message**
|
|
95
|
+
|
|
96
|
+
>>> import streamlit as st
|
|
97
|
+
>>>
|
|
98
|
+
>>> st.toast("Your edited image was saved!", icon="😍")
|
|
99
|
+
|
|
100
|
+
.. output::
|
|
101
|
+
https://doc-status-toast.streamlit.app
|
|
102
|
+
height: 200px
|
|
103
|
+
|
|
104
|
+
**Example 2: Show multiple toasts**
|
|
105
|
+
|
|
106
|
+
When multiple toasts are generated, they will stack. Hovering over a
|
|
107
|
+
toast will stop it from disappearing. When hovering ends, the toast
|
|
108
|
+
will disappear after time specified in ``duration``.
|
|
109
|
+
|
|
110
|
+
>>> import time
|
|
85
111
|
>>> import streamlit as st
|
|
86
112
|
>>>
|
|
87
|
-
>>> st.
|
|
113
|
+
>>> if st.button("Three cheers"):
|
|
114
|
+
>>> st.toast("Hip!")
|
|
115
|
+
>>> time.sleep(0.5)
|
|
116
|
+
>>> st.toast("Hip!")
|
|
117
|
+
>>> time.sleep(0.5)
|
|
118
|
+
>>> st.toast("Hooray!", icon="🎉")
|
|
119
|
+
|
|
120
|
+
.. output::
|
|
121
|
+
https://doc-status-toast1.streamlit.app
|
|
122
|
+
height: 300px
|
|
123
|
+
|
|
124
|
+
**Example 3: Update a toast message**
|
|
125
|
+
|
|
126
|
+
Toast messages can also be updated. Assign ``st.toast(my_message)`` to
|
|
127
|
+
a variable and use the ``.toast()`` method to update it. If a toast has
|
|
128
|
+
already disappeared or been dismissed, the update will not be seen.
|
|
129
|
+
|
|
130
|
+
>>> import time
|
|
131
|
+
>>> import streamlit as st
|
|
132
|
+
>>>
|
|
133
|
+
>>> def cook_breakfast():
|
|
134
|
+
>>> msg = st.toast("Gathering ingredients...")
|
|
135
|
+
>>> time.sleep(1)
|
|
136
|
+
>>> msg.toast("Cooking...")
|
|
137
|
+
>>> time.sleep(1)
|
|
138
|
+
>>> msg.toast("Ready!", icon="🥞")
|
|
139
|
+
>>>
|
|
140
|
+
>>> if st.button("Cook breakfast"):
|
|
141
|
+
>>> cook_breakfast()
|
|
142
|
+
|
|
143
|
+
.. output::
|
|
144
|
+
https://doc-status-toast2.streamlit.app
|
|
145
|
+
height: 200px
|
|
146
|
+
|
|
88
147
|
"""
|
|
89
148
|
toast_proto = ToastProto()
|
|
90
149
|
toast_proto.body = clean_text(validate_text(body))
|
|
91
150
|
toast_proto.icon = validate_icon_or_emoji(icon)
|
|
151
|
+
|
|
152
|
+
if duration in ["short", "long", "infinite"] or (
|
|
153
|
+
isinstance(duration, int) and duration > 0
|
|
154
|
+
):
|
|
155
|
+
if duration == "short":
|
|
156
|
+
toast_proto.duration = 4
|
|
157
|
+
elif duration == "long":
|
|
158
|
+
toast_proto.duration = 10
|
|
159
|
+
elif duration == "infinite":
|
|
160
|
+
toast_proto.duration = 0
|
|
161
|
+
else:
|
|
162
|
+
toast_proto.duration = duration
|
|
163
|
+
else:
|
|
164
|
+
raise StreamlitValueError(
|
|
165
|
+
"duration", ["short", "long", "infinite", "a positive integer"]
|
|
166
|
+
)
|
|
167
|
+
|
|
92
168
|
return self.dg._enqueue("toast", toast_proto)
|
|
93
169
|
|
|
94
170
|
@property
|
|
@@ -387,18 +387,14 @@ def _convert_altair_to_vega_lite_spec(
|
|
|
387
387
|
alt.data_transformers.register("id", id_transform) # type: ignore[arg-type,attr-defined,unused-ignore]
|
|
388
388
|
|
|
389
389
|
# alt.themes was deprecated in Altair 5.5.0 in favor of alt.theme
|
|
390
|
-
|
|
391
|
-
alt.themes if type_util.is_altair_version_less_than("5.5.0") else alt.theme
|
|
390
|
+
alt_theme = (
|
|
391
|
+
alt.themes if type_util.is_altair_version_less_than("5.5.0") else alt.theme # ty: ignore[unresolved-attribute]
|
|
392
392
|
)
|
|
393
393
|
|
|
394
394
|
# The default altair theme has some width/height defaults defined
|
|
395
395
|
# which are not useful for Streamlit. Therefore, we change the theme to
|
|
396
396
|
# "none" to avoid those defaults.
|
|
397
|
-
with (
|
|
398
|
-
altair_theme.enable("none")
|
|
399
|
-
if altair_theme.active == "default"
|
|
400
|
-
else nullcontext()
|
|
401
|
-
): # type: ignore[attr-defined,unused-ignore]
|
|
397
|
+
with alt_theme.enable("none") if alt_theme.active == "default" else nullcontext(): # ty: ignore
|
|
402
398
|
with alt.data_transformers.enable("id"): # type: ignore[attr-defined,unused-ignore]
|
|
403
399
|
chart_dict = altair_chart.to_dict()
|
|
404
400
|
|
|
@@ -2083,7 +2079,6 @@ class VegaChartsMixin:
|
|
|
2083
2079
|
vega_lite_proto.id = compute_and_register_element_id(
|
|
2084
2080
|
"arrow_vega_lite_chart",
|
|
2085
2081
|
user_key=key,
|
|
2086
|
-
form_id=vega_lite_proto.form_id,
|
|
2087
2082
|
dg=self.dg,
|
|
2088
2083
|
vega_lite_spec=vega_lite_proto.spec,
|
|
2089
2084
|
# The data is either in vega_lite_proto.data.data
|
|
@@ -914,8 +914,6 @@ class ButtonMixin:
|
|
|
914
914
|
element_id = compute_and_register_element_id(
|
|
915
915
|
"download_button",
|
|
916
916
|
user_key=key,
|
|
917
|
-
# download_button is not allowed to be used in a form.
|
|
918
|
-
form_id=None,
|
|
919
917
|
dg=self.dg,
|
|
920
918
|
label=label,
|
|
921
919
|
icon=icon,
|
|
@@ -1123,8 +1121,6 @@ class ButtonMixin:
|
|
|
1123
1121
|
element_id = compute_and_register_element_id(
|
|
1124
1122
|
"button",
|
|
1125
1123
|
user_key=key,
|
|
1126
|
-
# Only the
|
|
1127
|
-
form_id=form_id,
|
|
1128
1124
|
dg=self.dg,
|
|
1129
1125
|
label=label,
|
|
1130
1126
|
icon=icon,
|
|
@@ -1031,7 +1031,6 @@ class ButtonGroupMixin:
|
|
|
1031
1031
|
|
|
1032
1032
|
check_widget_policies(self.dg, key, on_change, default_value=_default)
|
|
1033
1033
|
|
|
1034
|
-
widget_name = "button_group"
|
|
1035
1034
|
ctx = get_script_run_ctx()
|
|
1036
1035
|
form_id = current_form_id(self.dg)
|
|
1037
1036
|
formatted_options = (
|
|
@@ -1042,10 +1041,12 @@ class ButtonGroupMixin:
|
|
|
1042
1041
|
for index, _ in enumerate(indexable_options)
|
|
1043
1042
|
]
|
|
1044
1043
|
)
|
|
1044
|
+
|
|
1045
1045
|
element_id = compute_and_register_element_id(
|
|
1046
|
-
|
|
1046
|
+
# The borderless style is used by st.feedback, but users expect to see
|
|
1047
|
+
# "feedback" in errors
|
|
1048
|
+
"feedback" if style == "borderless" else style,
|
|
1047
1049
|
user_key=key,
|
|
1048
|
-
form_id=form_id,
|
|
1049
1050
|
dg=self.dg,
|
|
1050
1051
|
options=formatted_options,
|
|
1051
1052
|
default=default,
|
|
@@ -1088,7 +1089,7 @@ class ButtonGroupMixin:
|
|
|
1088
1089
|
if ctx:
|
|
1089
1090
|
save_for_app_testing(ctx, element_id, format_func)
|
|
1090
1091
|
|
|
1091
|
-
self.dg._enqueue(
|
|
1092
|
+
self.dg._enqueue("button_group", proto, layout_config=layout_config)
|
|
1092
1093
|
|
|
1093
1094
|
return widget_state
|
|
1094
1095
|
|
|
@@ -32,7 +32,7 @@ from streamlit.elements.lib.file_uploader_utils import (
|
|
|
32
32
|
normalize_upload_file_type,
|
|
33
33
|
)
|
|
34
34
|
from streamlit.elements.lib.form_utils import is_in_form
|
|
35
|
-
from streamlit.elements.lib.image_utils import AtomicImage,
|
|
35
|
+
from streamlit.elements.lib.image_utils import AtomicImage, image_to_url
|
|
36
36
|
from streamlit.elements.lib.layout_utils import (
|
|
37
37
|
LayoutConfig,
|
|
38
38
|
Width,
|
|
@@ -147,7 +147,7 @@ def _process_avatar_input(
|
|
|
147
147
|
try:
|
|
148
148
|
return AvatarType.IMAGE, image_to_url(
|
|
149
149
|
avatar,
|
|
150
|
-
width=
|
|
150
|
+
layout_config=LayoutConfig(width="content"),
|
|
151
151
|
clamp=False,
|
|
152
152
|
channels="RGB",
|
|
153
153
|
output_format="auto",
|
|
@@ -391,7 +391,7 @@ class ChatMixin:
|
|
|
391
391
|
*,
|
|
392
392
|
key: Key | None = None,
|
|
393
393
|
max_chars: int | None = None,
|
|
394
|
-
accept_file: Literal[True, "multiple"],
|
|
394
|
+
accept_file: Literal[True, "multiple", "directory"],
|
|
395
395
|
file_type: str | Sequence[str] | None = None,
|
|
396
396
|
disabled: bool = False,
|
|
397
397
|
on_submit: WidgetCallback | None = None,
|
|
@@ -407,7 +407,7 @@ class ChatMixin:
|
|
|
407
407
|
*,
|
|
408
408
|
key: Key | None = None,
|
|
409
409
|
max_chars: int | None = None,
|
|
410
|
-
accept_file: bool | Literal["multiple"] = False,
|
|
410
|
+
accept_file: bool | Literal["multiple", "directory"] = False,
|
|
411
411
|
file_type: str | Sequence[str] | None = None,
|
|
412
412
|
disabled: bool = False,
|
|
413
413
|
on_submit: WidgetCallback | None = None,
|
|
@@ -433,7 +433,7 @@ class ChatMixin:
|
|
|
433
433
|
The maximum number of characters that can be entered. If this is
|
|
434
434
|
``None`` (default), there will be no maximum.
|
|
435
435
|
|
|
436
|
-
accept_file : bool or
|
|
436
|
+
accept_file : bool, "multiple", or "directory"
|
|
437
437
|
Whether the chat input should accept files. This can be one of the
|
|
438
438
|
following values:
|
|
439
439
|
|
|
@@ -442,9 +442,9 @@ class ChatMixin:
|
|
|
442
442
|
- ``True``: The user can add a single file to their submission.
|
|
443
443
|
- ``"multiple"``: The user can add multiple files to their
|
|
444
444
|
submission.
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
445
|
+
- ``"directory"``: The user can add multiple files to their
|
|
446
|
+
submission by selecting a directory. If ``file_type`` is set,
|
|
447
|
+
only files matching those type(s) will be uploaded.
|
|
448
448
|
|
|
449
449
|
By default, uploaded files are limited to 200 MB each. You can
|
|
450
450
|
configure this using the ``server.maxUploadSize`` config option.
|
|
@@ -614,9 +614,9 @@ class ChatMixin:
|
|
|
614
614
|
writes_allowed=True,
|
|
615
615
|
)
|
|
616
616
|
|
|
617
|
-
if accept_file not in {True, False, "multiple"}:
|
|
617
|
+
if accept_file not in {True, False, "multiple", "directory"}:
|
|
618
618
|
raise StreamlitAPIException(
|
|
619
|
-
"The `accept_file` parameter must be a boolean or 'multiple'."
|
|
619
|
+
"The `accept_file` parameter must be a boolean or 'multiple' or 'directory'."
|
|
620
620
|
)
|
|
621
621
|
|
|
622
622
|
ctx = get_script_run_ctx()
|
|
@@ -624,8 +624,6 @@ class ChatMixin:
|
|
|
624
624
|
element_id = compute_and_register_element_id(
|
|
625
625
|
"chat_input",
|
|
626
626
|
user_key=key,
|
|
627
|
-
# chat_input is not allowed to be used in a form.
|
|
628
|
-
form_id=None,
|
|
629
627
|
dg=self.dg,
|
|
630
628
|
placeholder=placeholder,
|
|
631
629
|
max_chars=max_chars,
|
|
@@ -677,7 +675,7 @@ class ChatMixin:
|
|
|
677
675
|
chat_input_proto.max_upload_size_mb = config.get_option("server.maxUploadSize")
|
|
678
676
|
|
|
679
677
|
serde = ChatInputSerde(
|
|
680
|
-
accept_files=
|
|
678
|
+
accept_files=accept_file in {True, "multiple", "directory"},
|
|
681
679
|
allowed_types=file_type,
|
|
682
680
|
)
|
|
683
681
|
widget_state = register_widget( # type: ignore[misc]
|
|
@@ -342,7 +342,6 @@ class CheckboxMixin:
|
|
|
342
342
|
element_id = compute_and_register_element_id(
|
|
343
343
|
"toggle" if type == CheckboxProto.StyleType.TOGGLE else "checkbox",
|
|
344
344
|
user_key=key,
|
|
345
|
-
form_id=current_form_id(self.dg),
|
|
346
345
|
dg=self.dg,
|
|
347
346
|
label=label,
|
|
348
347
|
value=bool(value),
|