streamlit 1.50.0__py3-none-any.whl → 1.52.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/__init__.py +5 -1
- streamlit/commands/execution_control.py +89 -14
- streamlit/commands/navigation.py +4 -6
- streamlit/commands/page_config.py +4 -6
- streamlit/components/v1/component_arrow.py +7 -7
- streamlit/components/v2/__init__.py +514 -0
- streamlit/components/v2/bidi_component/__init__.py +20 -0
- streamlit/components/v2/bidi_component/constants.py +29 -0
- streamlit/components/v2/bidi_component/main.py +534 -0
- streamlit/components/v2/bidi_component/serialization.py +272 -0
- streamlit/components/v2/bidi_component/state.py +92 -0
- streamlit/components/v2/component_definition_resolver.py +143 -0
- streamlit/components/v2/component_file_watcher.py +403 -0
- streamlit/components/v2/component_manager.py +439 -0
- streamlit/components/v2/component_manifest_handler.py +122 -0
- streamlit/components/v2/component_path_utils.py +245 -0
- streamlit/components/v2/component_registry.py +426 -0
- streamlit/components/v2/get_bidi_component_manager.py +51 -0
- streamlit/components/v2/manifest_scanner.py +615 -0
- streamlit/components/v2/presentation.py +198 -0
- streamlit/components/v2/types.py +324 -0
- streamlit/config.py +456 -53
- streamlit/config_option.py +4 -1
- streamlit/config_util.py +650 -1
- streamlit/connections/snowflake_connection.py +1 -1
- streamlit/connections/snowpark_connection.py +1 -1
- streamlit/dataframe_util.py +33 -26
- streamlit/delta_generator.py +13 -4
- streamlit/delta_generator_singletons.py +11 -15
- streamlit/deprecation_util.py +17 -6
- streamlit/elements/alert.py +16 -0
- streamlit/elements/arrow.py +68 -10
- streamlit/elements/bokeh_chart.py +10 -78
- streamlit/elements/code.py +2 -2
- streamlit/elements/deck_gl_json_chart.py +98 -40
- streamlit/elements/dialog_decorator.py +2 -1
- streamlit/elements/exception.py +4 -2
- streamlit/elements/form.py +27 -0
- streamlit/elements/graphviz_chart.py +1 -3
- streamlit/elements/heading.py +63 -10
- streamlit/elements/html.py +13 -2
- streamlit/elements/image.py +3 -5
- streamlit/elements/layouts.py +59 -33
- streamlit/elements/lib/built_in_chart_utils.py +50 -19
- streamlit/elements/lib/color_util.py +9 -19
- streamlit/elements/lib/column_config_utils.py +9 -12
- streamlit/elements/lib/column_types.py +40 -12
- streamlit/elements/lib/dialog.py +2 -2
- streamlit/elements/lib/image_utils.py +3 -5
- streamlit/elements/lib/layout_utils.py +100 -13
- streamlit/elements/lib/mutable_status_container.py +2 -2
- streamlit/elements/lib/options_selector_utils.py +2 -2
- streamlit/elements/lib/pandas_styler_utils.py +17 -9
- streamlit/elements/lib/shortcut_utils.py +152 -0
- streamlit/elements/lib/utils.py +4 -4
- streamlit/elements/map.py +80 -37
- streamlit/elements/markdown.py +50 -3
- streamlit/elements/media.py +5 -7
- streamlit/elements/metric.py +34 -6
- streamlit/elements/pdf.py +2 -4
- streamlit/elements/plotly_chart.py +197 -20
- streamlit/elements/progress.py +2 -4
- streamlit/elements/space.py +113 -0
- streamlit/elements/spinner.py +1 -1
- streamlit/elements/text.py +20 -3
- streamlit/elements/toast.py +2 -0
- streamlit/elements/vega_charts.py +356 -149
- streamlit/elements/widgets/audio_input.py +12 -11
- streamlit/elements/widgets/button.py +280 -43
- streamlit/elements/widgets/button_group.py +60 -9
- streamlit/elements/widgets/camera_input.py +3 -5
- streamlit/elements/widgets/chat.py +307 -43
- streamlit/elements/widgets/color_picker.py +8 -1
- streamlit/elements/widgets/data_editor.py +88 -44
- streamlit/elements/widgets/file_uploader.py +9 -11
- streamlit/elements/widgets/multiselect.py +4 -3
- streamlit/elements/widgets/number_input.py +4 -4
- streamlit/elements/widgets/radio.py +10 -3
- streamlit/elements/widgets/select_slider.py +8 -5
- streamlit/elements/widgets/selectbox.py +6 -3
- streamlit/elements/widgets/slider.py +38 -42
- streamlit/elements/widgets/text_widgets.py +2 -0
- streamlit/elements/widgets/time_widgets.py +587 -21
- streamlit/elements/write.py +27 -6
- streamlit/emojis.py +1 -1
- streamlit/errors.py +137 -0
- streamlit/git_util.py +1 -1
- streamlit/hello/hello.py +8 -0
- streamlit/hello/utils.py +2 -1
- streamlit/material_icon_names.py +1 -1
- streamlit/navigation/page.py +11 -1
- streamlit/net_util.py +2 -2
- streamlit/proto/Alert_pb2.pyi +3 -3
- streamlit/proto/AppPage_pb2.pyi +7 -1
- streamlit/proto/ArrowData_pb2.py +27 -0
- streamlit/proto/ArrowData_pb2.pyi +52 -0
- streamlit/proto/ArrowNamedDataSet_pb2.pyi +7 -1
- streamlit/proto/ArrowVegaLiteChart_pb2.pyi +7 -1
- streamlit/proto/Arrow_pb2.py +10 -10
- streamlit/proto/Arrow_pb2.pyi +19 -12
- streamlit/proto/AudioInput_pb2.pyi +7 -1
- streamlit/proto/Audio_pb2.pyi +7 -1
- streamlit/proto/AuthRedirect_pb2.pyi +7 -1
- streamlit/proto/AutoRerun_pb2.pyi +7 -1
- streamlit/proto/BackMsg_pb2.py +4 -2
- streamlit/proto/BackMsg_pb2.pyi +34 -4
- streamlit/proto/Balloons_pb2.pyi +7 -1
- streamlit/proto/BidiComponent_pb2.py +34 -0
- streamlit/proto/BidiComponent_pb2.pyi +159 -0
- streamlit/proto/Block_pb2.py +7 -7
- streamlit/proto/Block_pb2.pyi +39 -36
- streamlit/proto/BokehChart_pb2.pyi +7 -1
- streamlit/proto/ButtonGroup_pb2.pyi +9 -9
- streamlit/proto/Button_pb2.py +2 -2
- streamlit/proto/Button_pb2.pyi +11 -2
- streamlit/proto/CameraInput_pb2.pyi +7 -1
- streamlit/proto/ChatInput_pb2.py +6 -6
- streamlit/proto/ChatInput_pb2.pyi +18 -6
- streamlit/proto/Checkbox_pb2.pyi +3 -3
- streamlit/proto/ClientState_pb2.pyi +10 -4
- streamlit/proto/Code_pb2.pyi +7 -1
- streamlit/proto/ColorPicker_pb2.pyi +7 -1
- streamlit/proto/Common_pb2.py +3 -3
- streamlit/proto/Common_pb2.pyi +35 -23
- streamlit/proto/Components_pb2.pyi +19 -13
- streamlit/proto/DataFrame_pb2.pyi +55 -49
- streamlit/proto/DateInput_pb2.pyi +7 -1
- streamlit/proto/DateTimeInput_pb2.py +28 -0
- streamlit/proto/DateTimeInput_pb2.pyi +92 -0
- streamlit/proto/DeckGlJsonChart_pb2.py +10 -4
- streamlit/proto/DeckGlJsonChart_pb2.pyi +12 -6
- streamlit/proto/Delta_pb2.pyi +7 -1
- streamlit/proto/DocString_pb2.pyi +10 -4
- streamlit/proto/DownloadButton_pb2.py +2 -2
- streamlit/proto/DownloadButton_pb2.pyi +16 -2
- streamlit/proto/Element_pb2.py +7 -3
- streamlit/proto/Element_pb2.pyi +33 -5
- streamlit/proto/Empty_pb2.pyi +7 -1
- streamlit/proto/Exception_pb2.pyi +7 -1
- streamlit/proto/Favicon_pb2.pyi +7 -1
- streamlit/proto/FileUploader_pb2.pyi +7 -1
- streamlit/proto/ForwardMsg_pb2.py +12 -10
- streamlit/proto/ForwardMsg_pb2.pyi +42 -15
- streamlit/proto/GapSize_pb2.pyi +4 -4
- streamlit/proto/GitInfo_pb2.pyi +3 -3
- streamlit/proto/GraphVizChart_pb2.pyi +7 -1
- streamlit/proto/Heading_pb2.pyi +7 -1
- streamlit/proto/HeightConfig_pb2.py +2 -2
- streamlit/proto/HeightConfig_pb2.pyi +13 -4
- streamlit/proto/Html_pb2.py +2 -2
- streamlit/proto/Html_pb2.pyi +11 -2
- streamlit/proto/IFrame_pb2.pyi +7 -1
- streamlit/proto/Image_pb2.pyi +10 -4
- streamlit/proto/Json_pb2.pyi +7 -1
- streamlit/proto/LabelVisibilityMessage_pb2.pyi +3 -3
- streamlit/proto/LinkButton_pb2.py +2 -2
- streamlit/proto/LinkButton_pb2.pyi +15 -2
- streamlit/proto/Logo_pb2.pyi +7 -1
- streamlit/proto/Markdown_pb2.pyi +3 -3
- streamlit/proto/Metric_pb2.pyi +7 -7
- streamlit/proto/MetricsEvent_pb2.pyi +10 -4
- streamlit/proto/MultiSelect_pb2.pyi +7 -1
- streamlit/proto/NamedDataSet_pb2.pyi +7 -1
- streamlit/proto/Navigation_pb2.pyi +3 -3
- streamlit/proto/NewSession_pb2.py +18 -18
- streamlit/proto/NewSession_pb2.pyi +59 -40
- streamlit/proto/NumberInput_pb2.pyi +3 -3
- streamlit/proto/PageConfig_pb2.pyi +7 -7
- streamlit/proto/PageInfo_pb2.pyi +7 -1
- streamlit/proto/PageLink_pb2.py +2 -2
- streamlit/proto/PageLink_pb2.pyi +11 -2
- streamlit/proto/PageNotFound_pb2.pyi +7 -1
- streamlit/proto/PageProfile_pb2.pyi +13 -7
- streamlit/proto/PagesChanged_pb2.pyi +7 -1
- streamlit/proto/ParentMessage_pb2.pyi +7 -1
- streamlit/proto/PlotlyChart_pb2.py +8 -6
- streamlit/proto/PlotlyChart_pb2.pyi +9 -7
- streamlit/proto/Progress_pb2.pyi +7 -1
- streamlit/proto/Radio_pb2.pyi +7 -1
- streamlit/proto/RootContainer_pb2.pyi +1 -1
- streamlit/proto/Selectbox_pb2.pyi +7 -1
- streamlit/proto/SessionEvent_pb2.pyi +7 -1
- streamlit/proto/SessionStatus_pb2.pyi +7 -1
- streamlit/proto/Skeleton_pb2.pyi +3 -3
- streamlit/proto/Slider_pb2.pyi +5 -5
- streamlit/proto/Snow_pb2.pyi +7 -1
- streamlit/proto/Space_pb2.py +27 -0
- streamlit/proto/Space_pb2.pyi +48 -0
- streamlit/proto/Spinner_pb2.pyi +7 -1
- streamlit/proto/TextAlignmentConfig_pb2.py +29 -0
- streamlit/proto/TextAlignmentConfig_pb2.pyi +68 -0
- streamlit/proto/TextArea_pb2.pyi +7 -1
- streamlit/proto/TextInput_pb2.pyi +3 -3
- streamlit/proto/Text_pb2.pyi +7 -1
- streamlit/proto/TimeInput_pb2.pyi +7 -1
- streamlit/proto/Toast_pb2.pyi +7 -1
- streamlit/proto/VegaLiteChart_pb2.pyi +7 -1
- streamlit/proto/Video_pb2.pyi +6 -6
- streamlit/proto/WidgetStates_pb2.py +2 -2
- streamlit/proto/WidgetStates_pb2.pyi +23 -7
- streamlit/proto/WidthConfig_pb2.py +2 -2
- streamlit/proto/WidthConfig_pb2.pyi +13 -4
- streamlit/proto/openmetrics_data_model_pb2.pyi +52 -52
- streamlit/runtime/app_session.py +65 -2
- streamlit/runtime/caching/cache_data_api.py +5 -5
- streamlit/runtime/caching/cache_errors.py +4 -1
- streamlit/runtime/caching/cache_resource_api.py +5 -4
- streamlit/runtime/caching/cache_utils.py +3 -2
- streamlit/runtime/caching/cached_message_replay.py +3 -3
- streamlit/runtime/caching/hashing.py +4 -5
- streamlit/runtime/caching/legacy_cache_api.py +2 -1
- streamlit/runtime/connection_factory.py +1 -3
- streamlit/runtime/download_data_util.py +53 -0
- streamlit/runtime/forward_msg_queue.py +5 -1
- streamlit/runtime/fragment.py +2 -1
- streamlit/runtime/media_file_manager.py +178 -2
- streamlit/runtime/memory_media_file_storage.py +1 -1
- streamlit/runtime/metrics_util.py +91 -3
- streamlit/runtime/runtime.py +14 -0
- streamlit/runtime/scriptrunner/exec_code.py +2 -1
- streamlit/runtime/scriptrunner/script_runner.py +5 -3
- streamlit/runtime/scriptrunner_utils/script_run_context.py +3 -6
- streamlit/runtime/secrets.py +2 -4
- streamlit/runtime/session_manager.py +3 -1
- streamlit/runtime/state/common.py +30 -5
- streamlit/runtime/state/presentation.py +85 -0
- streamlit/runtime/state/query_params.py +80 -29
- streamlit/runtime/state/safe_session_state.py +2 -2
- streamlit/runtime/state/session_state.py +221 -17
- streamlit/runtime/state/widgets.py +19 -3
- streamlit/runtime/websocket_session_manager.py +3 -1
- streamlit/source_util.py +2 -2
- streamlit/static/index.html +2 -2
- streamlit/static/manifest.json +557 -239
- streamlit/static/static/css/{index.CIiu7Ygf.css → index.BpABIXK9.css} +1 -1
- streamlit/static/static/css/index.DgR7E2CV.css +1 -0
- streamlit/static/static/js/{ErrorOutline.esm.DUpR0_Ka.js → ErrorOutline.esm.ZJDbmVTx.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.CN4j9-1w.js → FileDownload.esm.Dx0vI3vH.js} +1 -1
- streamlit/static/static/js/{FileHelper.CaIUKG91.js → FileHelper.B7Ero7qQ.js} +3 -3
- streamlit/static/static/js/{FormClearHelper.DTcdrasw.js → FormClearHelper.CG2XN1_g.js} +1 -1
- streamlit/static/static/js/IFrameUtil.DefezniK.js +1 -0
- streamlit/static/static/js/InputInstructions.Cj5-1zf6.js +1 -0
- streamlit/static/static/js/Particles.BfWfv0Aw.js +1 -0
- streamlit/static/static/js/{ProgressBar.DetlP5aY.js → ProgressBar.CGQ8OgfO.js} +2 -2
- streamlit/static/static/js/StreamlitSyntaxHighlighter.DTKLpwhl.js +20 -0
- streamlit/static/static/js/{Toolbar.C77ar7rq.js → Toolbar.B2qFUmd9.js} +1 -1
- streamlit/static/static/js/_arrayIncludes.B19Iyn2B.js +1 -0
- streamlit/static/static/js/_baseIndexOf.BTknn6Gb.js +1 -0
- streamlit/static/static/js/{base-input.BQft14La.js → base-input.o9tL8MDP.js} +4 -4
- streamlit/static/static/js/{checkbox.yZOfXCeX.js → checkbox.0BeV1IBL.js} +1 -1
- streamlit/static/static/js/{createSuper.Dh9w1cs8.js → createSuper.RBO59fEm.js} +1 -1
- streamlit/static/static/js/data-grid-overlay-editor.CiTkUy0t.js +1 -0
- streamlit/static/static/js/{downloader.MeHtkq8r.js → downloader.DwNZg3Mw.js} +1 -1
- streamlit/static/static/js/embed.XT9xNd3F.js +195 -0
- streamlit/static/static/js/{es6.VpBPGCnM.js → es6.x9KsYQg-.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.yMw_ARIL.js → iframeResizer.contentWindow.ZVXpMPi0.js} +1 -1
- streamlit/static/static/js/index.5VPOamri.js +1 -0
- streamlit/static/static/js/index.8HslT92O.js +14 -0
- streamlit/static/static/js/index.AnXMIBz3.js +7 -0
- streamlit/static/static/js/index.B0yp3bM1.js +6 -0
- streamlit/static/static/js/index.B1fRb5wF.js +1 -0
- streamlit/static/static/js/index.B527JZdO.js +3 -0
- streamlit/static/static/js/index.BHgV-yW4.js +1 -0
- streamlit/static/static/js/index.BQr-XwGV.js +1 -0
- streamlit/static/static/js/index.BTtmaLDB.js +1 -0
- streamlit/static/static/js/index.BWB_91TA.js +1 -0
- streamlit/static/static/js/index.BfEKaEmw.js +1 -0
- streamlit/static/static/js/index.BfXjTO8b.js +1 -0
- streamlit/static/static/js/index.Bjy4NRu9.js +3 -0
- streamlit/static/static/js/index.Bu5JWpT_.js +1 -0
- streamlit/static/static/js/index.BuCx76ZV.js +1 -0
- streamlit/static/static/js/index.BxjzhVUb.js +2 -0
- streamlit/static/static/js/index.By55VdPY.js +1 -0
- streamlit/static/static/js/index.CF5MxTbK.js +1 -0
- streamlit/static/static/js/index.CLmq_z9K.js +1 -0
- streamlit/static/static/js/index.CNH4rdSz.js +1 -0
- streamlit/static/static/js/{index.B0H9IXUJ.js → index.CTgm_-jO.js} +10 -41
- streamlit/static/static/js/index.C_rK-Swb.js +188 -0
- streamlit/static/static/js/index.CjozwSzS.js +1 -0
- streamlit/static/static/js/{index.CH1tqnSs.js → index.CkGVt6-G.js} +1 -1
- streamlit/static/static/js/index.CuvXOyER.js +2 -0
- streamlit/static/static/js/{index.FFOzOWzC.js → index.CyUHWoCC.js} +2 -2
- streamlit/static/static/js/index.CyroQtI4.js +2 -0
- streamlit/static/static/js/index.D6HmkoDm.js +263 -0
- streamlit/static/static/js/index.DAqCNvsO.js +1 -0
- streamlit/static/static/js/index.DB_w_CZQ.js +1 -0
- streamlit/static/static/js/index.DBalctjj.js +2 -0
- streamlit/static/static/js/index.DK0RFJUG.js +11 -0
- streamlit/static/static/js/index.DMxc2XFp.js +151 -0
- streamlit/static/static/js/index.DO5utP74.js +2 -0
- streamlit/static/static/js/index.DS7lf09n.js +1 -0
- streamlit/static/static/js/index.DWexTVLY.js +1 -0
- streamlit/static/static/js/index.DXxnU5ej.js +1 -0
- streamlit/static/static/js/index.DcU3uDvB.js +2 -0
- streamlit/static/static/js/index.DlltaH7J.js +1 -0
- streamlit/static/static/js/index.DpNTZz82.js +27 -0
- streamlit/static/static/js/index.Dr9HIhQw.js +1 -0
- streamlit/static/static/js/index.DsgAU5lc.js +1 -0
- streamlit/static/static/js/{index.64ejlaaT.js → index.KfXqjDYy.js} +1 -1
- streamlit/static/static/js/index.PaidgjCs.js +1 -0
- streamlit/static/static/js/index.RJZuWCGA.js +1 -0
- streamlit/static/static/js/{index.Ctn27_AE.js → index.hbeqcRTn.js} +53 -122
- streamlit/static/static/js/index.q5hIQwAY.js +1 -0
- streamlit/static/static/js/index.rORSX6IW.js +1 -0
- streamlit/static/static/js/index.uSX757_v.js +1 -0
- streamlit/static/static/js/index.x_QRaLMd.js +1 -0
- streamlit/static/static/js/{input.s6pjQ49A.js → input.D5oh9-aB.js} +2 -2
- streamlit/static/static/js/main.q9oGOg0H.js +13 -0
- streamlit/static/static/js/{memory.Cuvsdfrl.js → memory.5kCSFUJS.js} +1 -1
- streamlit/static/static/js/moment.C3j7ZXd7.js +4 -0
- streamlit/static/static/js/number-overlay-editor.Cn_LsK8N.js +9 -0
- streamlit/static/static/js/pandasStylerUtils.BqhXt51_.js +1 -0
- streamlit/static/static/js/{possibleConstructorReturn.CqidKeei.js → possibleConstructorReturn.DD9NK1Z8.js} +1 -1
- streamlit/static/static/js/record.B-tDciZb.js +1 -0
- streamlit/static/static/js/{sandbox.CCQREcJx.js → sandbox.DACSyz29.js} +1 -1
- streamlit/static/static/js/styled-components.C3R090At.js +1 -0
- streamlit/static/static/js/threshold.Q1mXg5rX.js +1 -0
- streamlit/static/static/js/throttle.B0GR3Iyz.js +1 -0
- streamlit/static/static/js/{timepicker.mkJF97Bb.js → timepicker.BdhzPxrv.js} +1 -1
- streamlit/static/static/js/timer.C2hYhUse.js +1 -0
- streamlit/static/static/js/{toConsumableArray.De7I7KVR.js → toConsumableArray.Db2pdqM2.js} +1 -1
- streamlit/static/static/js/uniqueId.CtqIr-Yh.js +1 -0
- streamlit/static/static/js/urls.BwSlolu9.js +1 -0
- streamlit/static/static/js/{useBasicWidgetState.CedkNjUW.js → useBasicWidgetState.Bfp6TnSw.js} +1 -1
- streamlit/static/static/js/useIntlLocale.hRV75Xgj.js +12 -0
- streamlit/static/static/js/{useTextInputAutoExpand.Ca7w8dVs.js → useTextInputAutoExpand.QepX7n8Y.js} +1 -1
- streamlit/static/static/js/useUpdateUiValue.DHx8TzX6.js +1 -0
- streamlit/static/static/js/useWaveformController.WxVzpzEX.js +1 -0
- streamlit/static/static/js/value.B4vHRSi7.js +1 -0
- streamlit/static/static/js/wavesurfer.esm.vI8Eid4k.js +73 -0
- streamlit/static/static/js/withCalculatedWidth.DcKeRSWJ.js +1 -0
- streamlit/static/static/js/withFullScreenWrapper.CrHddARq.js +1 -0
- streamlit/static/static/media/MaterialSymbols-Rounded.C7IFxh57.woff2 +0 -0
- streamlit/string_util.py +9 -4
- streamlit/testing/v1/app_test.py +17 -2
- streamlit/testing/v1/element_tree.py +85 -9
- streamlit/testing/v1/util.py +2 -2
- streamlit/type_util.py +3 -4
- streamlit/url_util.py +1 -3
- streamlit/user_info.py +1 -2
- streamlit/util.py +3 -1
- streamlit/watcher/event_based_path_watcher.py +23 -12
- streamlit/watcher/local_sources_watcher.py +11 -1
- streamlit/watcher/path_watcher.py +9 -6
- streamlit/watcher/polling_path_watcher.py +4 -1
- streamlit/watcher/util.py +2 -2
- streamlit/web/bootstrap.py +24 -0
- streamlit/web/cli.py +51 -22
- streamlit/web/server/bidi_component_request_handler.py +193 -0
- streamlit/web/server/component_file_utils.py +97 -0
- streamlit/web/server/component_request_handler.py +8 -21
- streamlit/web/server/oauth_authlib_routes.py +5 -2
- streamlit/web/server/oidc_mixin.py +3 -1
- streamlit/web/server/routes.py +2 -2
- streamlit/web/server/server.py +9 -0
- streamlit/web/server/server_util.py +3 -1
- streamlit/web/server/upload_file_request_handler.py +19 -1
- {streamlit-1.50.0.dist-info → streamlit-1.52.0.dist-info}/METADATA +10 -7
- streamlit-1.52.0.dist-info/RECORD +620 -0
- streamlit/static/static/css/index.CHEnSPGk.css +0 -1
- streamlit/static/static/js/Hooks.BRba_Own.js +0 -1
- streamlit/static/static/js/InputInstructions.xnSDuYeQ.js +0 -1
- streamlit/static/static/js/Particles.CElH0XX2.js +0 -1
- streamlit/static/static/js/data-grid-overlay-editor.DcuHuCyW.js +0 -1
- streamlit/static/static/js/index.6xX1278W.js +0 -975
- streamlit/static/static/js/index.B-hiXRzw.js +0 -1
- streamlit/static/static/js/index.B4cAbHP6.js +0 -1
- streamlit/static/static/js/index.B4dUQfni.js +0 -1
- streamlit/static/static/js/index.BPQo7BKk.js +0 -1
- streamlit/static/static/js/index.Baqa90pe.js +0 -2
- streamlit/static/static/js/index.Bj9JgOEC.js +0 -1
- streamlit/static/static/js/index.BjCwMzj4.js +0 -3
- streamlit/static/static/js/index.Bm3VbPB5.js +0 -1
- streamlit/static/static/js/index.Bxz2yX3P.js +0 -1
- streamlit/static/static/js/index.BycLveZ4.js +0 -1
- streamlit/static/static/js/index.C9BdUqTi.js +0 -1
- streamlit/static/static/js/index.CFMf5_ez.js +0 -197
- streamlit/static/static/js/index.CGYqqs6j.js +0 -1
- streamlit/static/static/js/index.CMItVsFA.js +0 -1
- streamlit/static/static/js/index.CTBk8Vk2.js +0 -1
- streamlit/static/static/js/index.CiAQIz1H.js +0 -7
- streamlit/static/static/js/index.Cj7DSzVR.js +0 -73
- streamlit/static/static/js/index.Ck8rQ9OL.js +0 -1
- streamlit/static/static/js/index.ClELlchS.js +0 -1617
- streamlit/static/static/js/index.Cnpi3o3E.js +0 -1
- streamlit/static/static/js/index.D2QEXQq_.js +0 -1
- streamlit/static/static/js/index.DH71Ezyj.js +0 -1
- streamlit/static/static/js/index.DHh-U0dK.js +0 -3
- streamlit/static/static/js/index.DK7hD7_w.js +0 -1
- streamlit/static/static/js/index.DKv_lNO7.js +0 -2
- streamlit/static/static/js/index.DNLrMXgm.js +0 -12
- streamlit/static/static/js/index.DW0Grddz.js +0 -1
- streamlit/static/static/js/index.Dbe-Q3C-.js +0 -2
- streamlit/static/static/js/index.DcPNYEUo.js +0 -1
- streamlit/static/static/js/index.DuxqVQpd.js +0 -1
- streamlit/static/static/js/index.GRUzrudl.js +0 -1
- streamlit/static/static/js/number-overlay-editor.DdgVR5m3.js +0 -9
- streamlit/static/static/js/uniqueId.RI1LJdtz.js +0 -1
- streamlit/static/static/js/useUpdateUiValue.DeXelfRH.js +0 -1
- streamlit/static/static/js/withFullScreenWrapper.C3561XxJ.js +0 -1
- streamlit/static/static/media/MaterialSymbols-Rounded.DeCZgS-4.woff2 +0 -0
- streamlit-1.50.0.dist-info/RECORD +0 -557
- {streamlit-1.50.0.data → streamlit-1.52.0.data}/scripts/streamlit.cmd +0 -0
- {streamlit-1.50.0.dist-info → streamlit-1.52.0.dist-info}/WHEEL +0 -0
- {streamlit-1.50.0.dist-info → streamlit-1.52.0.dist-info}/entry_points.txt +0 -0
- {streamlit-1.50.0.dist-info → streamlit-1.52.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,514 @@
|
|
|
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
|
+
|
|
15
|
+
"""Register the st.components.v2 API namespace."""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from typing import TYPE_CHECKING, Any
|
|
20
|
+
|
|
21
|
+
from streamlit.components.v2.component_definition_resolver import (
|
|
22
|
+
build_definition_with_validation,
|
|
23
|
+
)
|
|
24
|
+
from streamlit.components.v2.get_bidi_component_manager import (
|
|
25
|
+
get_bidi_component_manager,
|
|
26
|
+
)
|
|
27
|
+
from streamlit.errors import StreamlitAPIException
|
|
28
|
+
|
|
29
|
+
if TYPE_CHECKING:
|
|
30
|
+
from streamlit.components.v2.types import BidiComponentCallable
|
|
31
|
+
|
|
32
|
+
if TYPE_CHECKING:
|
|
33
|
+
from collections.abc import Callable
|
|
34
|
+
|
|
35
|
+
from streamlit.components.v2.bidi_component import BidiComponentResult
|
|
36
|
+
from streamlit.elements.lib.layout_utils import Height, Width
|
|
37
|
+
from streamlit.runtime.state.common import WidgetCallback
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _register_component(
|
|
41
|
+
name: str,
|
|
42
|
+
html: str | None = None,
|
|
43
|
+
css: str | None = None,
|
|
44
|
+
js: str | None = None,
|
|
45
|
+
) -> str:
|
|
46
|
+
"""Register a component and return its fully qualified key.
|
|
47
|
+
|
|
48
|
+
This shared function handles the component registration and constructing a
|
|
49
|
+
validated definition against any pre-registered components from
|
|
50
|
+
``pyproject.toml``.
|
|
51
|
+
|
|
52
|
+
Parameters
|
|
53
|
+
----------
|
|
54
|
+
name : str
|
|
55
|
+
A short, descriptive identifier for the component.
|
|
56
|
+
html : str or None
|
|
57
|
+
Inline HTML markup for the component root.
|
|
58
|
+
css : str | None
|
|
59
|
+
Either inline CSS (string) or an asset-dir-relative path/glob to a
|
|
60
|
+
``.css`` file declared in the component's ``asset_dir``. Globs are
|
|
61
|
+
allowed and must resolve to exactly one file within ``asset_dir``.
|
|
62
|
+
js : str | None
|
|
63
|
+
Either inline JavaScript (string) or an asset-dir-relative path/glob to
|
|
64
|
+
a ``.js`` file declared in the component's ``asset_dir``. Globs are
|
|
65
|
+
allowed and must resolve to exactly one file within ``asset_dir``.
|
|
66
|
+
|
|
67
|
+
Returns
|
|
68
|
+
-------
|
|
69
|
+
str
|
|
70
|
+
The fully qualified component key in the form ``<module_name>.<n>``.
|
|
71
|
+
|
|
72
|
+
Raises
|
|
73
|
+
------
|
|
74
|
+
StreamlitAPIException
|
|
75
|
+
If ``css`` or ``js`` parameters are not strings or None.
|
|
76
|
+
"""
|
|
77
|
+
# Parameter type guards: only strings or None are supported for js/css
|
|
78
|
+
for _param_name, _param_value in (("css", css), ("js", js)):
|
|
79
|
+
if _param_value is not None and not isinstance(_param_value, str):
|
|
80
|
+
raise StreamlitAPIException(
|
|
81
|
+
f"{_param_name} parameter must be a string or None. Pass a string path or glob."
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
component_key = name
|
|
85
|
+
|
|
86
|
+
manager = get_bidi_component_manager()
|
|
87
|
+
manager.register(
|
|
88
|
+
build_definition_with_validation(
|
|
89
|
+
manager=manager,
|
|
90
|
+
component_key=component_key,
|
|
91
|
+
html=html,
|
|
92
|
+
css=css,
|
|
93
|
+
js=js,
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
# Record API inputs for future re-resolution on file changes
|
|
98
|
+
manager.record_api_inputs(component_key, css, js)
|
|
99
|
+
|
|
100
|
+
return component_key
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _create_component_callable(
|
|
104
|
+
name: str,
|
|
105
|
+
*,
|
|
106
|
+
html: str | None = None,
|
|
107
|
+
css: str | None = None,
|
|
108
|
+
js: str | None = None,
|
|
109
|
+
) -> Callable[..., Any]:
|
|
110
|
+
"""Create a component callable, handling both lookup and registration cases.
|
|
111
|
+
|
|
112
|
+
Parameters
|
|
113
|
+
----------
|
|
114
|
+
name : str
|
|
115
|
+
A short, descriptive identifier for the component.
|
|
116
|
+
html : str | None
|
|
117
|
+
Inline HTML markup for the component root.
|
|
118
|
+
css : str | None
|
|
119
|
+
Inline CSS (string) or a string path/glob to a file under ``asset_dir``;
|
|
120
|
+
see :func:`_register_component` for path validation semantics.
|
|
121
|
+
js : str | None
|
|
122
|
+
Inline JavaScript (string) or a string path/glob to a file under
|
|
123
|
+
``asset_dir``; see :func:`_register_component` for path validation semantics.
|
|
124
|
+
|
|
125
|
+
Returns
|
|
126
|
+
-------
|
|
127
|
+
Callable[..., Any]
|
|
128
|
+
A function that, when called inside a Streamlit script, mounts the
|
|
129
|
+
component and returns its state.
|
|
130
|
+
|
|
131
|
+
Raises
|
|
132
|
+
------
|
|
133
|
+
StreamlitAPIException
|
|
134
|
+
If a component is not found in the registry.
|
|
135
|
+
"""
|
|
136
|
+
component_key = _register_component(name=name, html=html, css=css, js=js)
|
|
137
|
+
|
|
138
|
+
# The inner callable that mounts the component.
|
|
139
|
+
def _mount_component(
|
|
140
|
+
*,
|
|
141
|
+
key: str | None = None,
|
|
142
|
+
data: Any | None = None,
|
|
143
|
+
default: dict[str, Any] | None = None,
|
|
144
|
+
width: Width = "stretch",
|
|
145
|
+
height: Height = "content",
|
|
146
|
+
isolate_styles: bool = True,
|
|
147
|
+
**on_callbacks: WidgetCallback | None,
|
|
148
|
+
) -> BidiComponentResult:
|
|
149
|
+
"""Mount the component.
|
|
150
|
+
|
|
151
|
+
Parameters
|
|
152
|
+
----------
|
|
153
|
+
key : str or None
|
|
154
|
+
An optional string to use as the unique key for the component.
|
|
155
|
+
data : Any or None
|
|
156
|
+
Data to pass to the component (JSON-serializable).
|
|
157
|
+
default : dict[str, Any] or None
|
|
158
|
+
A dictionary of default values for state properties. Keys must
|
|
159
|
+
correspond to valid state names (those with on_*_change callbacks).
|
|
160
|
+
width : Width
|
|
161
|
+
The width of the component.
|
|
162
|
+
height : Height
|
|
163
|
+
The height of the component.
|
|
164
|
+
isolate_styles : bool
|
|
165
|
+
Whether to sandbox the component styles in a shadow-root. Defaults to
|
|
166
|
+
True.
|
|
167
|
+
**on_callbacks : WidgetCallback
|
|
168
|
+
Callback functions for handling component events. Use pattern
|
|
169
|
+
on_{state_name}_change (e.g., on_click_change, on_value_change).
|
|
170
|
+
|
|
171
|
+
Returns
|
|
172
|
+
-------
|
|
173
|
+
BidiComponentResult
|
|
174
|
+
Component state.
|
|
175
|
+
"""
|
|
176
|
+
import streamlit as st
|
|
177
|
+
|
|
178
|
+
return st._bidi_component(
|
|
179
|
+
component_key,
|
|
180
|
+
key=key,
|
|
181
|
+
isolate_styles=isolate_styles,
|
|
182
|
+
data=data,
|
|
183
|
+
default=default,
|
|
184
|
+
width=width,
|
|
185
|
+
height=height,
|
|
186
|
+
**on_callbacks,
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
# Ensure the function remains compatible with the shared public callable type.
|
|
190
|
+
# Static type assertion to ensure the callable matches the shared signature
|
|
191
|
+
_typed_check_mount_component: BidiComponentCallable = _mount_component
|
|
192
|
+
|
|
193
|
+
return _mount_component
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def component(
|
|
197
|
+
name: str,
|
|
198
|
+
*,
|
|
199
|
+
html: str | None = None,
|
|
200
|
+
css: str | None = None,
|
|
201
|
+
js: str | None = None,
|
|
202
|
+
) -> BidiComponentCallable:
|
|
203
|
+
'''Register an ``st.components.v2`` component and return a callable to mount it.
|
|
204
|
+
|
|
205
|
+
A component must have HTML, JavaScript, or both. If you want a component
|
|
206
|
+
with only CSS, use ``st.html`` instead.
|
|
207
|
+
|
|
208
|
+
If your component is defined in an installed package, you can declare an
|
|
209
|
+
asset directory (``asset_dir``) through ``pyproject.toml`` files in the
|
|
210
|
+
package. This allows you to serve component assets and reference them by
|
|
211
|
+
path or glob in the ``html``, ``css``, and ``js`` parameters. Otherwise,
|
|
212
|
+
you must provide raw HTML, CSS, and/or JavaScript strings directly to these
|
|
213
|
+
parameters.
|
|
214
|
+
|
|
215
|
+
.. important::
|
|
216
|
+
When using paths or globs to define one or more component assets, the
|
|
217
|
+
paths must be relative to the component's ``asset_dir`` as declared in
|
|
218
|
+
the component manifest. This is only possible for installed components.
|
|
219
|
+
|
|
220
|
+
For security reasons, absolute paths and path traversals are rejected.
|
|
221
|
+
Because of runtime constraints, paths and globs must be provided as
|
|
222
|
+
strings and not ``Path`` objects.
|
|
223
|
+
|
|
224
|
+
Parameters
|
|
225
|
+
----------
|
|
226
|
+
name : str
|
|
227
|
+
A short, descriptive identifier for the component. This is used
|
|
228
|
+
internally by Streamlit to manage instances of the component.
|
|
229
|
+
|
|
230
|
+
Component names must be unique across an app. The names of imported
|
|
231
|
+
components are prefixed by their module name to avoid collisions.
|
|
232
|
+
|
|
233
|
+
If you register multiple components with the same name, a warning is
|
|
234
|
+
logged and the last-registered component is used. Because this can lead
|
|
235
|
+
to unexpected behavior, ensure that component names are unique. If you
|
|
236
|
+
intend to have multiple instances of a component in one app, avoid
|
|
237
|
+
wrapping a component definition together with its mounting command so
|
|
238
|
+
you don't re-register your component with each instance.
|
|
239
|
+
|
|
240
|
+
html : str or None
|
|
241
|
+
Inline HTML markup for the component root. This can be one of the
|
|
242
|
+
following strings:
|
|
243
|
+
|
|
244
|
+
- Raw HTML. This doesn't require any ``<html>``, ``<head>``, or
|
|
245
|
+
``<body>`` tags; just provide the inner HTML.
|
|
246
|
+
- A path or glob to an HTML file, relative to the component's
|
|
247
|
+
asset directory.
|
|
248
|
+
|
|
249
|
+
If any HTML depends on data passed at mount time, use a placeholder
|
|
250
|
+
element and populate it via JavaScript. Alternatively, you can append
|
|
251
|
+
a new element to the parent. For more information, see Example 2.
|
|
252
|
+
|
|
253
|
+
``html`` and ``js`` can't both be ``None``. At least one of them must
|
|
254
|
+
be provided.
|
|
255
|
+
|
|
256
|
+
css : str or None
|
|
257
|
+
Inline CSS. This can be one of the following strings:
|
|
258
|
+
|
|
259
|
+
- Raw CSS (without a ``<style>`` block).
|
|
260
|
+
- A path or glob to a CSS file, relative to the component's
|
|
261
|
+
asset directory.
|
|
262
|
+
|
|
263
|
+
js : str or None
|
|
264
|
+
Inline JavaScript. This can be one of the following strings:
|
|
265
|
+
|
|
266
|
+
- Raw JavaScript (without a ``<script>`` block).
|
|
267
|
+
- A path or glob to a JS file, relative to the component's
|
|
268
|
+
asset directory.
|
|
269
|
+
|
|
270
|
+
``html`` and ``js`` can't both be ``None``. At least one of them must
|
|
271
|
+
be provided.
|
|
272
|
+
|
|
273
|
+
Returns
|
|
274
|
+
-------
|
|
275
|
+
BidiComponentCallable
|
|
276
|
+
The component's mounting command.
|
|
277
|
+
|
|
278
|
+
This callable accepts the component parameters like ``key`` and
|
|
279
|
+
``data`` and returns a ``BidiComponentResult`` object with the
|
|
280
|
+
component's state. The mounting command can be included in a
|
|
281
|
+
user-friendly wrapper function to provide a simpler API. A mounting
|
|
282
|
+
command can be called multiple times in an app to create multiple
|
|
283
|
+
instances of the component.
|
|
284
|
+
|
|
285
|
+
Examples
|
|
286
|
+
--------
|
|
287
|
+
**Example 1: Create a JavaScript-only component that captures link clicks**
|
|
288
|
+
|
|
289
|
+
You can create a simple component that allows inline links to communicate
|
|
290
|
+
with Python. Normally, clicking links in a Streamlit app would start a new
|
|
291
|
+
session. This component captures link clicks and sends them to Python as
|
|
292
|
+
trigger values.
|
|
293
|
+
|
|
294
|
+
.. code-block:: python
|
|
295
|
+
|
|
296
|
+
import streamlit as st
|
|
297
|
+
|
|
298
|
+
JS = """
|
|
299
|
+
export default function(component) {
|
|
300
|
+
const { setTriggerValue } = component;
|
|
301
|
+
const links = document.querySelectorAll('a[href="#"]');
|
|
302
|
+
|
|
303
|
+
links.forEach((link) => {
|
|
304
|
+
link.onclick = (e) => {
|
|
305
|
+
setTriggerValue('clicked', link.innerHTML);
|
|
306
|
+
};
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
"""
|
|
310
|
+
|
|
311
|
+
my_component = st.components.v2.component(
|
|
312
|
+
"inline_links",
|
|
313
|
+
js=JS,
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
result = my_component(on_clicked_change=lambda: None)
|
|
317
|
+
|
|
318
|
+
st.markdown(
|
|
319
|
+
"Components aren't [sandboxed](#), so you can write JS that [interacts](#) with the main [document](#)."
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
if result.clicked:
|
|
323
|
+
st.write(f"You clicked {result.clicked}!")
|
|
324
|
+
|
|
325
|
+
.. output::
|
|
326
|
+
https://doc-components-markdown-links.streamlit.app/
|
|
327
|
+
height: 250px
|
|
328
|
+
|
|
329
|
+
**Example 2: Display a paragraph with custom inline links**
|
|
330
|
+
|
|
331
|
+
If you want to dynamically pass custom data from inline links, you can pass
|
|
332
|
+
HTML to the ``data`` parameter of the component's mount command. When a
|
|
333
|
+
link is clicked, the component sets a trigger value from the link's
|
|
334
|
+
``data-link`` HTML attribute.
|
|
335
|
+
|
|
336
|
+
.. warning::
|
|
337
|
+
|
|
338
|
+
If you directly modify the inner HTML of the parent element, you will
|
|
339
|
+
overwrite the HTML and CSS passed to the component. Instead, create a
|
|
340
|
+
new child element and set its inner HTML. You can create the
|
|
341
|
+
placeholder dynamically in JavaScript or include it in the ``html``
|
|
342
|
+
parameter.
|
|
343
|
+
|
|
344
|
+
.. code-block:: python
|
|
345
|
+
|
|
346
|
+
import streamlit as st
|
|
347
|
+
|
|
348
|
+
CSS = """
|
|
349
|
+
a {
|
|
350
|
+
color: var(--st-link-color);
|
|
351
|
+
}
|
|
352
|
+
"""
|
|
353
|
+
|
|
354
|
+
JS = """
|
|
355
|
+
export default function(component) {
|
|
356
|
+
const { data, setTriggerValue, parentElement } = component;
|
|
357
|
+
const newElement = document.createElement('div');
|
|
358
|
+
parentElement.appendChild(newElement);
|
|
359
|
+
newElement.innerHTML = data;
|
|
360
|
+
|
|
361
|
+
const links = newElement.querySelectorAll('a');
|
|
362
|
+
|
|
363
|
+
links.forEach((link) => {
|
|
364
|
+
link.onclick = (e) => {
|
|
365
|
+
setTriggerValue('clicked', link.getAttribute('data-link'));
|
|
366
|
+
};
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
"""
|
|
370
|
+
|
|
371
|
+
my_component = st.components.v2.component(
|
|
372
|
+
"inline_links",
|
|
373
|
+
css=CSS,
|
|
374
|
+
js=JS,
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
paragraph_html = """
|
|
378
|
+
<p>This is an example paragraph with inline links. To see the response in
|
|
379
|
+
Python, click on the <a href="#" data-link="link_1">first link</a> or
|
|
380
|
+
<a href="#" data-link="link_2">second link</a>.</p>
|
|
381
|
+
"""
|
|
382
|
+
|
|
383
|
+
result = my_component(data=paragraph_html, on_clicked_change=lambda: None)
|
|
384
|
+
if result.clicked == "link_1":
|
|
385
|
+
st.write("You clicked the first link!")
|
|
386
|
+
elif result.clicked == "link_2":
|
|
387
|
+
st.write("You clicked the second link!")
|
|
388
|
+
|
|
389
|
+
.. output::
|
|
390
|
+
https://doc-components-custom-anchors.streamlit.app/
|
|
391
|
+
height: 250px
|
|
392
|
+
|
|
393
|
+
**Example 3: Display an interactive SVG image**
|
|
394
|
+
|
|
395
|
+
You can create a component that displays an SVG image with clickable
|
|
396
|
+
shapes. When a shape is clicked, the component sends the shape type to
|
|
397
|
+
Python as a trigger value.
|
|
398
|
+
|
|
399
|
+
.. code-block:: python
|
|
400
|
+
|
|
401
|
+
import streamlit as st
|
|
402
|
+
|
|
403
|
+
HTML = """
|
|
404
|
+
<p>Click on the triangle, square, or circle to interact with the shapes:</p>
|
|
405
|
+
|
|
406
|
+
<svg width="400" height="300">
|
|
407
|
+
<polygon points="100,50 50,150 150,150" data-shape="triangle"></polygon>
|
|
408
|
+
<rect x="200" y="75" width="100" height="100" data-shape="square"></rect>
|
|
409
|
+
<circle cx="125" cy="225" r="40" data-shape="circle"></circle>
|
|
410
|
+
</svg>
|
|
411
|
+
"""
|
|
412
|
+
|
|
413
|
+
JS = """
|
|
414
|
+
export default function(component) {
|
|
415
|
+
const { setTriggerValue, parentElement } = component;
|
|
416
|
+
const shapes = parentElement.querySelectorAll('[data-shape]');
|
|
417
|
+
|
|
418
|
+
shapes.forEach((shape) => {
|
|
419
|
+
shape.onclick = (e) => {
|
|
420
|
+
setTriggerValue('clicked', shape.getAttribute('data-shape'));
|
|
421
|
+
};
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
"""
|
|
425
|
+
|
|
426
|
+
CSS = """
|
|
427
|
+
polygon, rect, circle {
|
|
428
|
+
stroke: var(--st-primary-color);
|
|
429
|
+
stroke-width: 2;
|
|
430
|
+
fill: transparent;
|
|
431
|
+
cursor: pointer;
|
|
432
|
+
}
|
|
433
|
+
polygon:hover, rect:hover, circle:hover {
|
|
434
|
+
fill: var(--st-secondary-background-color);
|
|
435
|
+
}
|
|
436
|
+
"""
|
|
437
|
+
|
|
438
|
+
my_component = st.components.v2.component(
|
|
439
|
+
"clickable_svg",
|
|
440
|
+
html=HTML,
|
|
441
|
+
css=CSS,
|
|
442
|
+
js=JS,
|
|
443
|
+
)
|
|
444
|
+
|
|
445
|
+
result = my_component(on_clicked_change=lambda: None)
|
|
446
|
+
result
|
|
447
|
+
|
|
448
|
+
.. output::
|
|
449
|
+
https://doc-components-interactive-svg.streamlit.app/
|
|
450
|
+
height: 550px
|
|
451
|
+
|
|
452
|
+
**Example 4: Clean up your component's resources**
|
|
453
|
+
|
|
454
|
+
You can use the return value of the component's JavaScript function to
|
|
455
|
+
clean up any resources when the component is unmounted. For example, you
|
|
456
|
+
can disconnect a MutationObserver that was monitoring changes in the DOM.
|
|
457
|
+
|
|
458
|
+
.. code-block:: python
|
|
459
|
+
|
|
460
|
+
import streamlit as st
|
|
461
|
+
|
|
462
|
+
JS = """
|
|
463
|
+
export default function(component) {
|
|
464
|
+
const { setStateValue, parentElement } = component;
|
|
465
|
+
const sidebar = document.querySelector('section.stSidebar');
|
|
466
|
+
const initialState = sidebar.getAttribute('aria-expanded') === 'true';
|
|
467
|
+
|
|
468
|
+
// Create observer to watch for aria-expanded attribute changes
|
|
469
|
+
const observer = new MutationObserver((mutations) => {
|
|
470
|
+
mutations.forEach((mutation) => {
|
|
471
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'aria-expanded') {
|
|
472
|
+
const newIsExpanded = sidebar.getAttribute('aria-expanded') === 'true';
|
|
473
|
+
setStateValue('expanded', newIsExpanded);
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
// Start observing
|
|
479
|
+
observer.observe(sidebar, {
|
|
480
|
+
attributes: true,
|
|
481
|
+
attributeFilter: ['aria-expanded']
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
// Set initial state
|
|
485
|
+
setStateValue('expanded', initialState);
|
|
486
|
+
|
|
487
|
+
// Cleanup function to remove the observer
|
|
488
|
+
return () => {
|
|
489
|
+
observer.disconnect();
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
};
|
|
493
|
+
"""
|
|
494
|
+
|
|
495
|
+
my_component = st.components.v2.component(
|
|
496
|
+
"sidebar_expansion_detector",
|
|
497
|
+
js=JS,
|
|
498
|
+
)
|
|
499
|
+
|
|
500
|
+
st.sidebar.write("Sidebar content")
|
|
501
|
+
result = my_component(on_expanded_change=lambda: None)
|
|
502
|
+
result
|
|
503
|
+
|
|
504
|
+
.. output::
|
|
505
|
+
https://doc-components-cleanup-function.streamlit.app/
|
|
506
|
+
height: 250px
|
|
507
|
+
|
|
508
|
+
'''
|
|
509
|
+
return _create_component_callable(name, html=html, css=css, js=js)
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
__all__ = [
|
|
513
|
+
"component",
|
|
514
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from streamlit.components.v2.bidi_component.main import BidiComponentMixin
|
|
18
|
+
from streamlit.components.v2.bidi_component.state import BidiComponentResult
|
|
19
|
+
|
|
20
|
+
__all__ = ["BidiComponentMixin", "BidiComponentResult"]
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from typing import Final
|
|
18
|
+
|
|
19
|
+
INTERNAL_COMPONENT_NAME: Final[str] = "bidi_component"
|
|
20
|
+
|
|
21
|
+
# Shared constant that delimits the base widget id from the event suffix.
|
|
22
|
+
# This value **must** stay in sync with its TypeScript counterpart defined in
|
|
23
|
+
# `frontend/lib/src/components/widgets/BidiComponent/constants.ts`.
|
|
24
|
+
EVENT_DELIM: Final[str] = "__"
|
|
25
|
+
|
|
26
|
+
# Shared constant that is used to identify ArrowReference objects in the data structure.
|
|
27
|
+
# This value **must** stay in sync with its TypeScript counterpart defined in
|
|
28
|
+
# `frontend/lib/src/components/widgets/BidiComponent/constants.ts`.
|
|
29
|
+
ARROW_REF_KEY: Final[str] = "__streamlit_arrow_ref__"
|