streamlit 1.45.1__py3-none-any.whl → 1.46.1__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 +5 -1
- streamlit/auth_util.py +12 -12
- streamlit/cli_util.py +4 -3
- streamlit/column_config.py +11 -9
- streamlit/commands/echo.py +6 -4
- streamlit/commands/execution_control.py +33 -32
- streamlit/commands/experimental_query_params.py +2 -2
- streamlit/commands/logo.py +9 -4
- streamlit/commands/navigation.py +61 -18
- streamlit/commands/page_config.py +57 -47
- streamlit/components/types/base_custom_component.py +7 -7
- streamlit/components/v1/component_registry.py +7 -3
- streamlit/components/v1/components.py +1 -1
- streamlit/components/v1/custom_component.py +8 -8
- streamlit/config.py +289 -144
- streamlit/config_option.py +19 -15
- streamlit/config_util.py +29 -23
- streamlit/connections/__init__.py +2 -2
- streamlit/connections/base_connection.py +5 -5
- streamlit/connections/snowflake_connection.py +13 -11
- streamlit/connections/snowpark_connection.py +3 -3
- streamlit/connections/sql_connection.py +20 -18
- streamlit/connections/util.py +2 -2
- streamlit/cursor.py +6 -6
- streamlit/dataframe_util.py +52 -52
- streamlit/delta_generator.py +46 -48
- streamlit/delta_generator_singletons.py +3 -3
- streamlit/deprecation_util.py +6 -6
- streamlit/elements/alert.py +37 -29
- streamlit/elements/arrow.py +40 -22
- streamlit/elements/code.py +46 -13
- streamlit/elements/deck_gl_json_chart.py +38 -27
- streamlit/elements/dialog_decorator.py +3 -4
- streamlit/elements/doc_string.py +64 -58
- streamlit/elements/exception.py +23 -27
- streamlit/elements/form.py +41 -0
- streamlit/elements/graphviz_chart.py +1 -1
- streamlit/elements/heading.py +60 -9
- streamlit/elements/html.py +3 -4
- streamlit/elements/image.py +8 -9
- streamlit/elements/json.py +21 -2
- streamlit/elements/layouts.py +120 -31
- streamlit/elements/lib/built_in_chart_utils.py +96 -73
- streamlit/elements/lib/color_util.py +3 -3
- streamlit/elements/lib/column_config_utils.py +2 -4
- streamlit/elements/lib/column_types.py +14 -8
- streamlit/elements/lib/dialog.py +9 -5
- streamlit/elements/lib/image_utils.py +39 -40
- streamlit/elements/lib/js_number.py +4 -4
- streamlit/elements/lib/layout_utils.py +65 -1
- streamlit/elements/lib/mutable_status_container.py +14 -3
- streamlit/elements/lib/options_selector_utils.py +22 -12
- streamlit/elements/lib/pandas_styler_utils.py +25 -21
- streamlit/elements/lib/policies.py +6 -5
- streamlit/elements/lib/streamlit_plotly_theme.py +54 -53
- streamlit/elements/lib/subtitle_utils.py +6 -9
- streamlit/elements/lib/utils.py +20 -5
- streamlit/elements/map.py +32 -56
- streamlit/elements/markdown.py +101 -12
- streamlit/elements/media.py +78 -21
- streamlit/elements/metric.py +32 -16
- streamlit/elements/plotly_chart.py +15 -15
- streamlit/elements/progress.py +33 -15
- streamlit/elements/spinner.py +31 -6
- streamlit/elements/text.py +21 -1
- streamlit/elements/toast.py +1 -2
- streamlit/elements/vega_charts.py +54 -23
- streamlit/elements/widgets/audio_input.py +24 -7
- streamlit/elements/widgets/button.py +26 -19
- streamlit/elements/widgets/button_group.py +10 -15
- streamlit/elements/widgets/camera_input.py +27 -7
- streamlit/elements/widgets/chat.py +91 -38
- streamlit/elements/widgets/checkbox.py +45 -4
- streamlit/elements/widgets/color_picker.py +40 -17
- streamlit/elements/widgets/data_editor.py +76 -37
- streamlit/elements/widgets/file_uploader.py +42 -13
- streamlit/elements/widgets/multiselect.py +7 -10
- streamlit/elements/widgets/number_input.py +123 -47
- streamlit/elements/widgets/radio.py +59 -13
- streamlit/elements/widgets/select_slider.py +35 -30
- streamlit/elements/widgets/selectbox.py +56 -9
- streamlit/elements/widgets/slider.py +190 -99
- streamlit/elements/widgets/text_widgets.py +54 -8
- streamlit/elements/widgets/time_widgets.py +53 -14
- streamlit/elements/write.py +5 -8
- streamlit/env_util.py +2 -7
- streamlit/error_util.py +16 -9
- streamlit/errors.py +69 -48
- streamlit/external/langchain/streamlit_callback_handler.py +10 -5
- streamlit/file_util.py +27 -10
- streamlit/git_util.py +29 -24
- streamlit/hello/animation_demo.py +9 -9
- streamlit/hello/dataframe_demo.py +5 -5
- streamlit/hello/hello.py +1 -0
- streamlit/hello/mapping_demo.py +7 -8
- streamlit/hello/plotting_demo.py +3 -3
- streamlit/hello/streamlit_app.py +28 -26
- streamlit/hello/utils.py +2 -1
- streamlit/logger.py +10 -11
- streamlit/navigation/page.py +11 -8
- streamlit/proto/Audio_pb2.py +4 -3
- streamlit/proto/Audio_pb2.pyi +8 -1
- streamlit/proto/Block_pb2.py +38 -29
- streamlit/proto/Block_pb2.pyi +72 -4
- streamlit/proto/ClientState_pb2.py +4 -4
- streamlit/proto/ClientState_pb2.pyi +7 -2
- streamlit/proto/Code_pb2.py +4 -2
- streamlit/proto/Code_pb2.pyi +1 -0
- streamlit/proto/DataFrame_pb2.pyi +1 -1
- streamlit/proto/DeckGlJsonChart_pb2.pyi +1 -1
- streamlit/proto/Element_pb2.py +5 -3
- streamlit/proto/Element_pb2.pyi +20 -3
- streamlit/proto/GapSize_pb2.py +29 -0
- streamlit/proto/GapSize_pb2.pyi +70 -0
- streamlit/proto/HeightConfig_pb2.py +27 -0
- streamlit/proto/HeightConfig_pb2.pyi +48 -0
- streamlit/proto/NamedDataSet_pb2.pyi +1 -1
- streamlit/proto/Navigation_pb2.py +3 -3
- streamlit/proto/Navigation_pb2.pyi +4 -0
- streamlit/proto/NewSession_pb2.py +18 -16
- streamlit/proto/NewSession_pb2.pyi +29 -3
- streamlit/proto/PageConfig_pb2.py +7 -7
- streamlit/proto/PageConfig_pb2.pyi +21 -1
- streamlit/proto/Video_pb2.py +8 -7
- streamlit/proto/Video_pb2.pyi +8 -1
- streamlit/proto/WidthConfig_pb2.py +2 -2
- streamlit/proto/WidthConfig_pb2.pyi +15 -1
- streamlit/runtime/__init__.py +1 -1
- streamlit/runtime/app_session.py +53 -40
- streamlit/runtime/caching/__init__.py +9 -9
- streamlit/runtime/caching/cache_data_api.py +36 -30
- streamlit/runtime/caching/cache_errors.py +4 -4
- streamlit/runtime/caching/cache_resource_api.py +8 -8
- streamlit/runtime/caching/cache_utils.py +15 -14
- streamlit/runtime/caching/cached_message_replay.py +14 -8
- streamlit/runtime/caching/hashing.py +91 -97
- streamlit/runtime/caching/legacy_cache_api.py +2 -2
- streamlit/runtime/caching/storage/cache_storage_protocol.py +1 -1
- streamlit/runtime/caching/storage/dummy_cache_storage.py +1 -1
- streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py +12 -14
- streamlit/runtime/caching/storage/local_disk_cache_storage.py +6 -6
- streamlit/runtime/connection_factory.py +36 -36
- streamlit/runtime/context.py +58 -9
- streamlit/runtime/credentials.py +29 -40
- streamlit/runtime/forward_msg_queue.py +11 -11
- streamlit/runtime/fragment.py +7 -7
- streamlit/runtime/media_file_manager.py +3 -4
- streamlit/runtime/memory_media_file_storage.py +6 -5
- streamlit/runtime/memory_uploaded_file_manager.py +2 -2
- streamlit/runtime/metrics_util.py +11 -12
- streamlit/runtime/pages_manager.py +4 -6
- streamlit/runtime/runtime.py +8 -6
- streamlit/runtime/runtime_util.py +7 -6
- streamlit/runtime/scriptrunner/__init__.py +4 -4
- streamlit/runtime/scriptrunner/exec_code.py +12 -5
- streamlit/runtime/scriptrunner/magic.py +16 -12
- streamlit/runtime/scriptrunner/script_cache.py +1 -1
- streamlit/runtime/scriptrunner/script_runner.py +53 -29
- streamlit/runtime/scriptrunner_utils/exceptions.py +1 -1
- streamlit/runtime/scriptrunner_utils/script_requests.py +7 -4
- streamlit/runtime/scriptrunner_utils/script_run_context.py +10 -23
- streamlit/runtime/secrets.py +40 -35
- streamlit/runtime/session_manager.py +2 -1
- streamlit/runtime/state/__init__.py +5 -5
- streamlit/runtime/state/common.py +2 -2
- streamlit/runtime/state/query_params.py +13 -15
- streamlit/runtime/state/query_params_proxy.py +17 -13
- streamlit/runtime/state/safe_session_state.py +2 -2
- streamlit/runtime/state/session_state.py +52 -34
- streamlit/runtime/stats.py +2 -2
- streamlit/runtime/uploaded_file_manager.py +1 -1
- streamlit/runtime/websocket_session_manager.py +10 -6
- streamlit/source_util.py +8 -6
- streamlit/static/index.html +3 -17
- streamlit/static/manifest.json +1180 -0
- streamlit/static/static/css/{index.DqDwtg6_.css → index.CJVRHjQZ.css} +1 -1
- streamlit/static/static/js/{ErrorOutline.esm.DU9IrB3M.js → ErrorOutline.esm.DitPpe1Y.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.P9rKwKo8.js → FileDownload.esm.AI3watX9.js} +1 -1
- streamlit/static/static/js/{FileHelper.D7RMkx0e.js → FileHelper.kt7mhnu8.js} +5 -5
- streamlit/static/static/js/{FormClearHelper.B67tgll0.js → FormClearHelper.D1M9GM_c.js} +1 -1
- streamlit/static/static/js/{Hooks.ncTJktu9.js → Hooks.BGwHKeUc.js} +1 -1
- streamlit/static/static/js/{InputInstructions.D-Y8geDN.js → InputInstructions.DaZ89mzH.js} +1 -1
- streamlit/static/static/js/{ProgressBar.B-kexwwD.js → ProgressBar.C0zPMe-p.js} +2 -2
- streamlit/static/static/js/{RenderInPortalIfExists.BgaoZgep.js → RenderInPortalIfExists.Ox8gQvdz.js} +1 -1
- streamlit/static/static/js/Toolbar.KhlcEc0K.js +1 -0
- streamlit/static/static/js/UploadFileInfo.0DCkpDDf.js +6 -0
- streamlit/static/static/js/{base-input.BoAa1U94.js → base-input.BJ4qsfSq.js} +4 -4
- streamlit/static/static/js/{checkbox.Z6iSfe5F.js → checkbox.DSDh78Xz.js} +2 -2
- streamlit/static/static/js/{createSuper.B4oGDYRm.js → createSuper.wQ9SIXEJ.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.msYws2Ou.js → data-grid-overlay-editor.DvbdPJ15.js} +1 -1
- streamlit/static/static/js/{downloader.kc14n2Hv.js → downloader.CD9rzih5.js} +1 -1
- streamlit/static/static/js/{es6.CxQz807-.js → es6.48Q9Qjgb.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.B19u0ONI.js → iframeResizer.contentWindow.CKdem3Bn.js} +1 -1
- streamlit/static/static/js/{index.LaIasviC.js → index.6md5Qhod.js} +1 -1
- streamlit/static/static/js/index.7hy6AeJ1.js +1 -0
- streamlit/static/static/js/index.B4CGJiBW.js +1 -0
- streamlit/static/static/js/index.B8oW0ZTD.js +1 -0
- streamlit/static/static/js/index.BU6RnlHI.js +73 -0
- streamlit/static/static/js/index.BUq9Wcf8.js +197 -0
- streamlit/static/static/js/{index.BFz9U2y0.js → index.BXXo-Yoj.js} +1 -1
- streamlit/static/static/js/index.Bae9H0OS.js +1 -0
- streamlit/static/static/js/{index.-5ruC9At.js → index.BhTl2Uyb.js} +1 -1
- streamlit/static/static/js/{index.BpILzHf_.js → index.BiSaCB1o.js} +20 -20
- streamlit/static/static/js/{index.xNQq3Ei5.js → index.BulSAJ9z.js} +1 -1
- streamlit/static/static/js/{index.9V1KdxfP.js → index.Bv-EuTKR.js} +1 -1
- streamlit/static/static/js/index.BvMLYCHi.js +1 -0
- streamlit/static/static/js/index.C1NIn1Y2.js +783 -0
- streamlit/static/static/js/index.CP-fthOJ.js +2 -0
- streamlit/static/static/js/{index.BoigZiu7.js → index.CS9guO3p.js} +1 -1
- streamlit/static/static/js/index.CYTBHth8.js +1 -0
- streamlit/static/static/js/{index.CmTAF0dM.js → index.CcJufcuD.js} +1 -1
- streamlit/static/static/js/index.CnENU1yn.js +1 -0
- streamlit/static/static/js/index.Cns13qBb.js +1 -0
- streamlit/static/static/js/index.Ct_xXq7w.js +1 -0
- streamlit/static/static/js/{index.BqfdT8-Q.js → index.CxGSemHL.js} +1 -1
- streamlit/static/static/js/index.D5S0ldVb.js +1 -0
- streamlit/static/static/js/index.D72B_ksb.js +2 -0
- streamlit/static/static/js/index.DI4yZ27M.js +1 -0
- streamlit/static/static/js/index.DN51vLxR.js +1 -0
- streamlit/static/static/js/index.DRtq5dka.js +1 -0
- streamlit/static/static/js/{index.BHXxWdde.js → index.DX-oiXlb.js} +1 -1
- streamlit/static/static/js/index.DlFE4_Aq.js +12 -0
- streamlit/static/static/js/{index.BHGGDa8K.js → index.J7BJwXOi.js} +2 -2
- streamlit/static/static/js/index.Jg38kJPP.js +1 -0
- streamlit/static/static/js/index.JhIO6abf.js +3 -0
- streamlit/static/static/js/{index.DeB9iKFW.js → index.NkRcWwc5.js} +255 -255
- streamlit/static/static/js/{index.BGga-hcS.js → index.prekPLrm.js} +25 -25
- streamlit/static/static/js/{index.BRXmLIsC.js → index.wyzngKUE.js} +1 -1
- streamlit/static/static/js/index.xW7mVdI8.js +1 -0
- streamlit/static/static/js/index.yk07dYGx.js +1 -0
- streamlit/static/static/js/{input.DsCfafm0.js → input.CxKZ5Wrc.js} +2 -2
- streamlit/static/static/js/{memory.nY_lMTtu.js → memory.DeZ9VUvl.js} +1 -1
- streamlit/static/static/js/{mergeWith.B_7zmsM4.js → mergeWith.CVkhrWUb.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.CSeVhHRU.js → number-overlay-editor.Bpkm3nTq.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.nNhsvgRd.js → possibleConstructorReturn.CIDCId52.js} +1 -1
- streamlit/static/static/js/{sandbox.Cgm3iuL6.js → sandbox.TrkMaokR.js} +1 -1
- streamlit/static/static/js/{textarea.BR8rlyih.js → textarea.QKjxR64N.js} +2 -2
- streamlit/static/static/js/{timepicker.w4XhAenH.js → timepicker.DJYmE1dK.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.CgkEPBwD.js → toConsumableArray.BZoworE-.js} +1 -1
- streamlit/static/static/js/{uniqueId.j-1rlNNH.js → uniqueId.O0UbJ2Bu.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.zXY9CjFS.js → useBasicWidgetState.Ci89jaH5.js} +1 -1
- streamlit/static/static/js/useOnInputChange.Cxh6ExEn.js +1 -0
- streamlit/static/static/js/{withFullScreenWrapper.Ov13692o.js → withFullScreenWrapper.iW37lS8Z.js} +1 -1
- streamlit/static/static/media/SourceCodeVF-Italic.ttf.Ba1oaZG1.woff2 +0 -0
- streamlit/static/static/media/SourceCodeVF-Upright.ttf.BjWn63N-.woff2 +0 -0
- streamlit/static/static/media/SourceSansVF-Italic.ttf.Bt9VkdQ3.woff2 +0 -0
- streamlit/static/static/media/SourceSansVF-Upright.ttf.BsWL4Kly.woff2 +0 -0
- streamlit/static/static/media/SourceSerifVariable-Italic.ttf.CVdzAtxO.woff2 +0 -0
- streamlit/static/static/media/SourceSerifVariable-Roman.ttf.mdpVL9bi.woff2 +0 -0
- streamlit/string_util.py +14 -19
- streamlit/temporary_directory.py +13 -4
- streamlit/testing/v1/app_test.py +15 -10
- streamlit/testing/v1/element_tree.py +157 -178
- streamlit/testing/v1/local_script_runner.py +11 -15
- streamlit/testing/v1/util.py +11 -4
- streamlit/type_util.py +8 -12
- streamlit/url_util.py +1 -1
- streamlit/user_info.py +6 -5
- streamlit/util.py +25 -1
- streamlit/vendor/pympler/asizeof.py +3 -2
- streamlit/watcher/event_based_path_watcher.py +21 -2
- streamlit/watcher/folder_black_list.py +2 -2
- streamlit/watcher/local_sources_watcher.py +64 -18
- streamlit/watcher/path_watcher.py +6 -10
- streamlit/watcher/polling_path_watcher.py +8 -7
- streamlit/watcher/util.py +7 -6
- streamlit/web/bootstrap.py +16 -14
- streamlit/web/cli.py +52 -45
- streamlit/web/server/__init__.py +7 -3
- streamlit/web/server/app_static_file_handler.py +1 -1
- streamlit/web/server/authlib_tornado_integration.py +9 -4
- streamlit/web/server/browser_websocket_handler.py +8 -2
- streamlit/web/server/component_request_handler.py +14 -10
- streamlit/web/server/media_file_handler.py +14 -7
- streamlit/web/server/oauth_authlib_routes.py +41 -9
- streamlit/web/server/oidc_mixin.py +35 -17
- streamlit/web/server/routes.py +32 -22
- streamlit/web/server/server.py +13 -24
- streamlit/web/server/server_util.py +43 -9
- streamlit/web/server/stats_request_handler.py +7 -5
- streamlit/web/server/upload_file_request_handler.py +22 -19
- streamlit/web/server/websocket_headers.py +1 -1
- {streamlit-1.45.1.dist-info → streamlit-1.46.1.dist-info}/METADATA +4 -4
- streamlit-1.46.1.dist-info/RECORD +559 -0
- {streamlit-1.45.1.dist-info → streamlit-1.46.1.dist-info}/WHEEL +1 -1
- streamlit/elements/lib/event_utils.py +0 -39
- streamlit/static/static/js/Toolbar.D9RUZv9G.js +0 -1
- streamlit/static/static/js/UploadFileInfo.C-jY39rj.js +0 -1
- streamlit/static/static/js/index.8jhZBWF2.js +0 -3
- streamlit/static/static/js/index.BCx3C6e_.js +0 -1
- streamlit/static/static/js/index.BRuTz_S4.js +0 -1
- streamlit/static/static/js/index.Bcru_ti-.js +0 -1
- streamlit/static/static/js/index.Bl1FMJRd.js +0 -1
- streamlit/static/static/js/index.C1z8KpLA.js +0 -779
- streamlit/static/static/js/index.C32I2PUe.js +0 -2
- streamlit/static/static/js/index.C5GnDRB7.js +0 -1
- streamlit/static/static/js/index.CG4qPaaW.js +0 -2
- streamlit/static/static/js/index.C_msmT1u.js +0 -1
- streamlit/static/static/js/index.CbeNTdd6.js +0 -1
- streamlit/static/static/js/index.CnGQVJcw.js +0 -12
- streamlit/static/static/js/index.CopVVq4l.js +0 -1
- streamlit/static/static/js/index.CtXupx4d.js +0 -197
- streamlit/static/static/js/index.DGmCchO7.js +0 -1
- streamlit/static/static/js/index.DH6zBk0e.js +0 -1
- streamlit/static/static/js/index.DHVlVWsm.js +0 -1
- streamlit/static/static/js/index.DRKIVBoi.js +0 -1
- streamlit/static/static/js/index.DUd-lFXx.js +0 -73
- streamlit/static/static/js/index.D_uRBA4B.js +0 -1
- streamlit/static/static/js/index.QHNfgPJd.js +0 -1
- streamlit/static/static/js/index.a-RJocYL.js +0 -1
- streamlit/static/static/js/index.cvz4B1gy.js +0 -1
- streamlit/static/static/js/index.t--hEgTQ.js +0 -6
- streamlit/static/static/js/useOnInputChange.z04u96A8.js +0 -1
- 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-1.45.1.dist-info/RECORD +0 -568
- {streamlit-1.45.1.data → streamlit-1.46.1.data}/scripts/streamlit.cmd +0 -0
- {streamlit-1.45.1.dist-info → streamlit-1.46.1.dist-info}/entry_points.txt +0 -0
- {streamlit-1.45.1.dist-info → streamlit-1.46.1.dist-info}/top_level.txt +0 -0
|
@@ -23,6 +23,7 @@ from typing import (
|
|
|
23
23
|
TYPE_CHECKING,
|
|
24
24
|
Any,
|
|
25
25
|
Final,
|
|
26
|
+
TypedDict,
|
|
26
27
|
TypeVar,
|
|
27
28
|
Union,
|
|
28
29
|
cast,
|
|
@@ -33,6 +34,7 @@ from typing_extensions import TypeAlias
|
|
|
33
34
|
|
|
34
35
|
from streamlit.elements.lib.form_utils import current_form_id
|
|
35
36
|
from streamlit.elements.lib.js_number import JSNumber, JSNumberBoundsException
|
|
37
|
+
from streamlit.elements.lib.layout_utils import LayoutConfig, validate_width
|
|
36
38
|
from streamlit.elements.lib.policies import (
|
|
37
39
|
check_widget_policies,
|
|
38
40
|
maybe_raise_label_warnings,
|
|
@@ -62,6 +64,7 @@ from streamlit.runtime.state import (
|
|
|
62
64
|
|
|
63
65
|
if TYPE_CHECKING:
|
|
64
66
|
from streamlit.delta_generator import DeltaGenerator
|
|
67
|
+
from streamlit.elements.lib.layout_utils import WidthWithoutContent
|
|
65
68
|
|
|
66
69
|
SliderNumericT = TypeVar("SliderNumericT", int, float)
|
|
67
70
|
SliderDatelikeT = TypeVar("SliderDatelikeT", date, time, datetime)
|
|
@@ -82,8 +85,8 @@ SliderDatelikeSpanT: TypeAlias = Union[
|
|
|
82
85
|
StepNumericT: TypeAlias = SliderNumericT
|
|
83
86
|
StepDatelikeT: TypeAlias = timedelta
|
|
84
87
|
|
|
85
|
-
SliderStep = Union[int, float, timedelta]
|
|
86
|
-
SliderScalar = Union[int, float, date, time, datetime]
|
|
88
|
+
SliderStep: TypeAlias = Union[int, float, timedelta]
|
|
89
|
+
SliderScalar: TypeAlias = Union[int, float, date, time, datetime]
|
|
87
90
|
SliderValueT = TypeVar("SliderValueT", int, float, date, time, datetime)
|
|
88
91
|
SliderValueGeneric: TypeAlias = Union[
|
|
89
92
|
SliderValueT,
|
|
@@ -114,6 +117,15 @@ DAYS_TO_MICROS: Final = 24 * 60 * 60 * SECONDS_TO_MICROS
|
|
|
114
117
|
|
|
115
118
|
UTC_EPOCH: Final = datetime(1970, 1, 1, tzinfo=timezone.utc)
|
|
116
119
|
|
|
120
|
+
SUPPORTED_TYPES: Final = {
|
|
121
|
+
Integral: SliderProto.INT,
|
|
122
|
+
Real: SliderProto.FLOAT,
|
|
123
|
+
datetime: SliderProto.DATETIME,
|
|
124
|
+
date: SliderProto.DATE,
|
|
125
|
+
time: SliderProto.TIME,
|
|
126
|
+
}
|
|
127
|
+
TIMELIKE_TYPES: Final = (SliderProto.DATETIME, SliderProto.TIME, SliderProto.DATE)
|
|
128
|
+
|
|
117
129
|
|
|
118
130
|
def _time_to_datetime(time_: time) -> datetime:
|
|
119
131
|
# Note, here we pick an arbitrary date well after Unix epoch.
|
|
@@ -152,6 +164,13 @@ def _micros_to_datetime(micros: int, orig_tz: tzinfo | None) -> datetime:
|
|
|
152
164
|
return utc_dt.replace(tzinfo=orig_tz)
|
|
153
165
|
|
|
154
166
|
|
|
167
|
+
class SliderDefaultValues(TypedDict):
|
|
168
|
+
min_value: SliderScalar
|
|
169
|
+
max_value: SliderScalar
|
|
170
|
+
step: SliderStep
|
|
171
|
+
format: str
|
|
172
|
+
|
|
173
|
+
|
|
155
174
|
@dataclass
|
|
156
175
|
class SliderSerde:
|
|
157
176
|
value: list[float]
|
|
@@ -159,7 +178,7 @@ class SliderSerde:
|
|
|
159
178
|
single_value: bool
|
|
160
179
|
orig_tz: tzinfo | None
|
|
161
180
|
|
|
162
|
-
def deserialize_single_value(self, value: float):
|
|
181
|
+
def deserialize_single_value(self, value: float) -> SliderScalar:
|
|
163
182
|
if self.data_type == SliderProto.INT:
|
|
164
183
|
return int(value)
|
|
165
184
|
if self.data_type == SliderProto.DATETIME:
|
|
@@ -174,7 +193,7 @@ class SliderSerde:
|
|
|
174
193
|
)
|
|
175
194
|
return value
|
|
176
195
|
|
|
177
|
-
def deserialize(self, ui_value: list[float] | None
|
|
196
|
+
def deserialize(self, ui_value: list[float] | None) -> Any:
|
|
178
197
|
if ui_value is not None:
|
|
179
198
|
val = ui_value
|
|
180
199
|
else:
|
|
@@ -182,26 +201,31 @@ class SliderSerde:
|
|
|
182
201
|
val = self.value
|
|
183
202
|
|
|
184
203
|
# The widget always returns a float array, so fix the return type if necessary
|
|
185
|
-
|
|
186
|
-
return
|
|
204
|
+
deserialized_values = [self.deserialize_single_value(v) for v in val]
|
|
205
|
+
return (
|
|
206
|
+
deserialized_values[0] if self.single_value else tuple(deserialized_values)
|
|
207
|
+
)
|
|
187
208
|
|
|
188
209
|
def serialize(self, v: Any) -> list[Any]:
|
|
189
210
|
range_value = isinstance(v, (list, tuple))
|
|
190
|
-
|
|
211
|
+
# Convert to list to handle tuples
|
|
212
|
+
processed_value = list(v) if range_value else [v]
|
|
213
|
+
|
|
191
214
|
if self.data_type == SliderProto.DATE:
|
|
192
|
-
|
|
215
|
+
return [
|
|
216
|
+
_datetime_to_micros(_date_to_datetime(val)) for val in processed_value
|
|
217
|
+
]
|
|
193
218
|
if self.data_type == SliderProto.TIME:
|
|
194
|
-
|
|
219
|
+
return [
|
|
220
|
+
_datetime_to_micros(_time_to_datetime(val)) for val in processed_value
|
|
221
|
+
]
|
|
195
222
|
if self.data_type == SliderProto.DATETIME:
|
|
196
|
-
|
|
197
|
-
|
|
223
|
+
return [_datetime_to_micros(val) for val in processed_value]
|
|
224
|
+
# For numeric types, ensure they are floats if not already
|
|
225
|
+
return [float(val) for val in processed_value]
|
|
198
226
|
|
|
199
227
|
|
|
200
228
|
class SliderMixin:
|
|
201
|
-
# For easier readability, all the arguments with un-changing types across these overload signatures have been
|
|
202
|
-
# collapsed onto a single line.
|
|
203
|
-
|
|
204
|
-
# fmt: off
|
|
205
229
|
# If min/max/value/step are not provided, then we return an int.
|
|
206
230
|
# if ONLY step is provided, then it must be an int and we return an int.
|
|
207
231
|
@overload
|
|
@@ -210,11 +234,19 @@ class SliderMixin:
|
|
|
210
234
|
label: str,
|
|
211
235
|
min_value: None = None,
|
|
212
236
|
max_value: None = None,
|
|
213
|
-
value:
|
|
237
|
+
value: None = None,
|
|
214
238
|
step: int | None = None,
|
|
215
|
-
format: str | None = None,
|
|
216
|
-
|
|
217
|
-
|
|
239
|
+
format: str | None = None,
|
|
240
|
+
key: Key | None = None,
|
|
241
|
+
help: str | None = None,
|
|
242
|
+
on_change: WidgetCallback | None = None,
|
|
243
|
+
args: WidgetArgs | None = None,
|
|
244
|
+
kwargs: WidgetKwargs | None = None,
|
|
245
|
+
*,
|
|
246
|
+
disabled: bool = False,
|
|
247
|
+
label_visibility: LabelVisibility = "visible",
|
|
248
|
+
width: WidthWithoutContent = "stretch",
|
|
249
|
+
) -> int: ...
|
|
218
250
|
|
|
219
251
|
# If min-value or max_value is provided and a numeric type, and value (if provided)
|
|
220
252
|
# is a singular numeric, return the same numeric type.
|
|
@@ -226,9 +258,17 @@ class SliderMixin:
|
|
|
226
258
|
max_value: SliderNumericT | None = None,
|
|
227
259
|
value: SliderNumericT | None = None,
|
|
228
260
|
step: StepNumericT[SliderNumericT] | None = None,
|
|
229
|
-
format: str | None = None,
|
|
230
|
-
|
|
231
|
-
|
|
261
|
+
format: str | None = None,
|
|
262
|
+
key: Key | None = None,
|
|
263
|
+
help: str | None = None,
|
|
264
|
+
on_change: WidgetCallback | None = None,
|
|
265
|
+
args: WidgetArgs | None = None,
|
|
266
|
+
kwargs: WidgetKwargs | None = None,
|
|
267
|
+
*,
|
|
268
|
+
disabled: bool = False,
|
|
269
|
+
label_visibility: LabelVisibility = "visible",
|
|
270
|
+
width: WidthWithoutContent = "stretch",
|
|
271
|
+
) -> SliderNumericT: ...
|
|
232
272
|
|
|
233
273
|
# If value is provided and a sequence of numeric type,
|
|
234
274
|
# return a tuple of the same numeric type.
|
|
@@ -241,9 +281,16 @@ class SliderMixin:
|
|
|
241
281
|
*,
|
|
242
282
|
value: SliderNumericSpanT[SliderNumericT],
|
|
243
283
|
step: StepNumericT[SliderNumericT] | None = None,
|
|
244
|
-
format: str | None = None,
|
|
245
|
-
|
|
246
|
-
|
|
284
|
+
format: str | None = None,
|
|
285
|
+
key: Key | None = None,
|
|
286
|
+
help: str | None = None,
|
|
287
|
+
on_change: WidgetCallback | None = None,
|
|
288
|
+
args: WidgetArgs | None = None,
|
|
289
|
+
kwargs: WidgetKwargs | None = None,
|
|
290
|
+
disabled: bool = False,
|
|
291
|
+
label_visibility: LabelVisibility = "visible",
|
|
292
|
+
width: WidthWithoutContent = "stretch",
|
|
293
|
+
) -> tuple[SliderNumericT, SliderNumericT]: ...
|
|
247
294
|
|
|
248
295
|
# If value is provided positionally and a sequence of numeric type,
|
|
249
296
|
# return a tuple of the same numeric type.
|
|
@@ -254,11 +301,18 @@ class SliderMixin:
|
|
|
254
301
|
min_value: SliderNumericT,
|
|
255
302
|
max_value: SliderNumericT,
|
|
256
303
|
value: SliderNumericSpanT[SliderNumericT],
|
|
257
|
-
/,
|
|
258
304
|
step: StepNumericT[SliderNumericT] | None = None,
|
|
259
|
-
format: str | None = None,
|
|
260
|
-
|
|
261
|
-
|
|
305
|
+
format: str | None = None,
|
|
306
|
+
key: Key | None = None,
|
|
307
|
+
help: str | None = None,
|
|
308
|
+
on_change: WidgetCallback | None = None,
|
|
309
|
+
args: WidgetArgs | None = None,
|
|
310
|
+
kwargs: WidgetKwargs | None = None,
|
|
311
|
+
*,
|
|
312
|
+
disabled: bool = False,
|
|
313
|
+
label_visibility: LabelVisibility = "visible",
|
|
314
|
+
width: WidthWithoutContent = "stretch",
|
|
315
|
+
) -> tuple[SliderNumericT, SliderNumericT]: ...
|
|
262
316
|
|
|
263
317
|
# If min-value is provided and a datelike type, and value (if provided)
|
|
264
318
|
# is a singular datelike, return the same datelike type.
|
|
@@ -270,9 +324,17 @@ class SliderMixin:
|
|
|
270
324
|
max_value: SliderDatelikeT | None = None,
|
|
271
325
|
value: SliderDatelikeT | None = None,
|
|
272
326
|
step: StepDatelikeT | None = None,
|
|
273
|
-
format: str | None = None,
|
|
274
|
-
|
|
275
|
-
|
|
327
|
+
format: str | None = None,
|
|
328
|
+
key: Key | None = None,
|
|
329
|
+
help: str | None = None,
|
|
330
|
+
on_change: WidgetCallback | None = None,
|
|
331
|
+
args: WidgetArgs | None = None,
|
|
332
|
+
kwargs: WidgetKwargs | None = None,
|
|
333
|
+
*,
|
|
334
|
+
disabled: bool = False,
|
|
335
|
+
label_visibility: LabelVisibility = "visible",
|
|
336
|
+
width: WidthWithoutContent = "stretch",
|
|
337
|
+
) -> SliderDatelikeT: ...
|
|
276
338
|
|
|
277
339
|
# If max-value is provided and a datelike type, and value (if provided)
|
|
278
340
|
# is a singular datelike, return the same datelike type.
|
|
@@ -280,28 +342,42 @@ class SliderMixin:
|
|
|
280
342
|
def slider(
|
|
281
343
|
self,
|
|
282
344
|
label: str,
|
|
283
|
-
min_value:
|
|
345
|
+
min_value: None = None,
|
|
284
346
|
*,
|
|
285
347
|
max_value: SliderDatelikeT,
|
|
286
348
|
value: SliderDatelikeT | None = None,
|
|
287
349
|
step: StepDatelikeT | None = None,
|
|
288
|
-
format: str | None = None,
|
|
289
|
-
|
|
290
|
-
|
|
350
|
+
format: str | None = None,
|
|
351
|
+
key: Key | None = None,
|
|
352
|
+
help: str | None = None,
|
|
353
|
+
on_change: WidgetCallback | None = None,
|
|
354
|
+
args: WidgetArgs | None = None,
|
|
355
|
+
kwargs: WidgetKwargs | None = None,
|
|
356
|
+
disabled: bool = False,
|
|
357
|
+
label_visibility: LabelVisibility = "visible",
|
|
358
|
+
width: WidthWithoutContent = "stretch",
|
|
359
|
+
) -> SliderDatelikeT: ...
|
|
291
360
|
|
|
292
361
|
# If value is provided and a datelike type, return the same datelike type.
|
|
293
362
|
@overload
|
|
294
363
|
def slider(
|
|
295
364
|
self,
|
|
296
365
|
label: str,
|
|
297
|
-
min_value:
|
|
298
|
-
max_value:
|
|
366
|
+
min_value: None = None,
|
|
367
|
+
max_value: None = None,
|
|
299
368
|
*,
|
|
300
369
|
value: SliderDatelikeT,
|
|
301
370
|
step: StepDatelikeT | None = None,
|
|
302
|
-
format: str | None = None,
|
|
303
|
-
|
|
304
|
-
|
|
371
|
+
format: str | None = None,
|
|
372
|
+
key: Key | None = None,
|
|
373
|
+
help: str | None = None,
|
|
374
|
+
on_change: WidgetCallback | None = None,
|
|
375
|
+
args: WidgetArgs | None = None,
|
|
376
|
+
kwargs: WidgetKwargs | None = None,
|
|
377
|
+
disabled: bool = False,
|
|
378
|
+
label_visibility: LabelVisibility = "visible",
|
|
379
|
+
width: WidthWithoutContent = "stretch",
|
|
380
|
+
) -> SliderDatelikeT: ...
|
|
305
381
|
|
|
306
382
|
# If value is provided and a sequence of datelike type,
|
|
307
383
|
# return a tuple of the same datelike type.
|
|
@@ -312,11 +388,20 @@ class SliderMixin:
|
|
|
312
388
|
min_value: SliderDatelikeT | None = None,
|
|
313
389
|
max_value: SliderDatelikeT | None = None,
|
|
314
390
|
*,
|
|
315
|
-
value:
|
|
391
|
+
value: list[SliderDatelikeT]
|
|
392
|
+
| tuple[SliderDatelikeT]
|
|
393
|
+
| tuple[SliderDatelikeT, SliderDatelikeT],
|
|
316
394
|
step: StepDatelikeT | None = None,
|
|
317
|
-
format: str | None = None,
|
|
318
|
-
|
|
319
|
-
|
|
395
|
+
format: str | None = None,
|
|
396
|
+
key: Key | None = None,
|
|
397
|
+
help: str | None = None,
|
|
398
|
+
on_change: WidgetCallback | None = None,
|
|
399
|
+
args: WidgetArgs | None = None,
|
|
400
|
+
kwargs: WidgetKwargs | None = None,
|
|
401
|
+
disabled: bool = False,
|
|
402
|
+
label_visibility: LabelVisibility = "visible",
|
|
403
|
+
width: WidthWithoutContent = "stretch",
|
|
404
|
+
) -> tuple[SliderDatelikeT, SliderDatelikeT]: ...
|
|
320
405
|
|
|
321
406
|
# If value is provided positionally and a sequence of datelike type,
|
|
322
407
|
# return a tuple of the same datelike type.
|
|
@@ -329,11 +414,17 @@ class SliderMixin:
|
|
|
329
414
|
value: SliderDatelikeSpanT[SliderDatelikeT],
|
|
330
415
|
/,
|
|
331
416
|
step: StepDatelikeT | None = None,
|
|
332
|
-
format: str | None = None,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
417
|
+
format: str | None = None,
|
|
418
|
+
key: Key | None = None,
|
|
419
|
+
help: str | None = None,
|
|
420
|
+
on_change: WidgetCallback | None = None,
|
|
421
|
+
args: WidgetArgs | None = None,
|
|
422
|
+
kwargs: WidgetKwargs | None = None,
|
|
423
|
+
*,
|
|
424
|
+
disabled: bool = False,
|
|
425
|
+
label_visibility: LabelVisibility = "visible",
|
|
426
|
+
width: WidthWithoutContent = "stretch",
|
|
427
|
+
) -> tuple[SliderDatelikeT, SliderDatelikeT]: ...
|
|
337
428
|
|
|
338
429
|
# https://github.com/python/mypy/issues/17614
|
|
339
430
|
@gather_metrics("slider") # type: ignore[misc]
|
|
@@ -353,6 +444,7 @@ class SliderMixin:
|
|
|
353
444
|
*, # keyword-only arguments:
|
|
354
445
|
disabled: bool = False,
|
|
355
446
|
label_visibility: LabelVisibility = "visible",
|
|
447
|
+
width: WidthWithoutContent = "stretch",
|
|
356
448
|
) -> Any:
|
|
357
449
|
r"""Display a slider widget.
|
|
358
450
|
|
|
@@ -368,7 +460,7 @@ class SliderMixin:
|
|
|
368
460
|
|
|
369
461
|
.. note::
|
|
370
462
|
Integer values exceeding +/- ``(1<<53) - 1`` cannot be accurately
|
|
371
|
-
stored or returned by the widget due to serialization
|
|
463
|
+
stored or returned by the widget due to serialization constraints
|
|
372
464
|
between the Python server and JavaScript client. You must handle
|
|
373
465
|
such numbers as floats, leading to a loss in precision.
|
|
374
466
|
|
|
@@ -476,9 +568,19 @@ class SliderMixin:
|
|
|
476
568
|
label_visibility : "visible", "hidden", or "collapsed"
|
|
477
569
|
The visibility of the label. The default is ``"visible"``. If this
|
|
478
570
|
is ``"hidden"``, Streamlit displays an empty spacer instead of the
|
|
479
|
-
label, which can help keep the widget
|
|
571
|
+
label, which can help keep the widget aligned with other widgets.
|
|
480
572
|
If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
|
481
573
|
|
|
574
|
+
width : "stretch" or int
|
|
575
|
+
The width of the slider widget. This can be one of the
|
|
576
|
+
following:
|
|
577
|
+
|
|
578
|
+
- ``"stretch"`` (default): The width of the widget matches the
|
|
579
|
+
width of the parent container.
|
|
580
|
+
- An integer specifying the width in pixels: The widget has a
|
|
581
|
+
fixed width. If the specified width is greater than the width of
|
|
582
|
+
the parent container, the width of the widget matches the width
|
|
583
|
+
of the parent container.
|
|
482
584
|
|
|
483
585
|
Returns
|
|
484
586
|
-------
|
|
@@ -542,16 +644,17 @@ class SliderMixin:
|
|
|
542
644
|
kwargs=kwargs,
|
|
543
645
|
disabled=disabled,
|
|
544
646
|
label_visibility=label_visibility,
|
|
647
|
+
width=width,
|
|
545
648
|
ctx=ctx,
|
|
546
649
|
)
|
|
547
650
|
|
|
548
651
|
def _slider(
|
|
549
652
|
self,
|
|
550
653
|
label: str,
|
|
551
|
-
min_value=None,
|
|
552
|
-
max_value=None,
|
|
553
|
-
value=None,
|
|
554
|
-
step=None,
|
|
654
|
+
min_value: Any = None,
|
|
655
|
+
max_value: Any = None,
|
|
656
|
+
value: Any = None,
|
|
657
|
+
step: Any = None,
|
|
555
658
|
format: str | None = None,
|
|
556
659
|
key: Key | None = None,
|
|
557
660
|
help: str | None = None,
|
|
@@ -561,6 +664,7 @@ class SliderMixin:
|
|
|
561
664
|
*, # keyword-only arguments:
|
|
562
665
|
disabled: bool = False,
|
|
563
666
|
label_visibility: LabelVisibility = "visible",
|
|
667
|
+
width: WidthWithoutContent = "stretch",
|
|
564
668
|
ctx: ScriptRunContext | None = None,
|
|
565
669
|
) -> SliderReturn:
|
|
566
670
|
key = to_key(key)
|
|
@@ -577,6 +681,7 @@ class SliderMixin:
|
|
|
577
681
|
"slider",
|
|
578
682
|
user_key=key,
|
|
579
683
|
form_id=current_form_id(self.dg),
|
|
684
|
+
dg=self.dg,
|
|
580
685
|
label=label,
|
|
581
686
|
min_value=min_value,
|
|
582
687
|
max_value=max_value,
|
|
@@ -584,21 +689,13 @@ class SliderMixin:
|
|
|
584
689
|
step=step,
|
|
585
690
|
format=format,
|
|
586
691
|
help=help,
|
|
692
|
+
width=width,
|
|
587
693
|
)
|
|
588
694
|
|
|
589
|
-
SUPPORTED_TYPES = {
|
|
590
|
-
Integral: SliderProto.INT,
|
|
591
|
-
Real: SliderProto.FLOAT,
|
|
592
|
-
datetime: SliderProto.DATETIME,
|
|
593
|
-
date: SliderProto.DATE,
|
|
594
|
-
time: SliderProto.TIME,
|
|
595
|
-
}
|
|
596
|
-
TIMELIKE_TYPES = (SliderProto.DATETIME, SliderProto.TIME, SliderProto.DATE)
|
|
597
|
-
|
|
598
695
|
if value is None:
|
|
599
696
|
# We need to know if this is a single or range slider, but don't have
|
|
600
697
|
# a default value, so we check if session_state can tell us.
|
|
601
|
-
# We already
|
|
698
|
+
# We already calculated the id, so there is no risk of this causing
|
|
602
699
|
# the id to change.
|
|
603
700
|
|
|
604
701
|
single_value = True
|
|
@@ -629,15 +726,14 @@ class SliderMixin:
|
|
|
629
726
|
if single_value:
|
|
630
727
|
value = [value]
|
|
631
728
|
|
|
632
|
-
def value_to_generic_type(v):
|
|
729
|
+
def value_to_generic_type(v: Any) -> SliderProto.DataType.ValueType:
|
|
633
730
|
if isinstance(v, Integral):
|
|
634
731
|
return SUPPORTED_TYPES[Integral]
|
|
635
|
-
|
|
732
|
+
if isinstance(v, Real):
|
|
636
733
|
return SUPPORTED_TYPES[Real]
|
|
637
|
-
|
|
638
|
-
return SUPPORTED_TYPES[type(v)]
|
|
734
|
+
return SUPPORTED_TYPES[type(v)]
|
|
639
735
|
|
|
640
|
-
def all_same_type(items):
|
|
736
|
+
def all_same_type(items: Any) -> bool:
|
|
641
737
|
return len(set(map(value_to_generic_type, items))) < 2
|
|
642
738
|
|
|
643
739
|
if not all_same_type(value):
|
|
@@ -646,10 +742,9 @@ class SliderMixin:
|
|
|
646
742
|
f"But were: {list(map(type, value))}"
|
|
647
743
|
)
|
|
648
744
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
data_type = value_to_generic_type(value[0])
|
|
745
|
+
data_type = (
|
|
746
|
+
SliderProto.INT if len(value) == 0 else value_to_generic_type(value[0])
|
|
747
|
+
)
|
|
653
748
|
|
|
654
749
|
datetime_min = time.min
|
|
655
750
|
datetime_max = time.max
|
|
@@ -660,7 +755,7 @@ class SliderMixin:
|
|
|
660
755
|
datetime_min = value[0] - timedelta(days=14)
|
|
661
756
|
datetime_max = value[0] + timedelta(days=14)
|
|
662
757
|
|
|
663
|
-
|
|
758
|
+
defaults: Final = {
|
|
664
759
|
SliderProto.INT: {
|
|
665
760
|
"min_value": 0,
|
|
666
761
|
"max_value": 100,
|
|
@@ -694,18 +789,18 @@ class SliderMixin:
|
|
|
694
789
|
}
|
|
695
790
|
|
|
696
791
|
if min_value is None:
|
|
697
|
-
min_value =
|
|
792
|
+
min_value = defaults[data_type]["min_value"]
|
|
698
793
|
if max_value is None:
|
|
699
|
-
max_value =
|
|
794
|
+
max_value = defaults[data_type]["max_value"]
|
|
700
795
|
if step is None:
|
|
701
|
-
step =
|
|
796
|
+
step = defaults[data_type]["step"]
|
|
702
797
|
if data_type in (
|
|
703
798
|
SliderProto.DATETIME,
|
|
704
799
|
SliderProto.DATE,
|
|
705
800
|
) and max_value - min_value < timedelta(days=1):
|
|
706
801
|
step = timedelta(minutes=15)
|
|
707
802
|
if format is None:
|
|
708
|
-
format = cast("str",
|
|
803
|
+
format = cast("str", defaults[data_type]["format"]) # noqa: A001
|
|
709
804
|
|
|
710
805
|
if step == 0:
|
|
711
806
|
raise StreamlitAPIException(
|
|
@@ -726,17 +821,13 @@ class SliderMixin:
|
|
|
726
821
|
)
|
|
727
822
|
|
|
728
823
|
if not int_args and not float_args and not timelike_args:
|
|
729
|
-
|
|
824
|
+
msg = (
|
|
730
825
|
"Slider value arguments must be of matching types."
|
|
731
|
-
"\n`min_value` has
|
|
732
|
-
"\n`max_value` has
|
|
733
|
-
"\n`step` has
|
|
734
|
-
% {
|
|
735
|
-
"min_type": type(min_value).__name__,
|
|
736
|
-
"max_type": type(max_value).__name__,
|
|
737
|
-
"step": type(step).__name__,
|
|
738
|
-
}
|
|
826
|
+
f"\n`min_value` has {type(min_value).__name__} type."
|
|
827
|
+
f"\n`max_value` has {type(max_value).__name__} type."
|
|
828
|
+
f"\n`step` has {type(step).__name__} type."
|
|
739
829
|
)
|
|
830
|
+
raise StreamlitAPIException(msg)
|
|
740
831
|
|
|
741
832
|
# Ensure that the value matches arguments' types.
|
|
742
833
|
all_ints = data_type == SliderProto.INT and int_args
|
|
@@ -744,17 +835,13 @@ class SliderMixin:
|
|
|
744
835
|
all_timelikes = data_type in TIMELIKE_TYPES and timelike_args
|
|
745
836
|
|
|
746
837
|
if not all_ints and not all_floats and not all_timelikes:
|
|
747
|
-
|
|
838
|
+
msg = (
|
|
748
839
|
"Both value and arguments must be of the same type."
|
|
749
|
-
"\n`value` has
|
|
750
|
-
"\n`min_value` has
|
|
751
|
-
"\n`max_value` has
|
|
752
|
-
% {
|
|
753
|
-
"value_type": type(value).__name__,
|
|
754
|
-
"min_type": type(min_value).__name__,
|
|
755
|
-
"max_type": type(max_value).__name__,
|
|
756
|
-
}
|
|
840
|
+
f"\n`value` has {type(value).__name__} type."
|
|
841
|
+
f"\n`min_value` has {type(min_value).__name__} type."
|
|
842
|
+
f"\n`max_value` has {type(max_value).__name__} type."
|
|
757
843
|
)
|
|
844
|
+
raise StreamlitAPIException(msg)
|
|
758
845
|
|
|
759
846
|
# Ensure that min <= value(s) <= max, adjusting the bounds as necessary.
|
|
760
847
|
min_value = min(min_value, max_value)
|
|
@@ -869,6 +956,7 @@ class SliderMixin:
|
|
|
869
956
|
for value in serialized_values:
|
|
870
957
|
# Use the deserialized values for more readable error messages for dates/times
|
|
871
958
|
deserialized_value = serde.deserialize_single_value(value)
|
|
959
|
+
|
|
872
960
|
if value < slider_proto.min:
|
|
873
961
|
raise StreamlitValueBelowMinError(
|
|
874
962
|
value=deserialized_value,
|
|
@@ -883,7 +971,10 @@ class SliderMixin:
|
|
|
883
971
|
slider_proto.value[:] = serialized_values
|
|
884
972
|
slider_proto.set_value = True
|
|
885
973
|
|
|
886
|
-
|
|
974
|
+
validate_width(width)
|
|
975
|
+
layout_config = LayoutConfig(width=width)
|
|
976
|
+
|
|
977
|
+
self.dg._enqueue("slider", slider_proto, layout_config=layout_config)
|
|
887
978
|
return cast("SliderReturn", widget_state.value)
|
|
888
979
|
|
|
889
980
|
@property
|