streamlit-nightly 1.45.1.dev20250503__py3-none-any.whl → 1.45.1.dev20250505__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/column_config.py +8 -8
- streamlit/commands/execution_control.py +2 -5
- streamlit/components/v1/components.py +1 -1
- streamlit/connections/__init__.py +2 -2
- streamlit/delta_generator.py +2 -2
- streamlit/elements/alert.py +1 -1
- streamlit/elements/json.py +1 -1
- streamlit/elements/lib/built_in_chart_utils.py +14 -6
- streamlit/elements/lib/column_config_utils.py +1 -3
- streamlit/elements/lib/file_uploader_utils.py +7 -2
- streamlit/elements/lib/options_selector_utils.py +1 -1
- streamlit/elements/metric.py +4 -4
- streamlit/elements/progress.py +1 -1
- streamlit/elements/widgets/number_input.py +23 -5
- streamlit/elements/widgets/selectbox.py +25 -0
- streamlit/elements/widgets/time_widgets.py +43 -0
- streamlit/proto/DateInput_pb2.py +4 -3
- streamlit/proto/DateInput_pb2.pyi +8 -2
- streamlit/proto/NumberInput_pb2.py +6 -5
- streamlit/proto/NumberInput_pb2.pyi +9 -2
- streamlit/proto/Selectbox_pb2.py +4 -3
- streamlit/proto/Selectbox_pb2.pyi +9 -2
- streamlit/proto/TimeInput_pb2.py +4 -3
- streamlit/proto/TimeInput_pb2.pyi +9 -2
- streamlit/runtime/__init__.py +1 -1
- streamlit/runtime/caching/__init__.py +6 -6
- streamlit/runtime/caching/hashing.py +1 -1
- streamlit/runtime/connection_factory.py +1 -1
- streamlit/runtime/credentials.py +1 -1
- streamlit/runtime/scriptrunner/__init__.py +4 -4
- streamlit/runtime/scriptrunner/script_runner.py +3 -6
- streamlit/runtime/secrets.py +1 -1
- streamlit/runtime/state/__init__.py +5 -5
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{ErrorOutline.esm.Bi4rIKce.js → ErrorOutline.esm.BgsGCsV4.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.CgcfJ7jp.js → FileDownload.esm.CCKezPn5.js} +1 -1
- streamlit/static/static/js/{FileHelper.DNojV8Y-.js → FileHelper.CprSF_kT.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.Dj9cIjIB.js → FormClearHelper.DiwQ0EtT.js} +1 -1
- streamlit/static/static/js/{Hooks.BzFUZ6MJ.js → Hooks.DDqhyZ1_.js} +1 -1
- streamlit/static/static/js/{InputInstructions.CYPXcx5I.js → InputInstructions.BCEZxme4.js} +1 -1
- streamlit/static/static/js/{ProgressBar.ZaslM_lv.js → ProgressBar.CGdY94g_.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.BuhqVIo4.js → RenderInPortalIfExists.uGJp_Q0v.js} +1 -1
- streamlit/static/static/js/{Toolbar.Dh9Ti0Xp.js → Toolbar.hTlw0-K1.js} +1 -1
- streamlit/static/static/js/{base-input.CWmg0piT.js → base-input.mGTY3-qU.js} +1 -1
- streamlit/static/static/js/{checkbox.B55PmSuL.js → checkbox.Cg-5cKAh.js} +1 -1
- streamlit/static/static/js/{createSuper.B_ZYGAdZ.js → createSuper.-HPb1oYT.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.BC3_SI0J.js → data-grid-overlay-editor.BpNYxiTp.js} +1 -1
- streamlit/static/static/js/{downloader.DCVryQ8m.js → downloader.DS9891pS.js} +1 -1
- streamlit/static/static/js/{es6.Dz_yB5z2.js → es6.CU1PEL2w.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.BL9oGsv0.js → iframeResizer.contentWindow.CgJE2bJN.js} +1 -1
- streamlit/static/static/js/{index.Dk4s-H9g.js → index.B209tswL.js} +1 -1
- streamlit/static/static/js/{index.DsUIRBrE.js → index.BC0ueJ8H.js} +1 -1
- streamlit/static/static/js/{index.B2rrdjSM.js → index.BHVQ94t4.js} +1 -1
- streamlit/static/static/js/{index.n-3bctcT.js → index.BT0p7gAu.js} +1 -1
- streamlit/static/static/js/{index.DJXE7AM9.js → index.BTTj6ld4.js} +1 -1
- streamlit/static/static/js/{index.BTniWQ7k.js → index.BVjgrQ4R.js} +1 -1
- streamlit/static/static/js/{index.CEtbVfDc.js → index.BXYstdPh.js} +1 -1
- streamlit/static/static/js/{index.CnBJWuqh.js → index.BZ9mqzEJ.js} +1 -1
- streamlit/static/static/js/{index.DX5LBKpa.js → index.Bb-Ukg41.js} +1 -1
- streamlit/static/static/js/{index.149XmMwk.js → index.BhTok8vt.js} +1 -1
- streamlit/static/static/js/{index.CNMeZMWE.js → index.Bph6ZoI5.js} +1 -1
- streamlit/static/static/js/{index.Cim9S8Ss.js → index.CJPcdxPe.js} +1 -1
- streamlit/static/static/js/{index.DB8lzSwd.js → index.CMOA-8Q2.js} +1 -1
- streamlit/static/static/js/{index.BKWZKL08.js → index.CN91oQMB.js} +5 -5
- streamlit/static/static/js/{index.Bkh6Uq46.js → index.CtoDsUtq.js} +1 -1
- streamlit/static/static/js/{index.Bw1GLRoJ.js → index.CvFsF3FD.js} +1 -1
- streamlit/static/static/js/{index.xXFNtMRp.js → index.CyGuL4If.js} +1 -1
- streamlit/static/static/js/{index.B8bKQXh9.js → index.CzGUd4IN.js} +1 -1
- streamlit/static/static/js/{index.CLm1vyQL.js → index.DAxf3_iz.js} +1 -1
- streamlit/static/static/js/{index.Bjv3WjfL.js → index.DJHUlWgy.js} +1 -1
- streamlit/static/static/js/{index.CqhFhCXO.js → index.DLTqo4pp.js} +1 -1
- streamlit/static/static/js/{index.B6Lkujkg.js → index.DPJBu2uZ.js} +1 -1
- streamlit/static/static/js/{index.B71v2qvG.js → index.DVpzZJNg.js} +1 -1
- streamlit/static/static/js/{index.DXNwUj37.js → index.DWV80Vyw.js} +1 -1
- streamlit/static/static/js/{index.C1Onnqgx.js → index.DZ6oX-v9.js} +5 -5
- streamlit/static/static/js/{index.JBn4qgd8.js → index.Dh4RKl-F.js} +1 -1
- streamlit/static/static/js/{index.C5Bk4I5D.js → index.Dn76KVNf.js} +1 -1
- streamlit/static/static/js/{index.BL9ZervX.js → index.DtqvdV-p.js} +1 -1
- streamlit/static/static/js/{index.DGQq6N06.js → index.ErkF0SoX.js} +1 -1
- streamlit/static/static/js/{index.Clgb-C0M.js → index.GSYBrzVp.js} +1 -1
- streamlit/static/static/js/{index.Bi2P2smS.js → index.OngWTN39.js} +1 -1
- streamlit/static/static/js/{index.poyxGVIV.js → index.PSwG8ayC.js} +1 -1
- streamlit/static/static/js/{index.C9t2WUik.js → index.UTlCdasa.js} +1 -1
- streamlit/static/static/js/{index.DBjodTv0.js → index.eR_vQpeg.js} +1 -1
- streamlit/static/static/js/{index.ZM4hBepQ.js → index.fLsU9uCJ.js} +1 -1
- streamlit/static/static/js/{index.CKlQXXH5.js → index.hPjr68pz.js} +1 -1
- streamlit/static/static/js/{index.B4dHtLlL.js → index.kXOZCC_6.js} +1 -1
- streamlit/static/static/js/{input.tN5HMxoF.js → input.DY17i94N.js} +1 -1
- streamlit/static/static/js/{memory.CUqn-HRH.js → memory.DsIIcbSd.js} +1 -1
- streamlit/static/static/js/{mergeWith.DerBQcY2.js → mergeWith.cRgGdgvI.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.BU-PumD0.js → number-overlay-editor.B8Xi2dYq.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.BqXvihmp.js → possibleConstructorReturn.BgDi5nUm.js} +1 -1
- streamlit/static/static/js/{sandbox.DEPmvMZ8.js → sandbox.BH9emp13.js} +1 -1
- streamlit/static/static/js/{textarea.DTRZkwAk.js → textarea.DAyShsGG.js} +1 -1
- streamlit/static/static/js/{timepicker.BkL0oPvT.js → timepicker.CCH2R2Y0.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.DtI7t_Vr.js → toConsumableArray.CNffSDCu.js} +1 -1
- streamlit/static/static/js/{uniqueId.CBIMIugU.js → uniqueId.B49CstkV.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.CBoFkKUi.js → useBasicWidgetState.CkThOkF9.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.B59UtP7h.js → useOnInputChange.BqEq0xFZ.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.BaWUpTVz.js → withFullScreenWrapper.UsvF_Jwr.js} +1 -1
- streamlit/web/bootstrap.py +3 -2
- streamlit/web/server/__init__.py +2 -2
- {streamlit_nightly-1.45.1.dev20250503.dist-info → streamlit_nightly-1.45.1.dev20250505.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.45.1.dev20250503.dist-info → streamlit_nightly-1.45.1.dev20250505.dist-info}/RECORD +108 -108
- {streamlit_nightly-1.45.1.dev20250503.dist-info → streamlit_nightly-1.45.1.dev20250505.dist-info}/WHEEL +1 -1
- {streamlit_nightly-1.45.1.dev20250503.data → streamlit_nightly-1.45.1.dev20250505.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.45.1.dev20250503.dist-info → streamlit_nightly-1.45.1.dev20250505.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.45.1.dev20250503.dist-info → streamlit_nightly-1.45.1.dev20250505.dist-info}/top_level.txt +0 -0
streamlit/column_config.py
CHANGED
@@ -18,21 +18,21 @@ from __future__ import annotations
|
|
18
18
|
|
19
19
|
__all__ = [
|
20
20
|
"AreaChartColumn",
|
21
|
-
"Column",
|
22
|
-
"TextColumn",
|
23
|
-
"NumberColumn",
|
24
21
|
"BarChartColumn",
|
25
22
|
"CheckboxColumn",
|
23
|
+
"Column",
|
24
|
+
"DateColumn",
|
26
25
|
"DatetimeColumn",
|
27
26
|
"ImageColumn",
|
28
|
-
"
|
29
|
-
"ProgressColumn",
|
30
|
-
"LinkColumn",
|
27
|
+
"JsonColumn",
|
31
28
|
"LineChartColumn",
|
29
|
+
"LinkColumn",
|
32
30
|
"ListColumn",
|
33
|
-
"
|
31
|
+
"NumberColumn",
|
32
|
+
"ProgressColumn",
|
33
|
+
"SelectboxColumn",
|
34
|
+
"TextColumn",
|
34
35
|
"TimeColumn",
|
35
|
-
"JsonColumn",
|
36
36
|
]
|
37
37
|
|
38
38
|
|
@@ -90,11 +90,8 @@ def _new_fragment_id_queue(
|
|
90
90
|
"functions during fragment reruns."
|
91
91
|
)
|
92
92
|
|
93
|
-
|
94
|
-
|
95
|
-
dropwhile(lambda x: x != ctx.current_fragment_id, curr_queue)
|
96
|
-
)
|
97
|
-
), (
|
93
|
+
new_queue = list(dropwhile(lambda x: x != ctx.current_fragment_id, curr_queue))
|
94
|
+
assert new_queue, (
|
98
95
|
"Could not find current_fragment_id in fragment_id_queue. This should never happen."
|
99
96
|
)
|
100
97
|
|
streamlit/delta_generator.py
CHANGED
@@ -284,7 +284,7 @@ class DeltaGenerator(
|
|
284
284
|
|
285
285
|
def __enter__(self) -> None:
|
286
286
|
# with block started
|
287
|
-
context_dg_stack.set(context_dg_stack.get()
|
287
|
+
context_dg_stack.set((*context_dg_stack.get(), self))
|
288
288
|
|
289
289
|
def __exit__(
|
290
290
|
self,
|
@@ -530,7 +530,7 @@ class DeltaGenerator(
|
|
530
530
|
# a brand new cursor for this new block we're creating.
|
531
531
|
block_cursor = cursor.RunningCursor(
|
532
532
|
root_container=dg._root_container,
|
533
|
-
parent_path=dg._cursor.parent_path
|
533
|
+
parent_path=(*dg._cursor.parent_path, dg._cursor.index),
|
534
534
|
)
|
535
535
|
|
536
536
|
# `dg_type` param added for st.status container. It allows us to
|
streamlit/elements/alert.py
CHANGED
streamlit/elements/json.py
CHANGED
@@ -134,7 +134,7 @@ class JsonMixin:
|
|
134
134
|
json_proto.max_expand_depth = expanded
|
135
135
|
else:
|
136
136
|
raise TypeError(
|
137
|
-
f"The type {
|
137
|
+
f"The type {type(expanded)} of `expanded` is not supported"
|
138
138
|
", must be bool or int."
|
139
139
|
)
|
140
140
|
|
@@ -74,11 +74,19 @@ class AddRowsMetadata:
|
|
74
74
|
|
75
75
|
|
76
76
|
class ChartType(Enum):
|
77
|
-
AREA = {"mark_type": "area", "command": "area_chart"}
|
78
|
-
VERTICAL_BAR = {
|
79
|
-
|
80
|
-
|
81
|
-
|
77
|
+
AREA: Final = {"mark_type": "area", "command": "area_chart"}
|
78
|
+
VERTICAL_BAR: Final = {
|
79
|
+
"mark_type": "bar",
|
80
|
+
"command": "bar_chart",
|
81
|
+
"horizontal": False,
|
82
|
+
}
|
83
|
+
HORIZONTAL_BAR: Final = {
|
84
|
+
"mark_type": "bar",
|
85
|
+
"command": "bar_chart",
|
86
|
+
"horizontal": True,
|
87
|
+
}
|
88
|
+
LINE: Final = {"mark_type": "line", "command": "line_chart"}
|
89
|
+
SCATTER: Final = {"mark_type": "circle", "command": "scatter_chart"}
|
82
90
|
|
83
91
|
|
84
92
|
# Color and size legends need different title paddings in order for them
|
@@ -1035,7 +1043,7 @@ def _get_size_encoding(
|
|
1035
1043
|
return alt.SizeValue(100)
|
1036
1044
|
else:
|
1037
1045
|
raise StreamlitAPIException(
|
1038
|
-
f"This does not look like a valid size: {
|
1046
|
+
f"This does not look like a valid size: {size_value!r}"
|
1039
1047
|
)
|
1040
1048
|
|
1041
1049
|
elif size_column is not None or size_value is not None:
|
@@ -509,9 +509,7 @@ def _convert_column_config_to_json(column_config_mapping: ColumnConfigMapping) -
|
|
509
509
|
# Ignore all None values and prefix columns specified by numerical index:
|
510
510
|
return json.dumps(
|
511
511
|
{
|
512
|
-
(
|
513
|
-
f"{_NUMERICAL_POSITION_PREFIX}{str(k)}" if isinstance(k, int) else k
|
514
|
-
): v
|
512
|
+
(f"{_NUMERICAL_POSITION_PREFIX}{k!s}" if isinstance(k, int) else k): v
|
515
513
|
for (k, v) in remove_none_values(column_config_mapping).items()
|
516
514
|
},
|
517
515
|
allow_nan=False,
|
@@ -59,9 +59,14 @@ def enforce_filename_restriction(filename: str, allowed_types: Sequence[str]) ->
|
|
59
59
|
enforce file type check by extension on the frontend, but we check it on backend
|
60
60
|
before returning file to the user to protect ourselves.
|
61
61
|
"""
|
62
|
-
|
62
|
+
normalized_filename = filename.lower()
|
63
|
+
base_name, extension = os.path.splitext(normalized_filename)
|
64
|
+
normalized_allowed_types = [allowed_type.lower() for allowed_type in allowed_types]
|
63
65
|
|
64
|
-
if not any(
|
66
|
+
if not any(
|
67
|
+
normalized_filename.endswith(allowed_type)
|
68
|
+
for allowed_type in normalized_allowed_types
|
69
|
+
):
|
65
70
|
raise StreamlitAPIException(
|
66
71
|
f"Invalid file extension: `{extension}`. Allowed: {allowed_types}"
|
67
72
|
)
|
@@ -57,7 +57,7 @@ def index_(iterable: Iterable[_Value], x: _Value) -> int:
|
|
57
57
|
elif isinstance(value, float) and isinstance(x, float):
|
58
58
|
if abs(x - value) < _FLOAT_EQUALITY_EPSILON:
|
59
59
|
return i
|
60
|
-
raise ValueError(f"{
|
60
|
+
raise ValueError(f"{x} is not in iterable")
|
61
61
|
|
62
62
|
|
63
63
|
def check_and_convert_to_indices(
|
streamlit/elements/metric.py
CHANGED
@@ -214,7 +214,7 @@ class MetricMixin:
|
|
214
214
|
def _parse_label(label: str) -> str:
|
215
215
|
if not isinstance(label, str):
|
216
216
|
raise TypeError(
|
217
|
-
f"'{
|
217
|
+
f"'{label}' is of type {type(label)}, which is not an accepted type."
|
218
218
|
" label only accepts: str. Please convert the label to an accepted type."
|
219
219
|
)
|
220
220
|
return label
|
@@ -236,7 +236,7 @@ def _parse_value(value: Value) -> str:
|
|
236
236
|
pass
|
237
237
|
|
238
238
|
raise TypeError(
|
239
|
-
f"'{
|
239
|
+
f"'{value}' is of type {type(value)}, which is not an accepted type."
|
240
240
|
" value only accepts: int, float, str, or None."
|
241
241
|
" Please convert the value to an accepted type."
|
242
242
|
)
|
@@ -251,7 +251,7 @@ def _parse_delta(delta: Delta) -> str:
|
|
251
251
|
return str(delta)
|
252
252
|
else:
|
253
253
|
raise TypeError(
|
254
|
-
f"'{
|
254
|
+
f"'{delta}' is of type {type(delta)}, which is not an accepted type."
|
255
255
|
" delta only accepts: int, float, str, or None."
|
256
256
|
" Please convert the value to an accepted type."
|
257
257
|
)
|
@@ -263,7 +263,7 @@ def _determine_delta_color_and_direction(
|
|
263
263
|
) -> MetricColorAndDirection:
|
264
264
|
if delta_color not in {"normal", "inverse", "off"}:
|
265
265
|
raise StreamlitAPIException(
|
266
|
-
f"'{
|
266
|
+
f"'{delta_color}' is not an accepted value. delta_color only accepts: "
|
267
267
|
"'normal', 'inverse', or 'off'"
|
268
268
|
)
|
269
269
|
|
streamlit/elements/progress.py
CHANGED
@@ -89,7 +89,7 @@ def _get_text(text: str | None) -> str | None:
|
|
89
89
|
if isinstance(text, str):
|
90
90
|
return clean_text(text)
|
91
91
|
raise StreamlitAPIException(
|
92
|
-
f"Progress Text is of type {
|
92
|
+
f"Progress Text is of type {type(text)}, which is not an accepted type."
|
93
93
|
"Text only accepts: str. Please convert the text to an accepted type."
|
94
94
|
)
|
95
95
|
|
@@ -23,6 +23,7 @@ from typing_extensions import TypeAlias
|
|
23
23
|
|
24
24
|
from streamlit.elements.lib.form_utils import current_form_id
|
25
25
|
from streamlit.elements.lib.js_number import JSNumber, JSNumberBoundsException
|
26
|
+
from streamlit.elements.lib.layout_utils import WidthWithoutContent, validate_width
|
26
27
|
from streamlit.elements.lib.policies import (
|
27
28
|
check_widget_policies,
|
28
29
|
maybe_raise_label_warnings,
|
@@ -42,6 +43,7 @@ from streamlit.errors import (
|
|
42
43
|
StreamlitValueBelowMinError,
|
43
44
|
)
|
44
45
|
from streamlit.proto.NumberInput_pb2 import NumberInput as NumberInputProto
|
46
|
+
from streamlit.proto.WidthConfig_pb2 import WidthConfig
|
45
47
|
from streamlit.runtime.metrics_util import gather_metrics
|
46
48
|
from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
|
47
49
|
from streamlit.runtime.state import (
|
@@ -96,7 +98,7 @@ class NumberInputMixin:
|
|
96
98
|
max_value: int | None = None,
|
97
99
|
value: IntOrNone | Literal["min"] = "min",
|
98
100
|
step: int | None = None,
|
99
|
-
format: str | None = None, key: Key | None = None, help: str | None = None, on_change: WidgetCallback | None = None, args: WidgetArgs | None = None, kwargs: WidgetKwargs | None = None, *, placeholder: str | None = None, disabled: bool = False, label_visibility: LabelVisibility = "visible", icon: str | None = None
|
101
|
+
format: str | None = None, key: Key | None = None, help: str | None = None, on_change: WidgetCallback | None = None, args: WidgetArgs | None = None, kwargs: WidgetKwargs | None = None, *, placeholder: str | None = None, disabled: bool = False, label_visibility: LabelVisibility = "visible", icon: str | None = None, width: WidthWithoutContent = "stretch"
|
100
102
|
) -> int | IntOrNone:
|
101
103
|
...
|
102
104
|
|
@@ -113,7 +115,7 @@ class NumberInputMixin:
|
|
113
115
|
max_value: int,
|
114
116
|
value: IntOrNone | Literal["min"] = "min",
|
115
117
|
step: int | None = None,
|
116
|
-
format: str | None = None, key: Key | None = None, help: str | None = None, on_change: WidgetCallback | None = None, args: WidgetArgs | None = None, kwargs: WidgetKwargs | None = None, placeholder: str | None = None, disabled: bool = False, label_visibility: LabelVisibility = "visible", icon: str | None = None
|
118
|
+
format: str | None = None, key: Key | None = None, help: str | None = None, on_change: WidgetCallback | None = None, args: WidgetArgs | None = None, kwargs: WidgetKwargs | None = None, placeholder: str | None = None, disabled: bool = False, label_visibility: LabelVisibility = "visible", icon: str | None = None, width: WidthWithoutContent = "stretch"
|
117
119
|
) -> int | IntOrNone:
|
118
120
|
...
|
119
121
|
|
@@ -128,7 +130,7 @@ class NumberInputMixin:
|
|
128
130
|
*,
|
129
131
|
value: int,
|
130
132
|
step: int | None = None,
|
131
|
-
format: str | None = None, key: Key | None = None, help: str | None = None, on_change: WidgetCallback | None = None, args: WidgetArgs | None = None, kwargs: WidgetKwargs | None = None, placeholder: str | None = None, disabled: bool = False, label_visibility: LabelVisibility = "visible", icon: str | None = None
|
133
|
+
format: str | None = None, key: Key | None = None, help: str | None = None, on_change: WidgetCallback | None = None, args: WidgetArgs | None = None, kwargs: WidgetKwargs | None = None, placeholder: str | None = None, disabled: bool = False, label_visibility: LabelVisibility = "visible", icon: str | None = None, width: WidthWithoutContent = "stretch"
|
132
134
|
) -> int:
|
133
135
|
...
|
134
136
|
|
@@ -145,7 +147,7 @@ class NumberInputMixin:
|
|
145
147
|
value: IntOrNone | Literal["min"] = "min",
|
146
148
|
*,
|
147
149
|
step: int,
|
148
|
-
format: str | None = None, key: Key | None = None, help: str | None = None, on_change: WidgetCallback | None = None, args: WidgetArgs | None = None, kwargs: WidgetKwargs | None = None, placeholder: str | None = None, disabled: bool = False, label_visibility: LabelVisibility = "visible", icon: str | None = None
|
150
|
+
format: str | None = None, key: Key | None = None, help: str | None = None, on_change: WidgetCallback | None = None, args: WidgetArgs | None = None, kwargs: WidgetKwargs | None = None, placeholder: str | None = None, disabled: bool = False, label_visibility: LabelVisibility = "visible", icon: str | None = None, width: WidthWithoutContent = "stretch"
|
149
151
|
) -> int | IntOrNone:
|
150
152
|
...
|
151
153
|
|
@@ -161,7 +163,7 @@ class NumberInputMixin:
|
|
161
163
|
max_value: float | None = None,
|
162
164
|
value: FloatOrNone | Literal["min"] = "min",
|
163
165
|
step: float | None = None,
|
164
|
-
format: str | None = None, key: Key | None = None, help: str | None = None, on_change: WidgetCallback | None = None, args: WidgetArgs | None = None, kwargs: WidgetKwargs | None = None, *, placeholder: str | None = None, disabled: bool = False, label_visibility: LabelVisibility = "visible", icon: str | None = None
|
166
|
+
format: str | None = None, key: Key | None = None, help: str | None = None, on_change: WidgetCallback | None = None, args: WidgetArgs | None = None, kwargs: WidgetKwargs | None = None, *, placeholder: str | None = None, disabled: bool = False, label_visibility: LabelVisibility = "visible", icon: str | None = None, width: WidthWithoutContent = "stretch"
|
165
167
|
) -> float | FloatOrNone:
|
166
168
|
...
|
167
169
|
# # fmt: on
|
@@ -185,6 +187,7 @@ class NumberInputMixin:
|
|
185
187
|
disabled: bool = False,
|
186
188
|
label_visibility: LabelVisibility = "visible",
|
187
189
|
icon: str | None = None,
|
190
|
+
width: WidthWithoutContent = "stretch",
|
188
191
|
) -> Number | None:
|
189
192
|
r"""Display a numeric input widget.
|
190
193
|
|
@@ -307,6 +310,9 @@ class NumberInputMixin:
|
|
307
310
|
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
|
308
311
|
font library.
|
309
312
|
|
313
|
+
width : WidthWithoutContent
|
314
|
+
The width of the number input. Can be an integer or "stretch". Defaults to "stretch".
|
315
|
+
|
310
316
|
Returns
|
311
317
|
-------
|
312
318
|
int or float or None
|
@@ -355,6 +361,7 @@ class NumberInputMixin:
|
|
355
361
|
disabled=disabled,
|
356
362
|
label_visibility=label_visibility,
|
357
363
|
icon=icon,
|
364
|
+
width=width,
|
358
365
|
ctx=ctx,
|
359
366
|
)
|
360
367
|
|
@@ -376,6 +383,7 @@ class NumberInputMixin:
|
|
376
383
|
disabled: bool = False,
|
377
384
|
label_visibility: LabelVisibility = "visible",
|
378
385
|
icon: str | None = None,
|
386
|
+
width: WidthWithoutContent = "stretch",
|
379
387
|
ctx: ScriptRunContext | None = None,
|
380
388
|
) -> Number | None:
|
381
389
|
key = to_key(key)
|
@@ -387,6 +395,7 @@ class NumberInputMixin:
|
|
387
395
|
default_value=value if value != "min" else None,
|
388
396
|
)
|
389
397
|
maybe_raise_label_warnings(label, label_visibility)
|
398
|
+
validate_width(width)
|
390
399
|
|
391
400
|
element_id = compute_and_register_element_id(
|
392
401
|
"number_input",
|
@@ -401,6 +410,7 @@ class NumberInputMixin:
|
|
401
410
|
help=help,
|
402
411
|
placeholder=None if placeholder is None else str(placeholder),
|
403
412
|
icon=icon,
|
413
|
+
width=width,
|
404
414
|
)
|
405
415
|
|
406
416
|
# Ensure that all arguments are of the same type.
|
@@ -552,6 +562,14 @@ class NumberInputMixin:
|
|
552
562
|
if icon is not None:
|
553
563
|
number_input_proto.icon = validate_icon_or_emoji(icon)
|
554
564
|
|
565
|
+
# Set up width configuration
|
566
|
+
width_config = WidthConfig()
|
567
|
+
if isinstance(width, int):
|
568
|
+
width_config.pixel_width = width
|
569
|
+
else:
|
570
|
+
width_config.use_stretch = True
|
571
|
+
number_input_proto.width_config.CopyFrom(width_config)
|
572
|
+
|
555
573
|
serde = NumberInputSerde(value, data_type)
|
556
574
|
widget_state = register_widget(
|
557
575
|
number_input_proto.id,
|
@@ -18,6 +18,7 @@ from typing import TYPE_CHECKING, Any, Callable, Generic, Literal, cast, overloa
|
|
18
18
|
|
19
19
|
from streamlit.dataframe_util import OptionSequence, convert_anything_to_list
|
20
20
|
from streamlit.elements.lib.form_utils import current_form_id
|
21
|
+
from streamlit.elements.lib.layout_utils import WidthWithoutContent, validate_width
|
21
22
|
from streamlit.elements.lib.options_selector_utils import (
|
22
23
|
create_mappings,
|
23
24
|
index_,
|
@@ -37,6 +38,7 @@ from streamlit.elements.lib.utils import (
|
|
37
38
|
)
|
38
39
|
from streamlit.errors import StreamlitAPIException
|
39
40
|
from streamlit.proto.Selectbox_pb2 import Selectbox as SelectboxProto
|
41
|
+
from streamlit.proto.WidthConfig_pb2 import WidthConfig
|
40
42
|
from streamlit.runtime.metrics_util import gather_metrics
|
41
43
|
from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
|
42
44
|
from streamlit.runtime.state import (
|
@@ -147,6 +149,7 @@ class SelectboxMixin:
|
|
147
149
|
disabled: bool = False,
|
148
150
|
label_visibility: LabelVisibility = "visible",
|
149
151
|
accept_new_options: Literal[False] = False,
|
152
|
+
width: WidthWithoutContent = "stretch",
|
150
153
|
) -> T: ...
|
151
154
|
|
152
155
|
@overload
|
@@ -166,6 +169,7 @@ class SelectboxMixin:
|
|
166
169
|
disabled: bool = False,
|
167
170
|
label_visibility: LabelVisibility = "visible",
|
168
171
|
accept_new_options: Literal[True] = True,
|
172
|
+
width: WidthWithoutContent = "stretch",
|
169
173
|
) -> T | str: ...
|
170
174
|
|
171
175
|
@overload
|
@@ -185,6 +189,7 @@ class SelectboxMixin:
|
|
185
189
|
disabled: bool = False,
|
186
190
|
label_visibility: LabelVisibility = "visible",
|
187
191
|
accept_new_options: Literal[False] = False,
|
192
|
+
width: WidthWithoutContent = "stretch",
|
188
193
|
) -> T | None: ...
|
189
194
|
|
190
195
|
@overload
|
@@ -204,6 +209,7 @@ class SelectboxMixin:
|
|
204
209
|
disabled: bool = False,
|
205
210
|
label_visibility: LabelVisibility = "visible",
|
206
211
|
accept_new_options: Literal[True] = True,
|
212
|
+
width: WidthWithoutContent = "stretch",
|
207
213
|
) -> T | str | None: ...
|
208
214
|
|
209
215
|
@overload
|
@@ -223,6 +229,7 @@ class SelectboxMixin:
|
|
223
229
|
disabled: bool = False,
|
224
230
|
label_visibility: LabelVisibility = "visible",
|
225
231
|
accept_new_options: bool = False,
|
232
|
+
width: WidthWithoutContent = "stretch",
|
226
233
|
) -> T | str | None: ...
|
227
234
|
|
228
235
|
@gather_metrics("selectbox")
|
@@ -242,6 +249,7 @@ class SelectboxMixin:
|
|
242
249
|
disabled: bool = False,
|
243
250
|
label_visibility: LabelVisibility = "visible",
|
244
251
|
accept_new_options: bool = False,
|
252
|
+
width: WidthWithoutContent = "stretch",
|
245
253
|
) -> T | str | None:
|
246
254
|
r"""Display a select widget.
|
247
255
|
|
@@ -340,6 +348,11 @@ class SelectboxMixin:
|
|
340
348
|
Streamlit will use a case-insensitive match from ``options`` before
|
341
349
|
adding a new item.
|
342
350
|
|
351
|
+
width : "stretch" or int
|
352
|
+
The width of the selectbox. If "stretch", the selectbox will stretch
|
353
|
+
to fill the available space. If a number, the selectbox will have a
|
354
|
+
fixed width of that many pixels. Defaults to "stretch".
|
355
|
+
|
343
356
|
Returns
|
344
357
|
-------
|
345
358
|
any
|
@@ -421,6 +434,7 @@ class SelectboxMixin:
|
|
421
434
|
disabled=disabled,
|
422
435
|
label_visibility=label_visibility,
|
423
436
|
accept_new_options=accept_new_options,
|
437
|
+
width=width,
|
424
438
|
ctx=ctx,
|
425
439
|
)
|
426
440
|
|
@@ -440,6 +454,7 @@ class SelectboxMixin:
|
|
440
454
|
disabled: bool = False,
|
441
455
|
label_visibility: LabelVisibility = "visible",
|
442
456
|
accept_new_options: bool = False,
|
457
|
+
width: WidthWithoutContent = "stretch",
|
443
458
|
ctx: ScriptRunContext | None = None,
|
444
459
|
) -> T | str | None:
|
445
460
|
key = to_key(key)
|
@@ -451,6 +466,7 @@ class SelectboxMixin:
|
|
451
466
|
default_value=None if index == 0 else index,
|
452
467
|
)
|
453
468
|
maybe_raise_label_warnings(label, label_visibility)
|
469
|
+
validate_width(width)
|
454
470
|
|
455
471
|
opt = convert_anything_to_list(options)
|
456
472
|
check_python_comparable(opt)
|
@@ -487,6 +503,7 @@ class SelectboxMixin:
|
|
487
503
|
help=help,
|
488
504
|
placeholder=placeholder,
|
489
505
|
accept_new_options=accept_new_options,
|
506
|
+
width=width,
|
490
507
|
)
|
491
508
|
|
492
509
|
session_state = get_session_state().filtered_state
|
@@ -510,6 +527,14 @@ class SelectboxMixin:
|
|
510
527
|
if help is not None:
|
511
528
|
selectbox_proto.help = dedent(help)
|
512
529
|
|
530
|
+
# Set up width configuration
|
531
|
+
width_config = WidthConfig()
|
532
|
+
if isinstance(width, int):
|
533
|
+
width_config.pixel_width = width
|
534
|
+
else:
|
535
|
+
width_config.use_stretch = True
|
536
|
+
selectbox_proto.width_config.CopyFrom(width_config)
|
537
|
+
|
513
538
|
serde = SelectboxSerde(
|
514
539
|
opt,
|
515
540
|
formatted_options=formatted_options,
|
@@ -31,6 +31,7 @@ from typing import (
|
|
31
31
|
from typing_extensions import TypeAlias
|
32
32
|
|
33
33
|
from streamlit.elements.lib.form_utils import current_form_id
|
34
|
+
from streamlit.elements.lib.layout_utils import WidthWithoutContent, validate_width
|
34
35
|
from streamlit.elements.lib.policies import (
|
35
36
|
check_widget_policies,
|
36
37
|
maybe_raise_label_warnings,
|
@@ -45,6 +46,7 @@ from streamlit.elements.lib.utils import (
|
|
45
46
|
from streamlit.errors import StreamlitAPIException
|
46
47
|
from streamlit.proto.DateInput_pb2 import DateInput as DateInputProto
|
47
48
|
from streamlit.proto.TimeInput_pb2 import TimeInput as TimeInputProto
|
49
|
+
from streamlit.proto.WidthConfig_pb2 import WidthConfig
|
48
50
|
from streamlit.runtime.metrics_util import gather_metrics
|
49
51
|
from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
|
50
52
|
from streamlit.runtime.state import (
|
@@ -321,6 +323,7 @@ class TimeWidgetsMixin:
|
|
321
323
|
disabled: bool = False,
|
322
324
|
label_visibility: LabelVisibility = "visible",
|
323
325
|
step: int | timedelta = timedelta(minutes=DEFAULT_STEP_MINUTES),
|
326
|
+
width: WidthWithoutContent = "stretch",
|
324
327
|
) -> time:
|
325
328
|
pass
|
326
329
|
|
@@ -338,6 +341,7 @@ class TimeWidgetsMixin:
|
|
338
341
|
disabled: bool = False,
|
339
342
|
label_visibility: LabelVisibility = "visible",
|
340
343
|
step: int | timedelta = timedelta(minutes=DEFAULT_STEP_MINUTES),
|
344
|
+
width: WidthWithoutContent = "stretch",
|
341
345
|
) -> time | None:
|
342
346
|
pass
|
343
347
|
|
@@ -355,6 +359,7 @@ class TimeWidgetsMixin:
|
|
355
359
|
disabled: bool = False,
|
356
360
|
label_visibility: LabelVisibility = "visible",
|
357
361
|
step: int | timedelta = timedelta(minutes=DEFAULT_STEP_MINUTES),
|
362
|
+
width: WidthWithoutContent = "stretch",
|
358
363
|
) -> time | None:
|
359
364
|
r"""Display a time input widget.
|
360
365
|
|
@@ -432,6 +437,11 @@ class TimeWidgetsMixin:
|
|
432
437
|
The stepping interval in seconds. Defaults to 900, i.e. 15 minutes.
|
433
438
|
You can also pass a datetime.timedelta object.
|
434
439
|
|
440
|
+
width : "stretch" or int
|
441
|
+
The width of the time input. If "stretch", the time input will stretch
|
442
|
+
to fill the available space. If a number, the time input will have a
|
443
|
+
fixed width of that many pixels. Defaults to "stretch".
|
444
|
+
|
435
445
|
Returns
|
436
446
|
-------
|
437
447
|
datetime.time or None
|
@@ -475,6 +485,7 @@ class TimeWidgetsMixin:
|
|
475
485
|
disabled=disabled,
|
476
486
|
label_visibility=label_visibility,
|
477
487
|
step=step,
|
488
|
+
width=width,
|
478
489
|
ctx=ctx,
|
479
490
|
)
|
480
491
|
|
@@ -491,6 +502,7 @@ class TimeWidgetsMixin:
|
|
491
502
|
disabled: bool = False,
|
492
503
|
label_visibility: LabelVisibility = "visible",
|
493
504
|
step: int | timedelta = timedelta(minutes=DEFAULT_STEP_MINUTES),
|
505
|
+
width: WidthWithoutContent = "stretch",
|
494
506
|
ctx: ScriptRunContext | None = None,
|
495
507
|
) -> time | None:
|
496
508
|
key = to_key(key)
|
@@ -502,6 +514,7 @@ class TimeWidgetsMixin:
|
|
502
514
|
default_value=value if value != "now" else None,
|
503
515
|
)
|
504
516
|
maybe_raise_label_warnings(label, label_visibility)
|
517
|
+
validate_width(width)
|
505
518
|
|
506
519
|
parsed_time: time | None
|
507
520
|
if value is None:
|
@@ -517,6 +530,7 @@ class TimeWidgetsMixin:
|
|
517
530
|
value=parsed_time if isinstance(value, (datetime, time)) else value,
|
518
531
|
help=help,
|
519
532
|
step=step,
|
533
|
+
width=width,
|
520
534
|
)
|
521
535
|
del value
|
522
536
|
|
@@ -549,6 +563,14 @@ class TimeWidgetsMixin:
|
|
549
563
|
if help is not None:
|
550
564
|
time_input_proto.help = dedent(help)
|
551
565
|
|
566
|
+
# Set up width configuration
|
567
|
+
width_config = WidthConfig()
|
568
|
+
if isinstance(width, int):
|
569
|
+
width_config.pixel_width = width
|
570
|
+
else:
|
571
|
+
width_config.use_stretch = True
|
572
|
+
time_input_proto.width_config.CopyFrom(width_config)
|
573
|
+
|
552
574
|
serde = TimeInputSerde(parsed_time)
|
553
575
|
widget_state = register_widget(
|
554
576
|
time_input_proto.id,
|
@@ -585,6 +607,7 @@ class TimeWidgetsMixin:
|
|
585
607
|
format: str = "YYYY/MM/DD",
|
586
608
|
disabled: bool = False,
|
587
609
|
label_visibility: LabelVisibility = "visible",
|
610
|
+
width: WidthWithoutContent = "stretch",
|
588
611
|
) -> date: ...
|
589
612
|
|
590
613
|
@overload
|
@@ -603,6 +626,7 @@ class TimeWidgetsMixin:
|
|
603
626
|
format: str = "YYYY/MM/DD",
|
604
627
|
disabled: bool = False,
|
605
628
|
label_visibility: LabelVisibility = "visible",
|
629
|
+
width: WidthWithoutContent = "stretch",
|
606
630
|
) -> date | None: ...
|
607
631
|
|
608
632
|
@overload
|
@@ -623,6 +647,7 @@ class TimeWidgetsMixin:
|
|
623
647
|
format: str = "YYYY/MM/DD",
|
624
648
|
disabled: bool = False,
|
625
649
|
label_visibility: LabelVisibility = "visible",
|
650
|
+
width: WidthWithoutContent = "stretch",
|
626
651
|
) -> DateWidgetRangeReturn: ...
|
627
652
|
|
628
653
|
@gather_metrics("date_input")
|
@@ -641,6 +666,7 @@ class TimeWidgetsMixin:
|
|
641
666
|
format: str = "YYYY/MM/DD",
|
642
667
|
disabled: bool = False,
|
643
668
|
label_visibility: LabelVisibility = "visible",
|
669
|
+
width: WidthWithoutContent = "stretch",
|
644
670
|
) -> DateWidgetReturn:
|
645
671
|
r"""Display a date input widget.
|
646
672
|
|
@@ -748,6 +774,11 @@ class TimeWidgetsMixin:
|
|
748
774
|
label, which can help keep the widget alligned with other widgets.
|
749
775
|
If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
750
776
|
|
777
|
+
width : "stretch" or int
|
778
|
+
The width of the date input. If "stretch", the date input will stretch
|
779
|
+
to fill the available space. If a number, the date input will have a
|
780
|
+
fixed width of that many pixels. Defaults to "stretch".
|
781
|
+
|
751
782
|
Returns
|
752
783
|
-------
|
753
784
|
datetime.date or a tuple with 0-2 dates or None
|
@@ -814,6 +845,7 @@ class TimeWidgetsMixin:
|
|
814
845
|
disabled=disabled,
|
815
846
|
label_visibility=label_visibility,
|
816
847
|
format=format,
|
848
|
+
width=width,
|
817
849
|
ctx=ctx,
|
818
850
|
)
|
819
851
|
|
@@ -832,6 +864,7 @@ class TimeWidgetsMixin:
|
|
832
864
|
format: str = "YYYY/MM/DD",
|
833
865
|
disabled: bool = False,
|
834
866
|
label_visibility: LabelVisibility = "visible",
|
867
|
+
width: WidthWithoutContent = "stretch",
|
835
868
|
ctx: ScriptRunContext | None = None,
|
836
869
|
) -> DateWidgetReturn:
|
837
870
|
key = to_key(key)
|
@@ -843,6 +876,7 @@ class TimeWidgetsMixin:
|
|
843
876
|
default_value=value if value != "today" else None,
|
844
877
|
)
|
845
878
|
maybe_raise_label_warnings(label, label_visibility)
|
879
|
+
validate_width(width)
|
846
880
|
|
847
881
|
def parse_date_deterministic_for_id(v: NullableScalarDateValue) -> str | None:
|
848
882
|
if v == "today":
|
@@ -884,6 +918,7 @@ class TimeWidgetsMixin:
|
|
884
918
|
max_value=parsed_max_date,
|
885
919
|
help=help,
|
886
920
|
format=format,
|
921
|
+
width=width,
|
887
922
|
)
|
888
923
|
if not bool(ALLOWED_DATE_FORMATS.match(format)):
|
889
924
|
raise StreamlitAPIException(
|
@@ -941,6 +976,14 @@ class TimeWidgetsMixin:
|
|
941
976
|
if help is not None:
|
942
977
|
date_input_proto.help = dedent(help)
|
943
978
|
|
979
|
+
# Set up width configuration
|
980
|
+
width_config = WidthConfig()
|
981
|
+
if isinstance(width, int):
|
982
|
+
width_config.pixel_width = width
|
983
|
+
else:
|
984
|
+
width_config.use_stretch = True
|
985
|
+
date_input_proto.width_config.CopyFrom(width_config)
|
986
|
+
|
944
987
|
serde = DateInputSerde(parsed_values)
|
945
988
|
|
946
989
|
widget_state = register_widget(
|