streamlit-nightly 1.43.2.dev20250307__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 +306 -0
- streamlit/__main__.py +20 -0
- streamlit/auth_util.py +218 -0
- streamlit/cli_util.py +105 -0
- streamlit/column_config.py +56 -0
- streamlit/commands/__init__.py +13 -0
- streamlit/commands/echo.py +126 -0
- streamlit/commands/execution_control.py +238 -0
- streamlit/commands/experimental_query_params.py +169 -0
- streamlit/commands/logo.py +189 -0
- streamlit/commands/navigation.py +385 -0
- streamlit/commands/page_config.py +311 -0
- streamlit/components/__init__.py +13 -0
- streamlit/components/lib/__init__.py +13 -0
- streamlit/components/lib/local_component_registry.py +84 -0
- streamlit/components/types/__init__.py +13 -0
- streamlit/components/types/base_component_registry.py +99 -0
- streamlit/components/types/base_custom_component.py +150 -0
- streamlit/components/v1/__init__.py +31 -0
- streamlit/components/v1/component_arrow.py +141 -0
- streamlit/components/v1/component_registry.py +130 -0
- streamlit/components/v1/components.py +38 -0
- streamlit/components/v1/custom_component.py +243 -0
- streamlit/config.py +1513 -0
- streamlit/config_option.py +311 -0
- streamlit/config_util.py +177 -0
- streamlit/connections/__init__.py +28 -0
- streamlit/connections/base_connection.py +174 -0
- streamlit/connections/snowflake_connection.py +562 -0
- streamlit/connections/snowpark_connection.py +213 -0
- streamlit/connections/sql_connection.py +425 -0
- streamlit/connections/util.py +97 -0
- streamlit/cursor.py +210 -0
- streamlit/dataframe_util.py +1416 -0
- streamlit/delta_generator.py +602 -0
- streamlit/delta_generator_singletons.py +204 -0
- streamlit/deprecation_util.py +209 -0
- streamlit/development.py +21 -0
- streamlit/elements/__init__.py +13 -0
- streamlit/elements/alert.py +234 -0
- streamlit/elements/arrow.py +962 -0
- streamlit/elements/balloons.py +47 -0
- streamlit/elements/bokeh_chart.py +133 -0
- streamlit/elements/code.py +114 -0
- streamlit/elements/deck_gl_json_chart.py +546 -0
- streamlit/elements/dialog_decorator.py +267 -0
- streamlit/elements/doc_string.py +558 -0
- streamlit/elements/empty.py +130 -0
- streamlit/elements/exception.py +331 -0
- streamlit/elements/form.py +354 -0
- streamlit/elements/graphviz_chart.py +150 -0
- streamlit/elements/heading.py +302 -0
- streamlit/elements/html.py +105 -0
- streamlit/elements/iframe.py +191 -0
- streamlit/elements/image.py +196 -0
- streamlit/elements/json.py +139 -0
- streamlit/elements/layouts.py +879 -0
- streamlit/elements/lib/__init__.py +13 -0
- streamlit/elements/lib/built_in_chart_utils.py +1157 -0
- streamlit/elements/lib/color_util.py +263 -0
- streamlit/elements/lib/column_config_utils.py +542 -0
- streamlit/elements/lib/column_types.py +2188 -0
- streamlit/elements/lib/dialog.py +147 -0
- streamlit/elements/lib/dicttools.py +154 -0
- streamlit/elements/lib/event_utils.py +37 -0
- streamlit/elements/lib/file_uploader_utils.py +66 -0
- streamlit/elements/lib/form_utils.py +77 -0
- streamlit/elements/lib/image_utils.py +441 -0
- streamlit/elements/lib/js_number.py +105 -0
- streamlit/elements/lib/mutable_status_container.py +183 -0
- streamlit/elements/lib/options_selector_utils.py +250 -0
- streamlit/elements/lib/pandas_styler_utils.py +274 -0
- streamlit/elements/lib/policies.py +194 -0
- streamlit/elements/lib/streamlit_plotly_theme.py +207 -0
- streamlit/elements/lib/subtitle_utils.py +176 -0
- streamlit/elements/lib/utils.py +250 -0
- streamlit/elements/map.py +508 -0
- streamlit/elements/markdown.py +277 -0
- streamlit/elements/media.py +793 -0
- streamlit/elements/metric.py +301 -0
- streamlit/elements/plotly_chart.py +546 -0
- streamlit/elements/progress.py +156 -0
- streamlit/elements/pyplot.py +194 -0
- streamlit/elements/snow.py +47 -0
- streamlit/elements/spinner.py +113 -0
- streamlit/elements/text.py +76 -0
- streamlit/elements/toast.py +98 -0
- streamlit/elements/vega_charts.py +1984 -0
- streamlit/elements/widgets/__init__.py +13 -0
- streamlit/elements/widgets/audio_input.py +310 -0
- streamlit/elements/widgets/button.py +1123 -0
- streamlit/elements/widgets/button_group.py +1008 -0
- streamlit/elements/widgets/camera_input.py +263 -0
- streamlit/elements/widgets/chat.py +647 -0
- streamlit/elements/widgets/checkbox.py +352 -0
- streamlit/elements/widgets/color_picker.py +265 -0
- streamlit/elements/widgets/data_editor.py +983 -0
- streamlit/elements/widgets/file_uploader.py +486 -0
- streamlit/elements/widgets/multiselect.py +338 -0
- streamlit/elements/widgets/number_input.py +545 -0
- streamlit/elements/widgets/radio.py +407 -0
- streamlit/elements/widgets/select_slider.py +437 -0
- streamlit/elements/widgets/selectbox.py +366 -0
- streamlit/elements/widgets/slider.py +880 -0
- streamlit/elements/widgets/text_widgets.py +628 -0
- streamlit/elements/widgets/time_widgets.py +970 -0
- streamlit/elements/write.py +574 -0
- streamlit/emojis.py +34 -0
- streamlit/env_util.py +61 -0
- streamlit/error_util.py +105 -0
- streamlit/errors.py +452 -0
- streamlit/external/__init__.py +13 -0
- streamlit/external/langchain/__init__.py +23 -0
- streamlit/external/langchain/streamlit_callback_handler.py +406 -0
- streamlit/file_util.py +247 -0
- streamlit/git_util.py +173 -0
- streamlit/hello/__init__.py +13 -0
- streamlit/hello/animation_demo.py +82 -0
- streamlit/hello/dataframe_demo.py +71 -0
- streamlit/hello/hello.py +37 -0
- streamlit/hello/mapping_demo.py +114 -0
- streamlit/hello/plotting_demo.py +55 -0
- streamlit/hello/streamlit_app.py +55 -0
- streamlit/hello/utils.py +28 -0
- streamlit/logger.py +130 -0
- streamlit/material_icon_names.py +25 -0
- streamlit/navigation/__init__.py +13 -0
- streamlit/navigation/page.py +302 -0
- streamlit/net_util.py +125 -0
- streamlit/platform.py +33 -0
- streamlit/proto/Alert_pb2.py +29 -0
- streamlit/proto/Alert_pb2.pyi +90 -0
- streamlit/proto/AppPage_pb2.py +27 -0
- streamlit/proto/AppPage_pb2.pyi +64 -0
- streamlit/proto/ArrowNamedDataSet_pb2.py +28 -0
- streamlit/proto/ArrowNamedDataSet_pb2.pyi +57 -0
- streamlit/proto/ArrowVegaLiteChart_pb2.py +29 -0
- streamlit/proto/ArrowVegaLiteChart_pb2.pyi +84 -0
- streamlit/proto/Arrow_pb2.py +33 -0
- streamlit/proto/Arrow_pb2.pyi +188 -0
- streamlit/proto/AudioInput_pb2.py +28 -0
- streamlit/proto/AudioInput_pb2.pyi +58 -0
- streamlit/proto/Audio_pb2.py +27 -0
- streamlit/proto/Audio_pb2.pyi +58 -0
- streamlit/proto/AuthRedirect_pb2.py +27 -0
- streamlit/proto/AuthRedirect_pb2.pyi +41 -0
- streamlit/proto/AutoRerun_pb2.py +27 -0
- streamlit/proto/AutoRerun_pb2.pyi +45 -0
- streamlit/proto/BackMsg_pb2.py +29 -0
- streamlit/proto/BackMsg_pb2.pyi +105 -0
- streamlit/proto/Balloons_pb2.py +27 -0
- streamlit/proto/Balloons_pb2.pyi +43 -0
- streamlit/proto/Block_pb2.py +53 -0
- streamlit/proto/Block_pb2.pyi +322 -0
- streamlit/proto/BokehChart_pb2.py +27 -0
- streamlit/proto/BokehChart_pb2.pyi +49 -0
- streamlit/proto/ButtonGroup_pb2.py +36 -0
- streamlit/proto/ButtonGroup_pb2.pyi +169 -0
- streamlit/proto/Button_pb2.py +27 -0
- streamlit/proto/Button_pb2.pyi +71 -0
- streamlit/proto/CameraInput_pb2.py +28 -0
- streamlit/proto/CameraInput_pb2.pyi +58 -0
- streamlit/proto/ChatInput_pb2.py +31 -0
- streamlit/proto/ChatInput_pb2.pyi +111 -0
- streamlit/proto/Checkbox_pb2.py +30 -0
- streamlit/proto/Checkbox_pb2.pyi +90 -0
- streamlit/proto/ClientState_pb2.py +30 -0
- streamlit/proto/ClientState_pb2.pyi +90 -0
- streamlit/proto/Code_pb2.py +27 -0
- streamlit/proto/Code_pb2.pyi +55 -0
- streamlit/proto/ColorPicker_pb2.py +28 -0
- streamlit/proto/ColorPicker_pb2.pyi +67 -0
- streamlit/proto/Common_pb2.py +51 -0
- streamlit/proto/Common_pb2.pyi +293 -0
- streamlit/proto/Components_pb2.py +35 -0
- streamlit/proto/Components_pb2.pyi +172 -0
- streamlit/proto/DataFrame_pb2.py +56 -0
- streamlit/proto/DataFrame_pb2.pyi +397 -0
- streamlit/proto/DateInput_pb2.py +28 -0
- streamlit/proto/DateInput_pb2.pyi +83 -0
- streamlit/proto/DeckGlJsonChart_pb2.py +29 -0
- streamlit/proto/DeckGlJsonChart_pb2.pyi +102 -0
- streamlit/proto/Delta_pb2.py +31 -0
- streamlit/proto/Delta_pb2.pyi +74 -0
- streamlit/proto/DocString_pb2.py +29 -0
- streamlit/proto/DocString_pb2.pyi +93 -0
- streamlit/proto/DownloadButton_pb2.py +27 -0
- streamlit/proto/DownloadButton_pb2.pyi +70 -0
- streamlit/proto/Element_pb2.py +78 -0
- streamlit/proto/Element_pb2.pyi +312 -0
- streamlit/proto/Empty_pb2.py +27 -0
- streamlit/proto/Empty_pb2.pyi +36 -0
- streamlit/proto/Exception_pb2.py +27 -0
- streamlit/proto/Exception_pb2.pyi +72 -0
- streamlit/proto/Favicon_pb2.py +27 -0
- streamlit/proto/Favicon_pb2.pyi +40 -0
- streamlit/proto/FileUploader_pb2.py +28 -0
- streamlit/proto/FileUploader_pb2.pyi +78 -0
- streamlit/proto/ForwardMsg_pb2.py +53 -0
- streamlit/proto/ForwardMsg_pb2.pyi +293 -0
- streamlit/proto/GitInfo_pb2.py +29 -0
- streamlit/proto/GitInfo_pb2.pyi +83 -0
- streamlit/proto/GraphVizChart_pb2.py +27 -0
- streamlit/proto/GraphVizChart_pb2.pyi +53 -0
- streamlit/proto/Heading_pb2.py +27 -0
- streamlit/proto/Heading_pb2.pyi +56 -0
- streamlit/proto/Html_pb2.py +27 -0
- streamlit/proto/Html_pb2.pyi +42 -0
- streamlit/proto/IFrame_pb2.py +27 -0
- streamlit/proto/IFrame_pb2.pyi +59 -0
- streamlit/proto/Image_pb2.py +29 -0
- streamlit/proto/Image_pb2.pyi +84 -0
- streamlit/proto/Json_pb2.py +27 -0
- streamlit/proto/Json_pb2.pyi +53 -0
- streamlit/proto/LabelVisibilityMessage_pb2.py +29 -0
- streamlit/proto/LabelVisibilityMessage_pb2.pyi +68 -0
- streamlit/proto/LinkButton_pb2.py +27 -0
- streamlit/proto/LinkButton_pb2.pyi +58 -0
- streamlit/proto/Logo_pb2.py +27 -0
- streamlit/proto/Logo_pb2.pyi +51 -0
- streamlit/proto/Markdown_pb2.py +29 -0
- streamlit/proto/Markdown_pb2.pyi +86 -0
- streamlit/proto/Metric_pb2.py +32 -0
- streamlit/proto/Metric_pb2.pyi +101 -0
- streamlit/proto/MetricsEvent_pb2.py +30 -0
- streamlit/proto/MetricsEvent_pb2.pyi +200 -0
- streamlit/proto/MultiSelect_pb2.py +28 -0
- streamlit/proto/MultiSelect_pb2.pyi +81 -0
- streamlit/proto/NamedDataSet_pb2.py +28 -0
- streamlit/proto/NamedDataSet_pb2.pyi +59 -0
- streamlit/proto/Navigation_pb2.py +30 -0
- streamlit/proto/Navigation_pb2.pyi +84 -0
- streamlit/proto/NewSession_pb2.py +51 -0
- streamlit/proto/NewSession_pb2.pyi +481 -0
- streamlit/proto/NumberInput_pb2.py +30 -0
- streamlit/proto/NumberInput_pb2.pyi +121 -0
- streamlit/proto/PageConfig_pb2.py +33 -0
- streamlit/proto/PageConfig_pb2.pyi +126 -0
- streamlit/proto/PageInfo_pb2.py +27 -0
- streamlit/proto/PageInfo_pb2.pyi +43 -0
- streamlit/proto/PageLink_pb2.py +27 -0
- streamlit/proto/PageLink_pb2.pyi +63 -0
- streamlit/proto/PageNotFound_pb2.py +27 -0
- streamlit/proto/PageNotFound_pb2.pyi +42 -0
- streamlit/proto/PageProfile_pb2.py +31 -0
- streamlit/proto/PageProfile_pb2.pyi +127 -0
- streamlit/proto/PagesChanged_pb2.py +28 -0
- streamlit/proto/PagesChanged_pb2.pyi +48 -0
- streamlit/proto/ParentMessage_pb2.py +27 -0
- streamlit/proto/ParentMessage_pb2.pyi +46 -0
- streamlit/proto/PlotlyChart_pb2.py +31 -0
- streamlit/proto/PlotlyChart_pb2.pyi +131 -0
- streamlit/proto/Progress_pb2.py +27 -0
- streamlit/proto/Progress_pb2.pyi +43 -0
- streamlit/proto/Radio_pb2.py +28 -0
- streamlit/proto/Radio_pb2.pyi +84 -0
- streamlit/proto/RootContainer_pb2.py +27 -0
- streamlit/proto/RootContainer_pb2.pyi +56 -0
- streamlit/proto/Selectbox_pb2.py +28 -0
- streamlit/proto/Selectbox_pb2.pyi +80 -0
- streamlit/proto/SessionEvent_pb2.py +28 -0
- streamlit/proto/SessionEvent_pb2.pyi +62 -0
- streamlit/proto/SessionStatus_pb2.py +27 -0
- streamlit/proto/SessionStatus_pb2.pyi +57 -0
- streamlit/proto/Skeleton_pb2.py +29 -0
- streamlit/proto/Skeleton_pb2.pyi +71 -0
- streamlit/proto/Slider_pb2.py +32 -0
- streamlit/proto/Slider_pb2.pyi +142 -0
- streamlit/proto/Snow_pb2.py +27 -0
- streamlit/proto/Snow_pb2.pyi +43 -0
- streamlit/proto/Spinner_pb2.py +27 -0
- streamlit/proto/Spinner_pb2.pyi +49 -0
- streamlit/proto/TextArea_pb2.py +28 -0
- streamlit/proto/TextArea_pb2.pyi +80 -0
- streamlit/proto/TextInput_pb2.py +30 -0
- streamlit/proto/TextInput_pb2.pyi +107 -0
- streamlit/proto/Text_pb2.py +27 -0
- streamlit/proto/Text_pb2.pyi +46 -0
- streamlit/proto/TimeInput_pb2.py +28 -0
- streamlit/proto/TimeInput_pb2.pyi +74 -0
- streamlit/proto/Toast_pb2.py +27 -0
- streamlit/proto/Toast_pb2.pyi +45 -0
- streamlit/proto/VegaLiteChart_pb2.py +29 -0
- streamlit/proto/VegaLiteChart_pb2.pyi +71 -0
- streamlit/proto/Video_pb2.py +31 -0
- streamlit/proto/Video_pb2.pyi +117 -0
- streamlit/proto/WidgetStates_pb2.py +31 -0
- streamlit/proto/WidgetStates_pb2.pyi +126 -0
- streamlit/proto/__init__.py +15 -0
- streamlit/proto/openmetrics_data_model_pb2.py +60 -0
- streamlit/proto/openmetrics_data_model_pb2.pyi +522 -0
- streamlit/py.typed +0 -0
- streamlit/runtime/__init__.py +50 -0
- streamlit/runtime/app_session.py +982 -0
- streamlit/runtime/caching/__init__.py +98 -0
- streamlit/runtime/caching/cache_data_api.py +665 -0
- streamlit/runtime/caching/cache_errors.py +142 -0
- streamlit/runtime/caching/cache_resource_api.py +527 -0
- streamlit/runtime/caching/cache_type.py +33 -0
- streamlit/runtime/caching/cache_utils.py +523 -0
- streamlit/runtime/caching/cached_message_replay.py +290 -0
- streamlit/runtime/caching/hashing.py +637 -0
- streamlit/runtime/caching/legacy_cache_api.py +169 -0
- streamlit/runtime/caching/storage/__init__.py +29 -0
- streamlit/runtime/caching/storage/cache_storage_protocol.py +239 -0
- streamlit/runtime/caching/storage/dummy_cache_storage.py +60 -0
- streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py +145 -0
- streamlit/runtime/caching/storage/local_disk_cache_storage.py +223 -0
- streamlit/runtime/connection_factory.py +436 -0
- streamlit/runtime/context.py +280 -0
- streamlit/runtime/credentials.py +364 -0
- streamlit/runtime/forward_msg_cache.py +296 -0
- streamlit/runtime/forward_msg_queue.py +240 -0
- streamlit/runtime/fragment.py +477 -0
- streamlit/runtime/media_file_manager.py +234 -0
- streamlit/runtime/media_file_storage.py +143 -0
- streamlit/runtime/memory_media_file_storage.py +181 -0
- streamlit/runtime/memory_session_storage.py +77 -0
- streamlit/runtime/memory_uploaded_file_manager.py +138 -0
- streamlit/runtime/metrics_util.py +486 -0
- streamlit/runtime/pages_manager.py +165 -0
- streamlit/runtime/runtime.py +792 -0
- streamlit/runtime/runtime_util.py +106 -0
- streamlit/runtime/script_data.py +46 -0
- streamlit/runtime/scriptrunner/__init__.py +38 -0
- streamlit/runtime/scriptrunner/exec_code.py +159 -0
- streamlit/runtime/scriptrunner/magic.py +273 -0
- streamlit/runtime/scriptrunner/magic_funcs.py +32 -0
- streamlit/runtime/scriptrunner/script_cache.py +89 -0
- streamlit/runtime/scriptrunner/script_runner.py +756 -0
- streamlit/runtime/scriptrunner_utils/__init__.py +19 -0
- streamlit/runtime/scriptrunner_utils/exceptions.py +48 -0
- streamlit/runtime/scriptrunner_utils/script_requests.py +307 -0
- streamlit/runtime/scriptrunner_utils/script_run_context.py +287 -0
- streamlit/runtime/secrets.py +534 -0
- streamlit/runtime/session_manager.py +394 -0
- streamlit/runtime/state/__init__.py +41 -0
- streamlit/runtime/state/common.py +191 -0
- streamlit/runtime/state/query_params.py +205 -0
- streamlit/runtime/state/query_params_proxy.py +218 -0
- streamlit/runtime/state/safe_session_state.py +138 -0
- streamlit/runtime/state/session_state.py +772 -0
- streamlit/runtime/state/session_state_proxy.py +153 -0
- streamlit/runtime/state/widgets.py +135 -0
- streamlit/runtime/stats.py +109 -0
- streamlit/runtime/uploaded_file_manager.py +148 -0
- streamlit/runtime/websocket_session_manager.py +167 -0
- streamlit/source_util.py +98 -0
- streamlit/static/favicon.png +0 -0
- streamlit/static/index.html +61 -0
- streamlit/static/static/css/index.Bmkmz40k.css +1 -0
- streamlit/static/static/css/index.DpJG_94W.css +1 -0
- streamlit/static/static/css/index.DzuxGC_t.css +1 -0
- streamlit/static/static/js/FileDownload.esm.Bp9m5jrx.js +1 -0
- streamlit/static/static/js/FileHelper.D_3pbilj.js +5 -0
- streamlit/static/static/js/FormClearHelper.Ct2rwLXo.js +1 -0
- streamlit/static/static/js/Hooks.BKdzj5MJ.js +1 -0
- streamlit/static/static/js/InputInstructions.DB3QGNJP.js +1 -0
- streamlit/static/static/js/ProgressBar.D40A5xc2.js +2 -0
- streamlit/static/static/js/RenderInPortalIfExists.DLUCooTN.js +1 -0
- streamlit/static/static/js/Toolbar.BiGGIQun.js +1 -0
- streamlit/static/static/js/UploadFileInfo.C-jY39rj.js +1 -0
- streamlit/static/static/js/base-input.CQBQT24M.js +4 -0
- streamlit/static/static/js/checkbox.Buj8gd_M.js +9 -0
- streamlit/static/static/js/createDownloadLinkElement.DZMwyjvU.js +1 -0
- streamlit/static/static/js/createSuper.CesK3I23.js +1 -0
- streamlit/static/static/js/data-grid-overlay-editor.B69OOFM4.js +1 -0
- streamlit/static/static/js/downloader.BZQhlBNT.js +1 -0
- streamlit/static/static/js/es6.D9Zhqujy.js +2 -0
- streamlit/static/static/js/iframeResizer.contentWindow.CAzcBpCC.js +1 -0
- streamlit/static/static/js/index.08vcOOvb.js +1 -0
- streamlit/static/static/js/index.0uqKfJUS.js +1 -0
- streamlit/static/static/js/index.B02M5u69.js +203 -0
- streamlit/static/static/js/index.B7mcZKMx.js +1 -0
- streamlit/static/static/js/index.BAQDHFA_.js +1 -0
- streamlit/static/static/js/index.BI60cMVr.js +2 -0
- streamlit/static/static/js/index.BLug2inK.js +1 -0
- streamlit/static/static/js/index.BM6TMY8g.js +2 -0
- streamlit/static/static/js/index.BZ9p1t7G.js +1 -0
- streamlit/static/static/js/index.BZqa87a1.js +2 -0
- streamlit/static/static/js/index.BcsRUzZZ.js +1 -0
- streamlit/static/static/js/index.BgVMiY_P.js +197 -0
- streamlit/static/static/js/index.BtuGy7By.js +6 -0
- streamlit/static/static/js/index.BuDuBmrs.js +1 -0
- streamlit/static/static/js/index.BvXU2oKV.js +1 -0
- streamlit/static/static/js/index.BxcwPacT.js +73 -0
- streamlit/static/static/js/index.CWX8KB81.js +1 -0
- streamlit/static/static/js/index.CXzZTo_q.js +1 -0
- streamlit/static/static/js/index.CcRWp_KL.js +1 -0
- streamlit/static/static/js/index.Cd-_xe55.js +3 -0
- streamlit/static/static/js/index.CdG2PXln.js +4537 -0
- streamlit/static/static/js/index.CjXvXmcP.js +1 -0
- streamlit/static/static/js/index.D1HZENZx.js +776 -0
- streamlit/static/static/js/index.D21Efo64.js +1617 -0
- streamlit/static/static/js/index.D9WgGVBx.js +7 -0
- streamlit/static/static/js/index.DEcsHtvb.js +12 -0
- streamlit/static/static/js/index.DFeMfr_K.js +1 -0
- streamlit/static/static/js/index.DHFBoItz.js +1 -0
- streamlit/static/static/js/index.D_PrBKnJ.js +3 -0
- streamlit/static/static/js/index.DmuRkekN.js +3855 -0
- streamlit/static/static/js/index.Do6eY8sf.js +1 -0
- streamlit/static/static/js/index.Dz3lP2P-.js +1 -0
- streamlit/static/static/js/index.Dz_UqF-s.js +1 -0
- streamlit/static/static/js/index.GkSUsPhJ.js +1 -0
- streamlit/static/static/js/index.H1U1IC_d.js +3 -0
- streamlit/static/static/js/index.g6p_4DPr.js +1 -0
- streamlit/static/static/js/index.g9x_GKss.js +1 -0
- streamlit/static/static/js/index.zo9jm08y.js +1 -0
- streamlit/static/static/js/input.DnaFglHq.js +2 -0
- streamlit/static/static/js/inputUtils.CQWz5UKz.js +1 -0
- streamlit/static/static/js/memory.Crb9x4-F.js +1 -0
- streamlit/static/static/js/mergeWith.ouAz0sK3.js +1 -0
- streamlit/static/static/js/number-overlay-editor._UaN-O48.js +9 -0
- streamlit/static/static/js/possibleConstructorReturn.CtGjGFHz.js +1 -0
- streamlit/static/static/js/sandbox.CBybYOhV.js +1 -0
- streamlit/static/static/js/sprintf.D7DtBTRn.js +1 -0
- streamlit/static/static/js/textarea.Cb_uJt5U.js +2 -0
- streamlit/static/static/js/threshold.DjX0wlsa.js +1 -0
- streamlit/static/static/js/timepicker.DKT7pfoF.js +4 -0
- streamlit/static/static/js/timer.CAwTRJ_g.js +1 -0
- streamlit/static/static/js/toConsumableArray.05Ikp13-.js +3 -0
- streamlit/static/static/js/uniqueId.D2FMWUEI.js +1 -0
- streamlit/static/static/js/useBasicWidgetState.urnZLANY.js +1 -0
- streamlit/static/static/js/useOnInputChange.BOKIIdJ1.js +1 -0
- streamlit/static/static/js/value.CgPGBV_l.js +1 -0
- streamlit/static/static/js/withFullScreenWrapper.C_N8J0Xx.js +1 -0
- streamlit/static/static/media/KaTeX_AMS-Regular.BQhdFMY1.woff2 +0 -0
- streamlit/static/static/media/KaTeX_AMS-Regular.DMm9YOAa.woff +0 -0
- streamlit/static/static/media/KaTeX_AMS-Regular.DRggAlZN.ttf +0 -0
- streamlit/static/static/media/KaTeX_Caligraphic-Bold.ATXxdsX0.ttf +0 -0
- streamlit/static/static/media/KaTeX_Caligraphic-Bold.BEiXGLvX.woff +0 -0
- streamlit/static/static/media/KaTeX_Caligraphic-Bold.Dq_IR9rO.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Caligraphic-Regular.CTRA-rTL.woff +0 -0
- streamlit/static/static/media/KaTeX_Caligraphic-Regular.Di6jR-x-.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Caligraphic-Regular.wX97UBjC.ttf +0 -0
- streamlit/static/static/media/KaTeX_Fraktur-Bold.BdnERNNW.ttf +0 -0
- streamlit/static/static/media/KaTeX_Fraktur-Bold.BsDP51OF.woff +0 -0
- streamlit/static/static/media/KaTeX_Fraktur-Bold.CL6g_b3V.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Fraktur-Regular.CB_wures.ttf +0 -0
- streamlit/static/static/media/KaTeX_Fraktur-Regular.CTYiF6lA.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Fraktur-Regular.Dxdc4cR9.woff +0 -0
- streamlit/static/static/media/KaTeX_Main-Bold.Cx986IdX.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Main-Bold.Jm3AIy58.woff +0 -0
- streamlit/static/static/media/KaTeX_Main-Bold.waoOVXN0.ttf +0 -0
- streamlit/static/static/media/KaTeX_Main-BoldItalic.DxDJ3AOS.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Main-BoldItalic.DzxPMmG6.ttf +0 -0
- streamlit/static/static/media/KaTeX_Main-BoldItalic.SpSLRI95.woff +0 -0
- streamlit/static/static/media/KaTeX_Main-Italic.3WenGoN9.ttf +0 -0
- streamlit/static/static/media/KaTeX_Main-Italic.BMLOBm91.woff +0 -0
- streamlit/static/static/media/KaTeX_Main-Italic.NWA7e6Wa.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Main-Regular.B22Nviop.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Main-Regular.Dr94JaBh.woff +0 -0
- streamlit/static/static/media/KaTeX_Main-Regular.ypZvNtVU.ttf +0 -0
- streamlit/static/static/media/KaTeX_Math-BoldItalic.B3XSjfu4.ttf +0 -0
- streamlit/static/static/media/KaTeX_Math-BoldItalic.CZnvNsCZ.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Math-BoldItalic.iY-2wyZ7.woff +0 -0
- streamlit/static/static/media/KaTeX_Math-Italic.DA0__PXp.woff +0 -0
- streamlit/static/static/media/KaTeX_Math-Italic.flOr_0UB.ttf +0 -0
- streamlit/static/static/media/KaTeX_Math-Italic.t53AETM-.woff2 +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Bold.CFMepnvq.ttf +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Bold.D1sUS0GD.woff2 +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Bold.DbIhKOiC.woff +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Italic.C3H0VqGB.woff2 +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Italic.DN2j7dab.woff +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Italic.YYjJ1zSn.ttf +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Regular.BNo7hRIc.ttf +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Regular.CS6fqUqJ.woff +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Regular.DDBCnlJ7.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Script-Regular.C5JkGWo-.ttf +0 -0
- streamlit/static/static/media/KaTeX_Script-Regular.D3wIWfF6.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Script-Regular.D5yQViql.woff +0 -0
- streamlit/static/static/media/KaTeX_Size1-Regular.C195tn64.woff +0 -0
- streamlit/static/static/media/KaTeX_Size1-Regular.Dbsnue_I.ttf +0 -0
- streamlit/static/static/media/KaTeX_Size1-Regular.mCD8mA8B.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Size2-Regular.B7gKUWhC.ttf +0 -0
- streamlit/static/static/media/KaTeX_Size2-Regular.Dy4dx90m.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Size2-Regular.oD1tc_U0.woff +0 -0
- streamlit/static/static/media/KaTeX_Size3-Regular.CTq5MqoE.woff +0 -0
- streamlit/static/static/media/KaTeX_Size3-Regular.DgpXs0kz.ttf +0 -0
- streamlit/static/static/media/KaTeX_Size4-Regular.BF-4gkZK.woff +0 -0
- streamlit/static/static/media/KaTeX_Size4-Regular.DWFBv043.ttf +0 -0
- streamlit/static/static/media/KaTeX_Size4-Regular.Dl5lxZxV.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Typewriter-Regular.C0xS9mPB.woff +0 -0
- streamlit/static/static/media/KaTeX_Typewriter-Regular.CO6r4hn1.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Typewriter-Regular.D3Ib7_Hf.ttf +0 -0
- streamlit/static/static/media/MaterialSymbols-Rounded.DcZbplWk.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-Bold.CFEfr7-q.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-BoldItalic.C-LkFXxa.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-Italic.CxFOx7N-.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-Regular.CBOlD63d.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-SemiBold.CFHwW3Wd.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-SemiBoldItalic.Cg2yRu82.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-Bold.-6c9oR8J.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-BoldItalic.DmM_grLY.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-Italic.I1ipWe7Q.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-Regular.DZLUzqI4.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-SemiBold.sKQIyTMz.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-SemiBoldItalic.C0wP0icr.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-Bold.8TUnKj4x.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-BoldItalic.CBVO7Ve7.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-Italic.DkFgL2HZ.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-Regular.CNJNET2S.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-SemiBold.CHyh9GC5.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-SemiBoldItalic.CBtz8sWN.woff2 +0 -0
- streamlit/static/static/media/balloon-0.Czj7AKwE.png +0 -0
- streamlit/static/static/media/balloon-1.CNvFFrND.png +0 -0
- streamlit/static/static/media/balloon-2.DTvC6B1t.png +0 -0
- streamlit/static/static/media/balloon-3.CgSk4tbL.png +0 -0
- streamlit/static/static/media/balloon-4.mbtFrzxf.png +0 -0
- streamlit/static/static/media/balloon-5.CSwkUfRA.png +0 -0
- streamlit/static/static/media/fireworks.B4d-_KUe.gif +0 -0
- streamlit/static/static/media/flake-0.DgWaVvm5.png +0 -0
- streamlit/static/static/media/flake-1.B2r5AHMK.png +0 -0
- streamlit/static/static/media/flake-2.BnWSExPC.png +0 -0
- streamlit/static/static/media/snowflake.JU2jBHL8.svg +11 -0
- streamlit/string_util.py +203 -0
- streamlit/temporary_directory.py +56 -0
- streamlit/testing/__init__.py +13 -0
- streamlit/testing/v1/__init__.py +17 -0
- streamlit/testing/v1/app_test.py +1050 -0
- streamlit/testing/v1/element_tree.py +2083 -0
- streamlit/testing/v1/local_script_runner.py +180 -0
- streamlit/testing/v1/util.py +53 -0
- streamlit/time_util.py +75 -0
- streamlit/type_util.py +460 -0
- streamlit/url_util.py +122 -0
- streamlit/user_info.py +519 -0
- streamlit/util.py +72 -0
- streamlit/vendor/__init__.py +0 -0
- streamlit/vendor/pympler/__init__.py +0 -0
- streamlit/vendor/pympler/asizeof.py +2869 -0
- streamlit/version.py +18 -0
- streamlit/watcher/__init__.py +28 -0
- streamlit/watcher/event_based_path_watcher.py +406 -0
- streamlit/watcher/folder_black_list.py +82 -0
- streamlit/watcher/local_sources_watcher.py +233 -0
- streamlit/watcher/path_watcher.py +185 -0
- streamlit/watcher/polling_path_watcher.py +124 -0
- streamlit/watcher/util.py +207 -0
- streamlit/web/__init__.py +13 -0
- streamlit/web/bootstrap.py +353 -0
- streamlit/web/cache_storage_manager_config.py +38 -0
- streamlit/web/cli.py +369 -0
- streamlit/web/server/__init__.py +26 -0
- streamlit/web/server/app_static_file_handler.py +93 -0
- streamlit/web/server/authlib_tornado_integration.py +60 -0
- streamlit/web/server/browser_websocket_handler.py +246 -0
- streamlit/web/server/component_request_handler.py +116 -0
- streamlit/web/server/media_file_handler.py +141 -0
- streamlit/web/server/oauth_authlib_routes.py +176 -0
- streamlit/web/server/oidc_mixin.py +108 -0
- streamlit/web/server/routes.py +295 -0
- streamlit/web/server/server.py +479 -0
- streamlit/web/server/server_util.py +161 -0
- streamlit/web/server/stats_request_handler.py +95 -0
- streamlit/web/server/upload_file_request_handler.py +137 -0
- streamlit/web/server/websocket_headers.py +56 -0
- streamlit_nightly-1.43.2.dev20250307.data/scripts/streamlit.cmd +16 -0
- streamlit_nightly-1.43.2.dev20250307.dist-info/METADATA +207 -0
- streamlit_nightly-1.43.2.dev20250307.dist-info/RECORD +563 -0
- streamlit_nightly-1.43.2.dev20250307.dist-info/WHEEL +5 -0
- streamlit_nightly-1.43.2.dev20250307.dist-info/entry_points.txt +2 -0
- streamlit_nightly-1.43.2.dev20250307.dist-info/top_level.txt +1 -0
@@ -0,0 +1,970 @@
|
|
1
|
+
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2025)
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
from __future__ import annotations
|
15
|
+
|
16
|
+
import re
|
17
|
+
from collections.abc import Sequence
|
18
|
+
from dataclasses import dataclass
|
19
|
+
from datetime import date, datetime, time, timedelta
|
20
|
+
from textwrap import dedent
|
21
|
+
from typing import (
|
22
|
+
TYPE_CHECKING,
|
23
|
+
Any,
|
24
|
+
Final,
|
25
|
+
Literal,
|
26
|
+
Union,
|
27
|
+
cast,
|
28
|
+
overload,
|
29
|
+
)
|
30
|
+
|
31
|
+
from typing_extensions import TypeAlias
|
32
|
+
|
33
|
+
from streamlit.elements.lib.form_utils import current_form_id
|
34
|
+
from streamlit.elements.lib.policies import (
|
35
|
+
check_widget_policies,
|
36
|
+
maybe_raise_label_warnings,
|
37
|
+
)
|
38
|
+
from streamlit.elements.lib.utils import (
|
39
|
+
Key,
|
40
|
+
LabelVisibility,
|
41
|
+
compute_and_register_element_id,
|
42
|
+
get_label_visibility_proto_value,
|
43
|
+
to_key,
|
44
|
+
)
|
45
|
+
from streamlit.errors import StreamlitAPIException
|
46
|
+
from streamlit.proto.DateInput_pb2 import DateInput as DateInputProto
|
47
|
+
from streamlit.proto.TimeInput_pb2 import TimeInput as TimeInputProto
|
48
|
+
from streamlit.runtime.metrics_util import gather_metrics
|
49
|
+
from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
|
50
|
+
from streamlit.runtime.state import (
|
51
|
+
WidgetArgs,
|
52
|
+
WidgetCallback,
|
53
|
+
WidgetKwargs,
|
54
|
+
get_session_state,
|
55
|
+
register_widget,
|
56
|
+
)
|
57
|
+
from streamlit.time_util import adjust_years
|
58
|
+
|
59
|
+
if TYPE_CHECKING:
|
60
|
+
from streamlit.delta_generator import DeltaGenerator
|
61
|
+
|
62
|
+
# Type for things that point to a specific time (even if a default time, though not None).
|
63
|
+
TimeValue: TypeAlias = Union[time, datetime, str, Literal["now"]]
|
64
|
+
|
65
|
+
# Type for things that point to a specific date (even if a default date, including None).
|
66
|
+
NullableScalarDateValue: TypeAlias = Union[date, datetime, str, Literal["today"], None]
|
67
|
+
|
68
|
+
# The accepted input value for st.date_input. Can be a date scalar or a date range.
|
69
|
+
DateValue: TypeAlias = Union[NullableScalarDateValue, Sequence[NullableScalarDateValue]]
|
70
|
+
|
71
|
+
# The return value of st.date_input.
|
72
|
+
DateWidgetRangeReturn: TypeAlias = Union[
|
73
|
+
tuple[()],
|
74
|
+
tuple[date],
|
75
|
+
tuple[date, date],
|
76
|
+
]
|
77
|
+
DateWidgetReturn: TypeAlias = Union[date, DateWidgetRangeReturn, None]
|
78
|
+
|
79
|
+
|
80
|
+
DEFAULT_STEP_MINUTES: Final = 15
|
81
|
+
ALLOWED_DATE_FORMATS: Final = re.compile(
|
82
|
+
r"^(YYYY[/.\-]MM[/.\-]DD|DD[/.\-]MM[/.\-]YYYY|MM[/.\-]DD[/.\-]YYYY)$"
|
83
|
+
)
|
84
|
+
|
85
|
+
|
86
|
+
def _convert_timelike_to_time(value: TimeValue) -> time:
|
87
|
+
if value == "now":
|
88
|
+
# Set value default.
|
89
|
+
return datetime.now().time().replace(second=0, microsecond=0)
|
90
|
+
|
91
|
+
if isinstance(value, str):
|
92
|
+
try:
|
93
|
+
return time.fromisoformat(value)
|
94
|
+
except ValueError:
|
95
|
+
try:
|
96
|
+
return (
|
97
|
+
datetime.fromisoformat(value)
|
98
|
+
.time()
|
99
|
+
.replace(second=0, microsecond=0)
|
100
|
+
)
|
101
|
+
except ValueError:
|
102
|
+
# We throw an error below.
|
103
|
+
pass
|
104
|
+
|
105
|
+
if isinstance(value, datetime):
|
106
|
+
return value.time().replace(second=0, microsecond=0)
|
107
|
+
|
108
|
+
if isinstance(value, time):
|
109
|
+
return value
|
110
|
+
|
111
|
+
raise StreamlitAPIException(
|
112
|
+
"The type of value should be one of datetime, time, ISO string or None"
|
113
|
+
)
|
114
|
+
|
115
|
+
|
116
|
+
def _convert_datelike_to_date(
|
117
|
+
value: NullableScalarDateValue,
|
118
|
+
) -> date:
|
119
|
+
if isinstance(value, datetime):
|
120
|
+
return value.date()
|
121
|
+
|
122
|
+
if isinstance(value, date):
|
123
|
+
return value
|
124
|
+
|
125
|
+
if value in {"today"}:
|
126
|
+
return datetime.now().date()
|
127
|
+
|
128
|
+
if isinstance(value, str):
|
129
|
+
try:
|
130
|
+
return date.fromisoformat(value)
|
131
|
+
except ValueError:
|
132
|
+
try:
|
133
|
+
return datetime.fromisoformat(value).date()
|
134
|
+
except ValueError:
|
135
|
+
# We throw an error below.
|
136
|
+
pass
|
137
|
+
|
138
|
+
raise StreamlitAPIException(
|
139
|
+
'Date value should either be an date/datetime or an ISO string or "today"'
|
140
|
+
)
|
141
|
+
|
142
|
+
|
143
|
+
def _parse_date_value(value: DateValue) -> tuple[list[date] | None, bool]:
|
144
|
+
if value is None:
|
145
|
+
return None, False
|
146
|
+
|
147
|
+
value_tuple: Sequence[NullableScalarDateValue]
|
148
|
+
|
149
|
+
if isinstance(value, Sequence) and not isinstance(value, str):
|
150
|
+
is_range = True
|
151
|
+
value_tuple = value
|
152
|
+
else:
|
153
|
+
is_range = False
|
154
|
+
value_tuple = [cast(NullableScalarDateValue, value)]
|
155
|
+
|
156
|
+
if len(value_tuple) not in {0, 1, 2}:
|
157
|
+
raise StreamlitAPIException(
|
158
|
+
"DateInput value should either be an date/datetime or a list/tuple of "
|
159
|
+
"0 - 2 date/datetime values"
|
160
|
+
)
|
161
|
+
|
162
|
+
parsed_dates = [_convert_datelike_to_date(v) for v in value_tuple]
|
163
|
+
|
164
|
+
return parsed_dates, is_range
|
165
|
+
|
166
|
+
|
167
|
+
def _parse_min_date(
|
168
|
+
min_value: NullableScalarDateValue,
|
169
|
+
parsed_dates: Sequence[date] | None,
|
170
|
+
) -> date:
|
171
|
+
parsed_min_date: date
|
172
|
+
if isinstance(min_value, (datetime, date, str)):
|
173
|
+
parsed_min_date = _convert_datelike_to_date(min_value)
|
174
|
+
elif min_value is None:
|
175
|
+
if parsed_dates:
|
176
|
+
parsed_min_date = adjust_years(parsed_dates[0], years=-10)
|
177
|
+
else:
|
178
|
+
parsed_min_date = adjust_years(date.today(), years=-10)
|
179
|
+
else:
|
180
|
+
raise StreamlitAPIException(
|
181
|
+
"DateInput min should either be a date/datetime or None"
|
182
|
+
)
|
183
|
+
return parsed_min_date
|
184
|
+
|
185
|
+
|
186
|
+
def _parse_max_date(
|
187
|
+
max_value: NullableScalarDateValue,
|
188
|
+
parsed_dates: Sequence[date] | None,
|
189
|
+
) -> date:
|
190
|
+
parsed_max_date: date
|
191
|
+
if isinstance(max_value, (datetime, date, str)):
|
192
|
+
parsed_max_date = _convert_datelike_to_date(max_value)
|
193
|
+
elif max_value is None:
|
194
|
+
if parsed_dates:
|
195
|
+
parsed_max_date = adjust_years(parsed_dates[-1], years=10)
|
196
|
+
else:
|
197
|
+
parsed_max_date = adjust_years(date.today(), years=10)
|
198
|
+
else:
|
199
|
+
raise StreamlitAPIException(
|
200
|
+
"DateInput max should either be a date/datetime or None"
|
201
|
+
)
|
202
|
+
return parsed_max_date
|
203
|
+
|
204
|
+
|
205
|
+
@dataclass(frozen=True)
|
206
|
+
class _DateInputValues:
|
207
|
+
value: Sequence[date] | None
|
208
|
+
is_range: bool
|
209
|
+
max: date
|
210
|
+
min: date
|
211
|
+
|
212
|
+
@classmethod
|
213
|
+
def from_raw_values(
|
214
|
+
cls,
|
215
|
+
value: DateValue,
|
216
|
+
min_value: NullableScalarDateValue,
|
217
|
+
max_value: NullableScalarDateValue,
|
218
|
+
) -> _DateInputValues:
|
219
|
+
parsed_value, is_range = _parse_date_value(value=value)
|
220
|
+
parsed_min = _parse_min_date(
|
221
|
+
min_value=min_value,
|
222
|
+
parsed_dates=parsed_value,
|
223
|
+
)
|
224
|
+
parsed_max = _parse_max_date(
|
225
|
+
max_value=max_value,
|
226
|
+
parsed_dates=parsed_value,
|
227
|
+
)
|
228
|
+
|
229
|
+
if value == "today":
|
230
|
+
v = cast(list[date], parsed_value)[0]
|
231
|
+
if v < parsed_min:
|
232
|
+
parsed_value = [parsed_min]
|
233
|
+
if v > parsed_max:
|
234
|
+
parsed_value = [parsed_max]
|
235
|
+
|
236
|
+
return cls(
|
237
|
+
value=parsed_value,
|
238
|
+
is_range=is_range,
|
239
|
+
min=parsed_min,
|
240
|
+
max=parsed_max,
|
241
|
+
)
|
242
|
+
|
243
|
+
def __post_init__(self) -> None:
|
244
|
+
if self.min > self.max:
|
245
|
+
raise StreamlitAPIException(
|
246
|
+
f"The `min_value`, set to {self.min}, shouldn't be larger "
|
247
|
+
f"than the `max_value`, set to {self.max}."
|
248
|
+
)
|
249
|
+
|
250
|
+
if self.value:
|
251
|
+
start_value = self.value[0]
|
252
|
+
end_value = self.value[-1]
|
253
|
+
|
254
|
+
if (start_value < self.min) or (end_value > self.max):
|
255
|
+
raise StreamlitAPIException(
|
256
|
+
f"The default `value` of {self.value} "
|
257
|
+
f"must lie between the `min_value` of {self.min} "
|
258
|
+
f"and the `max_value` of {self.max}, inclusively."
|
259
|
+
)
|
260
|
+
|
261
|
+
|
262
|
+
@dataclass
|
263
|
+
class TimeInputSerde:
|
264
|
+
value: time | None
|
265
|
+
|
266
|
+
def deserialize(self, ui_value: str | None, widget_id: Any = "") -> time | None:
|
267
|
+
return (
|
268
|
+
datetime.strptime(ui_value, "%H:%M").time()
|
269
|
+
if ui_value is not None
|
270
|
+
else self.value
|
271
|
+
)
|
272
|
+
|
273
|
+
def serialize(self, v: datetime | time | None) -> str | None:
|
274
|
+
if v is None:
|
275
|
+
return None
|
276
|
+
if isinstance(v, datetime):
|
277
|
+
v = v.time()
|
278
|
+
return time.strftime(v, "%H:%M")
|
279
|
+
|
280
|
+
|
281
|
+
@dataclass
|
282
|
+
class DateInputSerde:
|
283
|
+
value: _DateInputValues
|
284
|
+
|
285
|
+
def deserialize(
|
286
|
+
self,
|
287
|
+
ui_value: Any,
|
288
|
+
widget_id: str = "",
|
289
|
+
) -> DateWidgetReturn:
|
290
|
+
return_value: Sequence[date] | None
|
291
|
+
if ui_value is not None:
|
292
|
+
return_value = tuple(
|
293
|
+
datetime.strptime(v, "%Y/%m/%d").date() for v in ui_value
|
294
|
+
)
|
295
|
+
else:
|
296
|
+
return_value = self.value.value
|
297
|
+
|
298
|
+
if return_value is None or len(return_value) == 0:
|
299
|
+
return () if self.value.is_range else None
|
300
|
+
|
301
|
+
if not self.value.is_range:
|
302
|
+
return return_value[0]
|
303
|
+
return cast(DateWidgetReturn, tuple(return_value))
|
304
|
+
|
305
|
+
def serialize(self, v: DateWidgetReturn) -> list[str]:
|
306
|
+
if v is None:
|
307
|
+
return []
|
308
|
+
|
309
|
+
to_serialize = list(v) if isinstance(v, Sequence) else [v]
|
310
|
+
return [date.strftime(v, "%Y/%m/%d") for v in to_serialize]
|
311
|
+
|
312
|
+
|
313
|
+
class TimeWidgetsMixin:
|
314
|
+
@overload
|
315
|
+
def time_input(
|
316
|
+
self,
|
317
|
+
label: str,
|
318
|
+
value: TimeValue = "now",
|
319
|
+
key: Key | None = None,
|
320
|
+
help: str | None = None,
|
321
|
+
on_change: WidgetCallback | None = None,
|
322
|
+
args: WidgetArgs | None = None,
|
323
|
+
kwargs: WidgetKwargs | None = None,
|
324
|
+
*, # keyword-only arguments:
|
325
|
+
disabled: bool = False,
|
326
|
+
label_visibility: LabelVisibility = "visible",
|
327
|
+
step: int | timedelta = timedelta(minutes=DEFAULT_STEP_MINUTES),
|
328
|
+
) -> time:
|
329
|
+
pass
|
330
|
+
|
331
|
+
@overload
|
332
|
+
def time_input(
|
333
|
+
self,
|
334
|
+
label: str,
|
335
|
+
value: None = None,
|
336
|
+
key: Key | None = None,
|
337
|
+
help: str | None = None,
|
338
|
+
on_change: WidgetCallback | None = None,
|
339
|
+
args: WidgetArgs | None = None,
|
340
|
+
kwargs: WidgetKwargs | None = None,
|
341
|
+
*, # keyword-only arguments:
|
342
|
+
disabled: bool = False,
|
343
|
+
label_visibility: LabelVisibility = "visible",
|
344
|
+
step: int | timedelta = timedelta(minutes=DEFAULT_STEP_MINUTES),
|
345
|
+
) -> time | None:
|
346
|
+
pass
|
347
|
+
|
348
|
+
@gather_metrics("time_input")
|
349
|
+
def time_input(
|
350
|
+
self,
|
351
|
+
label: str,
|
352
|
+
value: TimeValue | None = "now",
|
353
|
+
key: Key | None = None,
|
354
|
+
help: str | None = None,
|
355
|
+
on_change: WidgetCallback | None = None,
|
356
|
+
args: WidgetArgs | None = None,
|
357
|
+
kwargs: WidgetKwargs | None = None,
|
358
|
+
*, # keyword-only arguments:
|
359
|
+
disabled: bool = False,
|
360
|
+
label_visibility: LabelVisibility = "visible",
|
361
|
+
step: int | timedelta = timedelta(minutes=DEFAULT_STEP_MINUTES),
|
362
|
+
) -> time | None:
|
363
|
+
r"""Display a time input widget.
|
364
|
+
|
365
|
+
Parameters
|
366
|
+
----------
|
367
|
+
label : str
|
368
|
+
A short label explaining to the user what this time input is for.
|
369
|
+
The label can optionally contain GitHub-flavored Markdown of the
|
370
|
+
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
|
371
|
+
and Images. Images display like icons, with a max height equal to
|
372
|
+
the font height.
|
373
|
+
|
374
|
+
Unsupported Markdown elements are unwrapped so only their children
|
375
|
+
(text contents) render. Display unsupported elements as literal
|
376
|
+
characters by backslash-escaping them. E.g.,
|
377
|
+
``"1\. Not an ordered list"``.
|
378
|
+
|
379
|
+
See the ``body`` parameter of |st.markdown|_ for additional,
|
380
|
+
supported Markdown directives.
|
381
|
+
|
382
|
+
For accessibility reasons, you should never set an empty label, but
|
383
|
+
you can hide it with ``label_visibility`` if needed. In the future,
|
384
|
+
we may disallow empty labels by raising an exception.
|
385
|
+
|
386
|
+
.. |st.markdown| replace:: ``st.markdown``
|
387
|
+
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
388
|
+
|
389
|
+
value : "now", datetime.time, datetime.datetime, str, or None
|
390
|
+
The value of this widget when it first renders. This can be one of
|
391
|
+
the following:
|
392
|
+
|
393
|
+
- ``"now"`` (default): The widget initializes with the current time.
|
394
|
+
- A ``datetime.time`` or ``datetime.datetime`` object: The widget
|
395
|
+
initializes with the given time, ignoring any date if included.
|
396
|
+
- An ISO-formatted time ("hh:mm", "hh:mm:ss", or "hh:mm:ss.sss") or
|
397
|
+
datetime ("YYYY-MM-DD hh:mm:ss") string: The widget initializes
|
398
|
+
with the given time, ignoring any date if included.
|
399
|
+
- ``None``: The widget initializes with no time and returns
|
400
|
+
``None`` until the user selects a time.
|
401
|
+
|
402
|
+
key : str or int
|
403
|
+
An optional string or integer to use as the unique key for the widget.
|
404
|
+
If this is omitted, a key will be generated for the widget
|
405
|
+
based on its content. No two widgets may have the same key.
|
406
|
+
|
407
|
+
help : str or None
|
408
|
+
A tooltip that gets displayed next to the widget label. Streamlit
|
409
|
+
only displays the tooltip when ``label_visibility="visible"``. If
|
410
|
+
this is ``None`` (default), no tooltip is displayed.
|
411
|
+
|
412
|
+
The tooltip can optionally contain GitHub-flavored Markdown,
|
413
|
+
including the Markdown directives described in the ``body``
|
414
|
+
parameter of ``st.markdown``.
|
415
|
+
|
416
|
+
on_change : callable
|
417
|
+
An optional callback invoked when this time_input's value changes.
|
418
|
+
|
419
|
+
args : tuple
|
420
|
+
An optional tuple of args to pass to the callback.
|
421
|
+
|
422
|
+
kwargs : dict
|
423
|
+
An optional dict of kwargs to pass to the callback.
|
424
|
+
|
425
|
+
disabled : bool
|
426
|
+
An optional boolean that disables the time input if set to
|
427
|
+
``True``. The default is ``False``.
|
428
|
+
|
429
|
+
label_visibility : "visible", "hidden", or "collapsed"
|
430
|
+
The visibility of the label. The default is ``"visible"``. If this
|
431
|
+
is ``"hidden"``, Streamlit displays an empty spacer instead of the
|
432
|
+
label, which can help keep the widget alligned with other widgets.
|
433
|
+
If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
434
|
+
|
435
|
+
step : int or timedelta
|
436
|
+
The stepping interval in seconds. Defaults to 900, i.e. 15 minutes.
|
437
|
+
You can also pass a datetime.timedelta object.
|
438
|
+
|
439
|
+
Returns
|
440
|
+
-------
|
441
|
+
datetime.time or None
|
442
|
+
The current value of the time input widget or ``None`` if no time has been
|
443
|
+
selected.
|
444
|
+
|
445
|
+
Example
|
446
|
+
-------
|
447
|
+
>>> import datetime
|
448
|
+
>>> import streamlit as st
|
449
|
+
>>>
|
450
|
+
>>> t = st.time_input("Set an alarm for", datetime.time(8, 45))
|
451
|
+
>>> st.write("Alarm is set for", t)
|
452
|
+
|
453
|
+
.. output::
|
454
|
+
https://doc-time-input.streamlit.app/
|
455
|
+
height: 260px
|
456
|
+
|
457
|
+
To initialize an empty time input, use ``None`` as the value:
|
458
|
+
|
459
|
+
>>> import datetime
|
460
|
+
>>> import streamlit as st
|
461
|
+
>>>
|
462
|
+
>>> t = st.time_input("Set an alarm for", value=None)
|
463
|
+
>>> st.write("Alarm is set for", t)
|
464
|
+
|
465
|
+
.. output::
|
466
|
+
https://doc-time-input-empty.streamlit.app/
|
467
|
+
height: 260px
|
468
|
+
|
469
|
+
"""
|
470
|
+
ctx = get_script_run_ctx()
|
471
|
+
return self._time_input(
|
472
|
+
label=label,
|
473
|
+
value=value,
|
474
|
+
key=key,
|
475
|
+
help=help,
|
476
|
+
on_change=on_change,
|
477
|
+
args=args,
|
478
|
+
kwargs=kwargs,
|
479
|
+
disabled=disabled,
|
480
|
+
label_visibility=label_visibility,
|
481
|
+
step=step,
|
482
|
+
ctx=ctx,
|
483
|
+
)
|
484
|
+
|
485
|
+
def _time_input(
|
486
|
+
self,
|
487
|
+
label: str,
|
488
|
+
value: TimeValue | None = "now",
|
489
|
+
key: Key | None = None,
|
490
|
+
help: str | None = None,
|
491
|
+
on_change: WidgetCallback | None = None,
|
492
|
+
args: WidgetArgs | None = None,
|
493
|
+
kwargs: WidgetKwargs | None = None,
|
494
|
+
*, # keyword-only arguments:
|
495
|
+
disabled: bool = False,
|
496
|
+
label_visibility: LabelVisibility = "visible",
|
497
|
+
step: int | timedelta = timedelta(minutes=DEFAULT_STEP_MINUTES),
|
498
|
+
ctx: ScriptRunContext | None = None,
|
499
|
+
) -> time | None:
|
500
|
+
key = to_key(key)
|
501
|
+
|
502
|
+
check_widget_policies(
|
503
|
+
self.dg,
|
504
|
+
key,
|
505
|
+
on_change,
|
506
|
+
default_value=value if value != "now" else None,
|
507
|
+
)
|
508
|
+
maybe_raise_label_warnings(label, label_visibility)
|
509
|
+
|
510
|
+
parsed_time: time | None
|
511
|
+
if value is None:
|
512
|
+
parsed_time = None
|
513
|
+
else:
|
514
|
+
parsed_time = _convert_timelike_to_time(value)
|
515
|
+
|
516
|
+
element_id = compute_and_register_element_id(
|
517
|
+
"time_input",
|
518
|
+
user_key=key,
|
519
|
+
form_id=current_form_id(self.dg),
|
520
|
+
label=label,
|
521
|
+
value=parsed_time if isinstance(value, (datetime, time)) else value,
|
522
|
+
help=help,
|
523
|
+
step=step,
|
524
|
+
)
|
525
|
+
del value
|
526
|
+
|
527
|
+
session_state = get_session_state().filtered_state
|
528
|
+
if key is not None and key in session_state and session_state[key] is None:
|
529
|
+
parsed_time = None
|
530
|
+
|
531
|
+
time_input_proto = TimeInputProto()
|
532
|
+
time_input_proto.id = element_id
|
533
|
+
time_input_proto.label = label
|
534
|
+
if parsed_time is not None:
|
535
|
+
time_input_proto.default = time.strftime(parsed_time, "%H:%M")
|
536
|
+
time_input_proto.form_id = current_form_id(self.dg)
|
537
|
+
if not isinstance(step, (int, timedelta)):
|
538
|
+
raise StreamlitAPIException(
|
539
|
+
f"`step` can only be `int` or `timedelta` but {type(step)} is provided."
|
540
|
+
)
|
541
|
+
if isinstance(step, timedelta):
|
542
|
+
step = step.seconds
|
543
|
+
if step < 60 or step > timedelta(hours=23).seconds:
|
544
|
+
raise StreamlitAPIException(
|
545
|
+
f"`step` must be between 60 seconds and 23 hours but is currently set to {step} seconds."
|
546
|
+
)
|
547
|
+
time_input_proto.step = step
|
548
|
+
time_input_proto.disabled = disabled
|
549
|
+
time_input_proto.label_visibility.value = get_label_visibility_proto_value(
|
550
|
+
label_visibility
|
551
|
+
)
|
552
|
+
|
553
|
+
if help is not None:
|
554
|
+
time_input_proto.help = dedent(help)
|
555
|
+
|
556
|
+
serde = TimeInputSerde(parsed_time)
|
557
|
+
widget_state = register_widget(
|
558
|
+
time_input_proto.id,
|
559
|
+
on_change_handler=on_change,
|
560
|
+
args=args,
|
561
|
+
kwargs=kwargs,
|
562
|
+
deserializer=serde.deserialize,
|
563
|
+
serializer=serde.serialize,
|
564
|
+
ctx=ctx,
|
565
|
+
value_type="string_value",
|
566
|
+
)
|
567
|
+
|
568
|
+
if widget_state.value_changed:
|
569
|
+
if (serialized_value := serde.serialize(widget_state.value)) is not None:
|
570
|
+
time_input_proto.value = serialized_value
|
571
|
+
time_input_proto.set_value = True
|
572
|
+
|
573
|
+
self.dg._enqueue("time_input", time_input_proto)
|
574
|
+
return widget_state.value
|
575
|
+
|
576
|
+
@overload
|
577
|
+
def date_input(
|
578
|
+
self,
|
579
|
+
label: str,
|
580
|
+
value: date | datetime | str | Literal["today"] = "today",
|
581
|
+
min_value: NullableScalarDateValue = None,
|
582
|
+
max_value: NullableScalarDateValue = None,
|
583
|
+
key: Key | None = None,
|
584
|
+
help: str | None = None,
|
585
|
+
on_change: WidgetCallback | None = None,
|
586
|
+
args: WidgetArgs | None = None,
|
587
|
+
kwargs: WidgetKwargs | None = None,
|
588
|
+
*, # keyword-only arguments:
|
589
|
+
format: str = "YYYY/MM/DD",
|
590
|
+
disabled: bool = False,
|
591
|
+
label_visibility: LabelVisibility = "visible",
|
592
|
+
) -> date: ...
|
593
|
+
|
594
|
+
@overload
|
595
|
+
def date_input(
|
596
|
+
self,
|
597
|
+
label: str,
|
598
|
+
value: None,
|
599
|
+
min_value: NullableScalarDateValue = None,
|
600
|
+
max_value: NullableScalarDateValue = None,
|
601
|
+
key: Key | None = None,
|
602
|
+
help: str | None = None,
|
603
|
+
on_change: WidgetCallback | None = None,
|
604
|
+
args: WidgetArgs | None = None,
|
605
|
+
kwargs: WidgetKwargs | None = None,
|
606
|
+
*, # keyword-only arguments:
|
607
|
+
format: str = "YYYY/MM/DD",
|
608
|
+
disabled: bool = False,
|
609
|
+
label_visibility: LabelVisibility = "visible",
|
610
|
+
) -> date | None: ...
|
611
|
+
|
612
|
+
@overload
|
613
|
+
def date_input(
|
614
|
+
self,
|
615
|
+
label: str,
|
616
|
+
value: tuple[NullableScalarDateValue]
|
617
|
+
| tuple[NullableScalarDateValue, NullableScalarDateValue]
|
618
|
+
| list[NullableScalarDateValue],
|
619
|
+
min_value: NullableScalarDateValue = None,
|
620
|
+
max_value: NullableScalarDateValue = None,
|
621
|
+
key: Key | None = None,
|
622
|
+
help: str | None = None,
|
623
|
+
on_change: WidgetCallback | None = None,
|
624
|
+
args: WidgetArgs | None = None,
|
625
|
+
kwargs: WidgetKwargs | None = None,
|
626
|
+
*, # keyword-only arguments:
|
627
|
+
format: str = "YYYY/MM/DD",
|
628
|
+
disabled: bool = False,
|
629
|
+
label_visibility: LabelVisibility = "visible",
|
630
|
+
) -> DateWidgetRangeReturn: ...
|
631
|
+
|
632
|
+
@gather_metrics("date_input")
|
633
|
+
def date_input(
|
634
|
+
self,
|
635
|
+
label: str,
|
636
|
+
value: DateValue = "today",
|
637
|
+
min_value: NullableScalarDateValue = None,
|
638
|
+
max_value: NullableScalarDateValue = None,
|
639
|
+
key: Key | None = None,
|
640
|
+
help: str | None = None,
|
641
|
+
on_change: WidgetCallback | None = None,
|
642
|
+
args: WidgetArgs | None = None,
|
643
|
+
kwargs: WidgetKwargs | None = None,
|
644
|
+
*, # keyword-only arguments:
|
645
|
+
format: str = "YYYY/MM/DD",
|
646
|
+
disabled: bool = False,
|
647
|
+
label_visibility: LabelVisibility = "visible",
|
648
|
+
) -> DateWidgetReturn:
|
649
|
+
r"""Display a date input widget.
|
650
|
+
|
651
|
+
The first day of the week is determined from the user's locale in their
|
652
|
+
browser.
|
653
|
+
|
654
|
+
Parameters
|
655
|
+
----------
|
656
|
+
label : str
|
657
|
+
A short label explaining to the user what this date input is for.
|
658
|
+
The label can optionally contain GitHub-flavored Markdown of the
|
659
|
+
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
|
660
|
+
and Images. Images display like icons, with a max height equal to
|
661
|
+
the font height.
|
662
|
+
|
663
|
+
Unsupported Markdown elements are unwrapped so only their children
|
664
|
+
(text contents) render. Display unsupported elements as literal
|
665
|
+
characters by backslash-escaping them. E.g.,
|
666
|
+
``"1\. Not an ordered list"``.
|
667
|
+
|
668
|
+
See the ``body`` parameter of |st.markdown|_ for additional,
|
669
|
+
supported Markdown directives.
|
670
|
+
|
671
|
+
For accessibility reasons, you should never set an empty label, but
|
672
|
+
you can hide it with ``label_visibility`` if needed. In the future,
|
673
|
+
we may disallow empty labels by raising an exception.
|
674
|
+
|
675
|
+
.. |st.markdown| replace:: ``st.markdown``
|
676
|
+
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
677
|
+
|
678
|
+
value : "today", datetime.date, datetime.datetime, str, list/tuple of these, or None
|
679
|
+
The value of this widget when it first renders. This can be one of
|
680
|
+
the following:
|
681
|
+
|
682
|
+
- ``"today"`` (default): The widget initializes with the current date.
|
683
|
+
- A ``datetime.date`` or ``datetime.datetime`` object: The widget
|
684
|
+
initializes with the given date, ignoring any time if included.
|
685
|
+
- An ISO-formatted date ("YYYY-MM-DD") or datetime
|
686
|
+
("YYYY-MM-DD hh:mm:ss") string: The widget initializes with the
|
687
|
+
given date, ignoring any time if included.
|
688
|
+
- A list or tuple with up to two of the above: The widget will
|
689
|
+
initialize with the given date interval and return a tuple of the
|
690
|
+
selected interval. You can pass an empty list to initialize the
|
691
|
+
widget with an empty interval or a list with one value to
|
692
|
+
initialize only the beginning date of the iterval.
|
693
|
+
- ``None``: The widget initializes with no date and returns
|
694
|
+
``None`` until the user selects a date.
|
695
|
+
|
696
|
+
min_value : "today", datetime.date, datetime.datetime, str, or None
|
697
|
+
The minimum selectable date. This can be any of the date types
|
698
|
+
accepted by ``value``, except list or tuple.
|
699
|
+
|
700
|
+
If this is ``None`` (default), the minimum selectable date is ten
|
701
|
+
years before the initial value. If the initial value is an
|
702
|
+
interval, the minimum selectable date is ten years before the start
|
703
|
+
date of the interval. If no initial value is set, the minimum
|
704
|
+
selectable date is ten years before today.
|
705
|
+
|
706
|
+
max_value : "today", datetime.date, datetime.datetime, str, or None
|
707
|
+
The maximum selectable date. This can be any of the date types
|
708
|
+
accepted by ``value``, except list or tuple.
|
709
|
+
|
710
|
+
If this is ``None`` (default), the maximum selectable date is ten
|
711
|
+
years after the initial value. If the initial value is an interval,
|
712
|
+
the maximum selectable date is ten years after the end date of the
|
713
|
+
interval. If no initial value is set, the maximum selectable date
|
714
|
+
is ten years after today.
|
715
|
+
|
716
|
+
key : str or int
|
717
|
+
An optional string or integer to use as the unique key for the widget.
|
718
|
+
If this is omitted, a key will be generated for the widget
|
719
|
+
based on its content. No two widgets may have the same key.
|
720
|
+
|
721
|
+
help : str or None
|
722
|
+
A tooltip that gets displayed next to the widget label. Streamlit
|
723
|
+
only displays the tooltip when ``label_visibility="visible"``. If
|
724
|
+
this is ``None`` (default), no tooltip is displayed.
|
725
|
+
|
726
|
+
The tooltip can optionally contain GitHub-flavored Markdown,
|
727
|
+
including the Markdown directives described in the ``body``
|
728
|
+
parameter of ``st.markdown``.
|
729
|
+
|
730
|
+
on_change : callable
|
731
|
+
An optional callback invoked when this date_input's value changes.
|
732
|
+
|
733
|
+
args : tuple
|
734
|
+
An optional tuple of args to pass to the callback.
|
735
|
+
|
736
|
+
kwargs : dict
|
737
|
+
An optional dict of kwargs to pass to the callback.
|
738
|
+
|
739
|
+
format : str
|
740
|
+
A format string controlling how the interface should display dates.
|
741
|
+
Supports "YYYY/MM/DD" (default), "DD/MM/YYYY", or "MM/DD/YYYY".
|
742
|
+
You may also use a period (.) or hyphen (-) as separators.
|
743
|
+
|
744
|
+
disabled : bool
|
745
|
+
An optional boolean that disables the date input if set to
|
746
|
+
``True``. The default is ``False``.
|
747
|
+
|
748
|
+
label_visibility : "visible", "hidden", or "collapsed"
|
749
|
+
The visibility of the label. The default is ``"visible"``. If this
|
750
|
+
is ``"hidden"``, Streamlit displays an empty spacer instead of the
|
751
|
+
label, which can help keep the widget alligned with other widgets.
|
752
|
+
If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
753
|
+
|
754
|
+
Returns
|
755
|
+
-------
|
756
|
+
datetime.date or a tuple with 0-2 dates or None
|
757
|
+
The current value of the date input widget or ``None`` if no date has been
|
758
|
+
selected.
|
759
|
+
|
760
|
+
Examples
|
761
|
+
--------
|
762
|
+
>>> import datetime
|
763
|
+
>>> import streamlit as st
|
764
|
+
>>>
|
765
|
+
>>> d = st.date_input("When's your birthday", datetime.date(2019, 7, 6))
|
766
|
+
>>> st.write("Your birthday is:", d)
|
767
|
+
|
768
|
+
.. output::
|
769
|
+
https://doc-date-input.streamlit.app/
|
770
|
+
height: 380px
|
771
|
+
|
772
|
+
>>> import datetime
|
773
|
+
>>> import streamlit as st
|
774
|
+
>>>
|
775
|
+
>>> today = datetime.datetime.now()
|
776
|
+
>>> next_year = today.year + 1
|
777
|
+
>>> jan_1 = datetime.date(next_year, 1, 1)
|
778
|
+
>>> dec_31 = datetime.date(next_year, 12, 31)
|
779
|
+
>>>
|
780
|
+
>>> d = st.date_input(
|
781
|
+
... "Select your vacation for next year",
|
782
|
+
... (jan_1, datetime.date(next_year, 1, 7)),
|
783
|
+
... jan_1,
|
784
|
+
... dec_31,
|
785
|
+
... format="MM.DD.YYYY",
|
786
|
+
... )
|
787
|
+
>>> d
|
788
|
+
|
789
|
+
.. output::
|
790
|
+
https://doc-date-input1.streamlit.app/
|
791
|
+
height: 380px
|
792
|
+
|
793
|
+
To initialize an empty date input, use ``None`` as the value:
|
794
|
+
|
795
|
+
>>> import datetime
|
796
|
+
>>> import streamlit as st
|
797
|
+
>>>
|
798
|
+
>>> d = st.date_input("When's your birthday", value=None)
|
799
|
+
>>> st.write("Your birthday is:", d)
|
800
|
+
|
801
|
+
.. output::
|
802
|
+
https://doc-date-input-empty.streamlit.app/
|
803
|
+
height: 380px
|
804
|
+
|
805
|
+
"""
|
806
|
+
ctx = get_script_run_ctx()
|
807
|
+
return self._date_input(
|
808
|
+
label=label,
|
809
|
+
value=value,
|
810
|
+
min_value=min_value,
|
811
|
+
max_value=max_value,
|
812
|
+
key=key,
|
813
|
+
help=help,
|
814
|
+
on_change=on_change,
|
815
|
+
args=args,
|
816
|
+
kwargs=kwargs,
|
817
|
+
disabled=disabled,
|
818
|
+
label_visibility=label_visibility,
|
819
|
+
format=format,
|
820
|
+
ctx=ctx,
|
821
|
+
)
|
822
|
+
|
823
|
+
def _date_input(
|
824
|
+
self,
|
825
|
+
label: str,
|
826
|
+
value: DateValue = "today",
|
827
|
+
min_value: NullableScalarDateValue = None,
|
828
|
+
max_value: NullableScalarDateValue = None,
|
829
|
+
key: Key | None = None,
|
830
|
+
help: str | None = None,
|
831
|
+
on_change: WidgetCallback | None = None,
|
832
|
+
args: WidgetArgs | None = None,
|
833
|
+
kwargs: WidgetKwargs | None = None,
|
834
|
+
*, # keyword-only arguments:
|
835
|
+
format: str = "YYYY/MM/DD",
|
836
|
+
disabled: bool = False,
|
837
|
+
label_visibility: LabelVisibility = "visible",
|
838
|
+
ctx: ScriptRunContext | None = None,
|
839
|
+
) -> DateWidgetReturn:
|
840
|
+
key = to_key(key)
|
841
|
+
|
842
|
+
check_widget_policies(
|
843
|
+
self.dg,
|
844
|
+
key,
|
845
|
+
on_change,
|
846
|
+
default_value=value if value != "today" else None,
|
847
|
+
)
|
848
|
+
maybe_raise_label_warnings(label, label_visibility)
|
849
|
+
|
850
|
+
def parse_date_deterministic_for_id(v: NullableScalarDateValue) -> str | None:
|
851
|
+
if v == "today":
|
852
|
+
# For ID purposes, no need to parse the input string.
|
853
|
+
return None
|
854
|
+
if isinstance(v, str):
|
855
|
+
# For ID purposes, no need to parse the input string.
|
856
|
+
return v
|
857
|
+
if isinstance(v, datetime):
|
858
|
+
return date.strftime(v.date(), "%Y/%m/%d")
|
859
|
+
if isinstance(v, date):
|
860
|
+
return date.strftime(v, "%Y/%m/%d")
|
861
|
+
|
862
|
+
return None
|
863
|
+
|
864
|
+
parsed_min_date = parse_date_deterministic_for_id(min_value)
|
865
|
+
parsed_max_date = parse_date_deterministic_for_id(max_value)
|
866
|
+
|
867
|
+
parsed: str | None | list[str | None]
|
868
|
+
if value == "today":
|
869
|
+
parsed = None
|
870
|
+
elif isinstance(value, Sequence):
|
871
|
+
parsed = [
|
872
|
+
parse_date_deterministic_for_id(cast(NullableScalarDateValue, v))
|
873
|
+
for v in value
|
874
|
+
]
|
875
|
+
else:
|
876
|
+
parsed = parse_date_deterministic_for_id(value)
|
877
|
+
|
878
|
+
# TODO: this is missing the error path, integrate with the dateinputvalues parsing
|
879
|
+
|
880
|
+
element_id = compute_and_register_element_id(
|
881
|
+
"date_input",
|
882
|
+
user_key=key,
|
883
|
+
form_id=current_form_id(self.dg),
|
884
|
+
label=label,
|
885
|
+
value=parsed,
|
886
|
+
min_value=parsed_min_date,
|
887
|
+
max_value=parsed_max_date,
|
888
|
+
help=help,
|
889
|
+
format=format,
|
890
|
+
)
|
891
|
+
if not bool(ALLOWED_DATE_FORMATS.match(format)):
|
892
|
+
raise StreamlitAPIException(
|
893
|
+
f"The provided format (`{format}`) is not valid. DateInput format "
|
894
|
+
"should be one of `YYYY/MM/DD`, `DD/MM/YYYY`, or `MM/DD/YYYY` "
|
895
|
+
"and can also use a period (.) or hyphen (-) as separators."
|
896
|
+
)
|
897
|
+
|
898
|
+
parsed_values = _DateInputValues.from_raw_values(
|
899
|
+
value=value,
|
900
|
+
min_value=min_value,
|
901
|
+
max_value=max_value,
|
902
|
+
)
|
903
|
+
|
904
|
+
if value == "today":
|
905
|
+
# We need to know if this is a single or range date_input, but don't have
|
906
|
+
# a default value, so we check if session_state can tell us.
|
907
|
+
# We already calculated the id, so there is no risk of this causing
|
908
|
+
# the id to change.
|
909
|
+
|
910
|
+
session_state = get_session_state().filtered_state
|
911
|
+
|
912
|
+
if key is not None and key in session_state:
|
913
|
+
state_value = session_state[key]
|
914
|
+
parsed_values = _DateInputValues.from_raw_values(
|
915
|
+
value=state_value,
|
916
|
+
min_value=min_value,
|
917
|
+
max_value=max_value,
|
918
|
+
)
|
919
|
+
|
920
|
+
del value, min_value, max_value
|
921
|
+
|
922
|
+
date_input_proto = DateInputProto()
|
923
|
+
date_input_proto.id = element_id
|
924
|
+
date_input_proto.is_range = parsed_values.is_range
|
925
|
+
date_input_proto.disabled = disabled
|
926
|
+
date_input_proto.label_visibility.value = get_label_visibility_proto_value(
|
927
|
+
label_visibility
|
928
|
+
)
|
929
|
+
date_input_proto.format = format
|
930
|
+
date_input_proto.label = label
|
931
|
+
if parsed_values.value is None:
|
932
|
+
# An empty array represents the empty state. The reason for using an empty
|
933
|
+
# array here is that we cannot optional keyword for repeated fields
|
934
|
+
# in protobuf.
|
935
|
+
date_input_proto.default[:] = []
|
936
|
+
else:
|
937
|
+
date_input_proto.default[:] = [
|
938
|
+
date.strftime(v, "%Y/%m/%d") for v in parsed_values.value
|
939
|
+
]
|
940
|
+
date_input_proto.min = date.strftime(parsed_values.min, "%Y/%m/%d")
|
941
|
+
date_input_proto.max = date.strftime(parsed_values.max, "%Y/%m/%d")
|
942
|
+
date_input_proto.form_id = current_form_id(self.dg)
|
943
|
+
|
944
|
+
if help is not None:
|
945
|
+
date_input_proto.help = dedent(help)
|
946
|
+
|
947
|
+
serde = DateInputSerde(parsed_values)
|
948
|
+
|
949
|
+
widget_state = register_widget(
|
950
|
+
date_input_proto.id,
|
951
|
+
on_change_handler=on_change,
|
952
|
+
args=args,
|
953
|
+
kwargs=kwargs,
|
954
|
+
deserializer=serde.deserialize,
|
955
|
+
serializer=serde.serialize,
|
956
|
+
ctx=ctx,
|
957
|
+
value_type="string_array_value",
|
958
|
+
)
|
959
|
+
|
960
|
+
if widget_state.value_changed:
|
961
|
+
date_input_proto.value[:] = serde.serialize(widget_state.value)
|
962
|
+
date_input_proto.set_value = True
|
963
|
+
|
964
|
+
self.dg._enqueue("date_input", date_input_proto)
|
965
|
+
return widget_state.value
|
966
|
+
|
967
|
+
@property
|
968
|
+
def dg(self) -> DeltaGenerator:
|
969
|
+
"""Get our DeltaGenerator."""
|
970
|
+
return cast("DeltaGenerator", self)
|