solara-ui 1.45.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.
- prefix/etc/jupyter/jupyter_notebook_config.d/solara.json +7 -0
- prefix/etc/jupyter/jupyter_server_config.d/solara.json +7 -0
- solara/__init__.py +124 -0
- solara/__main__.py +765 -0
- solara/_stores.py +297 -0
- solara/alias.py +6 -0
- solara/autorouting.py +555 -0
- solara/cache.py +305 -0
- solara/checks.html +71 -0
- solara/checks.py +227 -0
- solara/comm.py +28 -0
- solara/components/__init__.py +77 -0
- solara/components/alert.py +155 -0
- solara/components/applayout.py +397 -0
- solara/components/button.py +85 -0
- solara/components/card.py +87 -0
- solara/components/checkbox.py +50 -0
- solara/components/code_highlight_css.py +11 -0
- solara/components/code_highlight_css.vue +63 -0
- solara/components/columns.py +159 -0
- solara/components/component_vue.py +134 -0
- solara/components/cross_filter.py +335 -0
- solara/components/dataframe.py +546 -0
- solara/components/datatable.py +214 -0
- solara/components/datatable.vue +175 -0
- solara/components/details.py +56 -0
- solara/components/download.vue +35 -0
- solara/components/echarts.py +86 -0
- solara/components/echarts.vue +139 -0
- solara/components/figure_altair.py +39 -0
- solara/components/file_browser.py +181 -0
- solara/components/file_download.py +199 -0
- solara/components/file_drop.py +159 -0
- solara/components/file_drop.vue +83 -0
- solara/components/file_list_widget.vue +78 -0
- solara/components/head.py +27 -0
- solara/components/head_tag.py +49 -0
- solara/components/head_tag.vue +60 -0
- solara/components/image.py +173 -0
- solara/components/input.py +456 -0
- solara/components/input_text_area.py +86 -0
- solara/components/link.py +55 -0
- solara/components/markdown.py +441 -0
- solara/components/markdown_editor.py +33 -0
- solara/components/markdown_editor.vue +359 -0
- solara/components/matplotlib.py +74 -0
- solara/components/meta.py +47 -0
- solara/components/misc.py +333 -0
- solara/components/pivot_table.py +258 -0
- solara/components/pivot_table.vue +158 -0
- solara/components/progress.py +47 -0
- solara/components/select.py +182 -0
- solara/components/select.vue +27 -0
- solara/components/slider.py +442 -0
- solara/components/slider_date.vue +56 -0
- solara/components/spinner-solara.vue +105 -0
- solara/components/spinner.py +45 -0
- solara/components/sql_code.py +41 -0
- solara/components/sql_code.vue +125 -0
- solara/components/style.py +105 -0
- solara/components/switch.py +71 -0
- solara/components/tab_navigation.py +37 -0
- solara/components/title.py +90 -0
- solara/components/title.vue +38 -0
- solara/components/togglebuttons.py +200 -0
- solara/components/tooltip.py +61 -0
- solara/core.py +42 -0
- solara/datatypes.py +143 -0
- solara/express.py +241 -0
- solara/hooks/__init__.py +4 -0
- solara/hooks/dataframe.py +99 -0
- solara/hooks/misc.py +263 -0
- solara/hooks/use_reactive.py +151 -0
- solara/hooks/use_thread.py +129 -0
- solara/kitchensink.py +8 -0
- solara/lab/__init__.py +34 -0
- solara/lab/components/__init__.py +7 -0
- solara/lab/components/chat.py +215 -0
- solara/lab/components/confirmation_dialog.py +163 -0
- solara/lab/components/cross_filter.py +7 -0
- solara/lab/components/input_date.py +339 -0
- solara/lab/components/input_time.py +133 -0
- solara/lab/components/menu.py +181 -0
- solara/lab/components/menu.vue +38 -0
- solara/lab/components/tabs.py +274 -0
- solara/lab/components/theming.py +98 -0
- solara/lab/components/theming.vue +72 -0
- solara/lab/hooks/__init__.py +0 -0
- solara/lab/hooks/dataframe.py +2 -0
- solara/lab/toestand.py +3 -0
- solara/lab/utils/__init__.py +2 -0
- solara/lab/utils/cookies.py +5 -0
- solara/lab/utils/dataframe.py +165 -0
- solara/lab/utils/headers.py +5 -0
- solara/layout.py +44 -0
- solara/lifecycle.py +46 -0
- solara/minisettings.py +141 -0
- solara/py.typed +0 -0
- solara/reactive.py +99 -0
- solara/routing.py +268 -0
- solara/scope/__init__.py +88 -0
- solara/scope/types.py +55 -0
- solara/server/__init__.py +0 -0
- solara/server/app.py +527 -0
- solara/server/assets/custom.css +1 -0
- solara/server/assets/custom.js +1 -0
- solara/server/assets/favicon.png +0 -0
- solara/server/assets/favicon.svg +5 -0
- solara/server/assets/style.css +1681 -0
- solara/server/assets/theme-dark.css +437 -0
- solara/server/assets/theme-light.css +420 -0
- solara/server/assets/theme.js +3 -0
- solara/server/cdn_helper.py +91 -0
- solara/server/esm.py +71 -0
- solara/server/fastapi.py +5 -0
- solara/server/flask.py +297 -0
- solara/server/jupyter/__init__.py +2 -0
- solara/server/jupyter/cdn_handler.py +28 -0
- solara/server/jupyter/server_extension.py +40 -0
- solara/server/jupyter/solara.py +91 -0
- solara/server/jupytertools.py +46 -0
- solara/server/kernel.py +388 -0
- solara/server/kernel_context.py +467 -0
- solara/server/patch.py +564 -0
- solara/server/pyinstaller/__init__.py +9 -0
- solara/server/pyinstaller/hook-ipyreact.py +5 -0
- solara/server/pyinstaller/hook-ipyvuetify.py +5 -0
- solara/server/pyinstaller/hook-solara.py +9 -0
- solara/server/qt.py +113 -0
- solara/server/reload.py +251 -0
- solara/server/server.py +484 -0
- solara/server/settings.py +249 -0
- solara/server/shell.py +269 -0
- solara/server/starlette.py +770 -0
- solara/server/static/ansi.js +270 -0
- solara/server/static/highlight-dark.css +82 -0
- solara/server/static/highlight.css +43 -0
- solara/server/static/main-vuetify.js +272 -0
- solara/server/static/main.js +163 -0
- solara/server/static/solara_bootstrap.py +129 -0
- solara/server/static/sun.svg +23 -0
- solara/server/static/webworker.js +42 -0
- solara/server/telemetry.py +212 -0
- solara/server/templates/index.html.j2 +1 -0
- solara/server/templates/loader-plain.css +11 -0
- solara/server/templates/loader-plain.html +20 -0
- solara/server/templates/loader-solara.css +111 -0
- solara/server/templates/loader-solara.html +40 -0
- solara/server/templates/plain.html +82 -0
- solara/server/templates/solara.html.j2 +486 -0
- solara/server/threaded.py +84 -0
- solara/server/utils.py +44 -0
- solara/server/websocket.py +45 -0
- solara/settings.py +86 -0
- solara/tasks.py +893 -0
- solara/template/button.py +16 -0
- solara/template/markdown.py +42 -0
- solara/template/portal/.flake8 +6 -0
- solara/template/portal/.pre-commit-config.yaml +28 -0
- solara/template/portal/LICENSE +21 -0
- solara/template/portal/Procfile +7 -0
- solara/template/portal/mypy.ini +3 -0
- solara/template/portal/pyproject.toml +26 -0
- solara/template/portal/solara_portal/__init__.py +4 -0
- solara/template/portal/solara_portal/components/__init__.py +2 -0
- solara/template/portal/solara_portal/components/article.py +28 -0
- solara/template/portal/solara_portal/components/data.py +28 -0
- solara/template/portal/solara_portal/components/header.py +6 -0
- solara/template/portal/solara_portal/components/layout.py +6 -0
- solara/template/portal/solara_portal/content/articles/equis-in-vidi.md +85 -0
- solara/template/portal/solara_portal/content/articles/substiterat-vati.md +70 -0
- solara/template/portal/solara_portal/data.py +60 -0
- solara/template/portal/solara_portal/pages/__init__.py +67 -0
- solara/template/portal/solara_portal/pages/article/__init__.py +26 -0
- solara/template/portal/solara_portal/pages/tabular.py +29 -0
- solara/template/portal/solara_portal/pages/viz/__init__.py +70 -0
- solara/template/portal/solara_portal/pages/viz/overview.py +14 -0
- solara/test/__init__.py +0 -0
- solara/test/pytest_plugin.py +783 -0
- solara/toestand.py +998 -0
- solara/util.py +348 -0
- solara/validate_hooks.py +258 -0
- solara/website/__init__.py +0 -0
- solara/website/assets/custom.css +444 -0
- solara/website/assets/images/logo-small.png +0 -0
- solara/website/assets/images/logo.svg +17 -0
- solara/website/assets/images/logo_white.svg +50 -0
- solara/website/assets/theme.js +8 -0
- solara/website/components/__init__.py +5 -0
- solara/website/components/algolia.py +6 -0
- solara/website/components/algolia.vue +24 -0
- solara/website/components/algolia_api.vue +202 -0
- solara/website/components/breadcrumbs.py +28 -0
- solara/website/components/contact.py +144 -0
- solara/website/components/docs.py +143 -0
- solara/website/components/header.py +75 -0
- solara/website/components/mailchimp.py +12 -0
- solara/website/components/mailchimp.vue +47 -0
- solara/website/components/markdown.py +99 -0
- solara/website/components/markdown_nav.vue +34 -0
- solara/website/components/notebook.py +171 -0
- solara/website/components/sidebar.py +105 -0
- solara/website/pages/__init__.py +370 -0
- solara/website/pages/about/__init__.py +9 -0
- solara/website/pages/about/about.md +3 -0
- solara/website/pages/apps/__init__.py +16 -0
- solara/website/pages/apps/authorization/__init__.py +119 -0
- solara/website/pages/apps/authorization/admin.py +12 -0
- solara/website/pages/apps/authorization/users.py +12 -0
- solara/website/pages/apps/jupyter-dashboard-1.py +116 -0
- solara/website/pages/apps/layout-demo.py +40 -0
- solara/website/pages/apps/multipage/__init__.py +38 -0
- solara/website/pages/apps/multipage/page1.py +26 -0
- solara/website/pages/apps/multipage/page2.py +34 -0
- solara/website/pages/apps/scatter.py +136 -0
- solara/website/pages/apps/scrolling.py +63 -0
- solara/website/pages/apps/tutorial-streamlit.py +18 -0
- solara/website/pages/careers/__init__.py +27 -0
- solara/website/pages/changelog/__init__.py +10 -0
- solara/website/pages/changelog/changelog.md +372 -0
- solara/website/pages/contact/__init__.py +34 -0
- solara/website/pages/doc_use_download.py +85 -0
- solara/website/pages/documentation/__init__.py +90 -0
- solara/website/pages/documentation/advanced/__init__.py +9 -0
- solara/website/pages/documentation/advanced/content/00-overview.md +1 -0
- solara/website/pages/documentation/advanced/content/10-howto/00-overview.md +6 -0
- solara/website/pages/documentation/advanced/content/10-howto/10-multipage.md +196 -0
- solara/website/pages/documentation/advanced/content/10-howto/20-layout.md +125 -0
- solara/website/pages/documentation/advanced/content/10-howto/30-testing.md +417 -0
- solara/website/pages/documentation/advanced/content/10-howto/31-debugging.md +69 -0
- solara/website/pages/documentation/advanced/content/10-howto/40-embed.md +50 -0
- solara/website/pages/documentation/advanced/content/10-howto/50-ipywidget_libraries.md +124 -0
- solara/website/pages/documentation/advanced/content/15-reference/00-overview.md +3 -0
- solara/website/pages/documentation/advanced/content/15-reference/40-static_files.md +31 -0
- solara/website/pages/documentation/advanced/content/15-reference/41-asset-files.md +72 -0
- solara/website/pages/documentation/advanced/content/15-reference/60-static-site-generation.md +59 -0
- solara/website/pages/documentation/advanced/content/15-reference/70-search.md +34 -0
- solara/website/pages/documentation/advanced/content/15-reference/80-reloading.md +34 -0
- solara/website/pages/documentation/advanced/content/15-reference/90-notebook-support.md +7 -0
- solara/website/pages/documentation/advanced/content/15-reference/95-caching.md +148 -0
- solara/website/pages/documentation/advanced/content/20-understanding/00-introduction.md +10 -0
- solara/website/pages/documentation/advanced/content/20-understanding/05-ipywidgets.md +35 -0
- solara/website/pages/documentation/advanced/content/20-understanding/06-ipyvuetify.md +42 -0
- solara/website/pages/documentation/advanced/content/20-understanding/10-reacton.md +28 -0
- solara/website/pages/documentation/advanced/content/20-understanding/12-reacton-basics.md +108 -0
- solara/website/pages/documentation/advanced/content/20-understanding/15-anatomy.md +23 -0
- solara/website/pages/documentation/advanced/content/20-understanding/17-rules-of-hooks.md +192 -0
- solara/website/pages/documentation/advanced/content/20-understanding/18-containers.md +166 -0
- solara/website/pages/documentation/advanced/content/20-understanding/20-solara.md +18 -0
- solara/website/pages/documentation/advanced/content/20-understanding/40-routing.md +256 -0
- solara/website/pages/documentation/advanced/content/20-understanding/50-solara-server.md +108 -0
- solara/website/pages/documentation/advanced/content/20-understanding/60-voila.md +12 -0
- solara/website/pages/documentation/advanced/content/30-enterprise/00-overview.md +7 -0
- solara/website/pages/documentation/advanced/content/30-enterprise/10-oauth.md +187 -0
- solara/website/pages/documentation/advanced/content/40-development/00-overview.md +0 -0
- solara/website/pages/documentation/advanced/content/40-development/01-contribute.md +45 -0
- solara/website/pages/documentation/advanced/content/40-development/10-setup.md +76 -0
- solara/website/pages/documentation/api/__init__.py +19 -0
- solara/website/pages/documentation/api/cross_filter/__init__.py +9 -0
- solara/website/pages/documentation/api/cross_filter/cross_filter_dataframe.py +22 -0
- solara/website/pages/documentation/api/cross_filter/cross_filter_report.py +20 -0
- solara/website/pages/documentation/api/cross_filter/cross_filter_select.py +20 -0
- solara/website/pages/documentation/api/cross_filter/cross_filter_slider.py +20 -0
- solara/website/pages/documentation/api/hooks/__init__.py +9 -0
- solara/website/pages/documentation/api/hooks/use_cross_filter.py +23 -0
- solara/website/pages/documentation/api/hooks/use_dark_effective.py +12 -0
- solara/website/pages/documentation/api/hooks/use_effect.md +43 -0
- solara/website/pages/documentation/api/hooks/use_effect.py +9 -0
- solara/website/pages/documentation/api/hooks/use_exception.py +31 -0
- solara/website/pages/documentation/api/hooks/use_memo.md +16 -0
- solara/website/pages/documentation/api/hooks/use_memo.py +9 -0
- solara/website/pages/documentation/api/hooks/use_previous.py +30 -0
- solara/website/pages/documentation/api/hooks/use_reactive.py +16 -0
- solara/website/pages/documentation/api/hooks/use_state.py +10 -0
- solara/website/pages/documentation/api/hooks/use_state_or_update.py +66 -0
- solara/website/pages/documentation/api/hooks/use_thread.md +64 -0
- solara/website/pages/documentation/api/hooks/use_thread.py +42 -0
- solara/website/pages/documentation/api/hooks/use_trait_observe.py +12 -0
- solara/website/pages/documentation/api/routing/__init__.py +9 -0
- solara/website/pages/documentation/api/routing/generate_routes.py +10 -0
- solara/website/pages/documentation/api/routing/generate_routes_directory.py +10 -0
- solara/website/pages/documentation/api/routing/resolve_path.py +35 -0
- solara/website/pages/documentation/api/routing/route.py +29 -0
- solara/website/pages/documentation/api/routing/use_route.py +76 -0
- solara/website/pages/documentation/api/routing/use_router.py +16 -0
- solara/website/pages/documentation/api/utilities/__init__.py +9 -0
- solara/website/pages/documentation/api/utilities/component_vue.py +10 -0
- solara/website/pages/documentation/api/utilities/computed.py +16 -0
- solara/website/pages/documentation/api/utilities/display.py +16 -0
- solara/website/pages/documentation/api/utilities/get_kernel_id.py +16 -0
- solara/website/pages/documentation/api/utilities/get_session_id.py +16 -0
- solara/website/pages/documentation/api/utilities/memoize.py +35 -0
- solara/website/pages/documentation/api/utilities/on_kernel_start.py +44 -0
- solara/website/pages/documentation/api/utilities/reactive.py +16 -0
- solara/website/pages/documentation/api/utilities/widget.py +104 -0
- solara/website/pages/documentation/components/__init__.py +12 -0
- solara/website/pages/documentation/components/advanced/__init__.py +9 -0
- solara/website/pages/documentation/components/advanced/link.py +25 -0
- solara/website/pages/documentation/components/advanced/meta.py +17 -0
- solara/website/pages/documentation/components/advanced/style.py +43 -0
- solara/website/pages/documentation/components/common.py +9 -0
- solara/website/pages/documentation/components/data/__init__.py +9 -0
- solara/website/pages/documentation/components/data/dataframe.py +44 -0
- solara/website/pages/documentation/components/data/pivot_table.py +81 -0
- solara/website/pages/documentation/components/enterprise/__init__.py +9 -0
- solara/website/pages/documentation/components/enterprise/avatar.py +24 -0
- solara/website/pages/documentation/components/enterprise/avatar_menu.py +25 -0
- solara/website/pages/documentation/components/input/__init__.py +9 -0
- solara/website/pages/documentation/components/input/button.py +23 -0
- solara/website/pages/documentation/components/input/checkbox.py +10 -0
- solara/website/pages/documentation/components/input/file_browser.py +30 -0
- solara/website/pages/documentation/components/input/file_drop.py +76 -0
- solara/website/pages/documentation/components/input/input.py +43 -0
- solara/website/pages/documentation/components/input/select.py +22 -0
- solara/website/pages/documentation/components/input/slider.py +29 -0
- solara/website/pages/documentation/components/input/switch.py +10 -0
- solara/website/pages/documentation/components/input/togglebuttons.py +21 -0
- solara/website/pages/documentation/components/lab/__init__.py +9 -0
- solara/website/pages/documentation/components/lab/chat.py +109 -0
- solara/website/pages/documentation/components/lab/confirmation_dialog.py +55 -0
- solara/website/pages/documentation/components/lab/cookies_headers.py +48 -0
- solara/website/pages/documentation/components/lab/input_date.py +20 -0
- solara/website/pages/documentation/components/lab/input_time.py +15 -0
- solara/website/pages/documentation/components/lab/menu.py +22 -0
- solara/website/pages/documentation/components/lab/tab.py +25 -0
- solara/website/pages/documentation/components/lab/tabs.py +45 -0
- solara/website/pages/documentation/components/lab/task.py +11 -0
- solara/website/pages/documentation/components/lab/theming.py +74 -0
- solara/website/pages/documentation/components/lab/use_task.py +11 -0
- solara/website/pages/documentation/components/layout/__init__.py +9 -0
- solara/website/pages/documentation/components/layout/app_bar.py +16 -0
- solara/website/pages/documentation/components/layout/app_bar_title.py +16 -0
- solara/website/pages/documentation/components/layout/app_layout.py +24 -0
- solara/website/pages/documentation/components/layout/card.py +15 -0
- solara/website/pages/documentation/components/layout/card_actions.py +16 -0
- solara/website/pages/documentation/components/layout/column.py +30 -0
- solara/website/pages/documentation/components/layout/columns.py +27 -0
- solara/website/pages/documentation/components/layout/columns_responsive.py +66 -0
- solara/website/pages/documentation/components/layout/details.py +13 -0
- solara/website/pages/documentation/components/layout/griddraggable.py +62 -0
- solara/website/pages/documentation/components/layout/gridfixed.py +19 -0
- solara/website/pages/documentation/components/layout/hbox.py +18 -0
- solara/website/pages/documentation/components/layout/row.py +30 -0
- solara/website/pages/documentation/components/layout/sidebar.py +24 -0
- solara/website/pages/documentation/components/layout/vbox.py +19 -0
- solara/website/pages/documentation/components/output/__init__.py +9 -0
- solara/website/pages/documentation/components/output/file_download.py +11 -0
- solara/website/pages/documentation/components/output/html.py +19 -0
- solara/website/pages/documentation/components/output/image.py +11 -0
- solara/website/pages/documentation/components/output/markdown.py +57 -0
- solara/website/pages/documentation/components/output/markdown_editor.py +51 -0
- solara/website/pages/documentation/components/output/sql_code.py +83 -0
- solara/website/pages/documentation/components/output/tooltip.py +11 -0
- solara/website/pages/documentation/components/page/__init__.py +9 -0
- solara/website/pages/documentation/components/page/head.py +15 -0
- solara/website/pages/documentation/components/page/title.py +25 -0
- solara/website/pages/documentation/components/status/__init__.py +9 -0
- solara/website/pages/documentation/components/status/error.py +39 -0
- solara/website/pages/documentation/components/status/info.py +39 -0
- solara/website/pages/documentation/components/status/progress.py +10 -0
- solara/website/pages/documentation/components/status/spinner.py +11 -0
- solara/website/pages/documentation/components/status/success.py +40 -0
- solara/website/pages/documentation/components/status/warning.py +47 -0
- solara/website/pages/documentation/components/viz/__init__.py +9 -0
- solara/website/pages/documentation/components/viz/altair.py +42 -0
- solara/website/pages/documentation/components/viz/echarts.py +77 -0
- solara/website/pages/documentation/components/viz/matplotlib.py +30 -0
- solara/website/pages/documentation/components/viz/plotly.py +63 -0
- solara/website/pages/documentation/components/viz/plotly_express.py +41 -0
- solara/website/pages/documentation/examples/__init__.py +54 -0
- solara/website/pages/documentation/examples/ai/__init__.py +11 -0
- solara/website/pages/documentation/examples/ai/chatbot.py +113 -0
- solara/website/pages/documentation/examples/ai/tokenizer.py +107 -0
- solara/website/pages/documentation/examples/basics/__init__.py +10 -0
- solara/website/pages/documentation/examples/basics/sine.py +28 -0
- solara/website/pages/documentation/examples/fullscreen/__init__.py +10 -0
- solara/website/pages/documentation/examples/fullscreen/authorization.py +3 -0
- solara/website/pages/documentation/examples/fullscreen/layout_demo.py +3 -0
- solara/website/pages/documentation/examples/fullscreen/multipage.py +3 -0
- solara/website/pages/documentation/examples/fullscreen/scatter.py +3 -0
- solara/website/pages/documentation/examples/fullscreen/scrolling.py +3 -0
- solara/website/pages/documentation/examples/fullscreen/tutorial_streamlit.py +3 -0
- solara/website/pages/documentation/examples/general/__init__.py +10 -0
- solara/website/pages/documentation/examples/general/custom_storage.py +70 -0
- solara/website/pages/documentation/examples/general/deploy_model.py +115 -0
- solara/website/pages/documentation/examples/general/live_update.py +32 -0
- solara/website/pages/documentation/examples/general/login_oauth.py +81 -0
- solara/website/pages/documentation/examples/general/mycard.vue +58 -0
- solara/website/pages/documentation/examples/general/pokemon_search.py +51 -0
- solara/website/pages/documentation/examples/general/vue_component.py +50 -0
- solara/website/pages/documentation/examples/ipycanvas.py +49 -0
- solara/website/pages/documentation/examples/libraries/__init__.py +10 -0
- solara/website/pages/documentation/examples/libraries/altair.py +65 -0
- solara/website/pages/documentation/examples/libraries/bqplot.py +39 -0
- solara/website/pages/documentation/examples/libraries/ipyleaflet.py +33 -0
- solara/website/pages/documentation/examples/libraries/ipyleaflet_advanced.py +66 -0
- solara/website/pages/documentation/examples/utilities/__init__.py +10 -0
- solara/website/pages/documentation/examples/utilities/calculator.py +157 -0
- solara/website/pages/documentation/examples/utilities/countdown_timer.py +62 -0
- solara/website/pages/documentation/examples/utilities/todo.py +196 -0
- solara/website/pages/documentation/examples/visualization/__init__.py +6 -0
- solara/website/pages/documentation/examples/visualization/annotator.py +67 -0
- solara/website/pages/documentation/examples/visualization/linked_views.py +81 -0
- solara/website/pages/documentation/examples/visualization/plotly.py +44 -0
- solara/website/pages/documentation/faq/__init__.py +12 -0
- solara/website/pages/documentation/faq/content/99-faq.md +112 -0
- solara/website/pages/documentation/getting_started/__init__.py +9 -0
- solara/website/pages/documentation/getting_started/content/00-quickstart.md +107 -0
- solara/website/pages/documentation/getting_started/content/01-introduction.md +125 -0
- solara/website/pages/documentation/getting_started/content/02-installing.md +134 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/00-overview.md +14 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/10_data_science.py +13 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/20-web-app.md +89 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/30-ipywidgets.md +124 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/40-streamlit.md +146 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/50-dash.md +144 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/60-jupyter-dashboard-part1.py +65 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/SF_crime_sample.csv.gz +0 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/_data_science.ipynb +445 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/_jupyter_dashboard_1.ipynb +1021 -0
- solara/website/pages/documentation/getting_started/content/05-fundamentals/00-overview.md +11 -0
- solara/website/pages/documentation/getting_started/content/05-fundamentals/10-components.md +228 -0
- solara/website/pages/documentation/getting_started/content/05-fundamentals/50-state-management.md +278 -0
- solara/website/pages/documentation/getting_started/content/07-deploying/00-overview.md +7 -0
- solara/website/pages/documentation/getting_started/content/07-deploying/10-self-hosted.md +305 -0
- solara/website/pages/documentation/getting_started/content/07-deploying/20-cloud-hosted.md +80 -0
- solara/website/pages/documentation/getting_started/content/80-what-is-lab.md +7 -0
- solara/website/pages/documentation/getting_started/content/90-troubleshoot.md +26 -0
- solara/website/pages/docutils.py +38 -0
- solara/website/pages/home.vue +1199 -0
- solara/website/pages/our_team/__init__.py +83 -0
- solara/website/pages/pricing/__init__.py +31 -0
- solara/website/pages/roadmap/__init__.py +11 -0
- solara/website/pages/roadmap/roadmap.md +47 -0
- solara/website/pages/scale_ipywidgets.py +45 -0
- solara/website/pages/showcase/__init__.py +105 -0
- solara/website/pages/showcase/domino_code_assist.py +60 -0
- solara/website/pages/showcase/planeto_tessa.py +19 -0
- solara/website/pages/showcase/solara_dev.py +54 -0
- solara/website/pages/showcase/solarathon_2023_team_2.py +22 -0
- solara/website/pages/showcase/solarathon_2023_team_4.py +22 -0
- solara/website/pages/showcase/solarathon_2023_team_5.py +23 -0
- solara/website/pages/showcase/solarathon_2023_team_6.py +34 -0
- solara/website/pages/showcase/wanderlust.py +27 -0
- solara/website/public/beach.jpeg +0 -0
- solara/website/public/logo.svg +6 -0
- solara/website/public/social/discord.svg +1 -0
- solara/website/public/social/github.svg +1 -0
- solara/website/public/social/twitter.svg +3 -0
- solara/website/public/success.html +25 -0
- solara/website/templates/index.html.j2 +117 -0
- solara/website/utils.py +51 -0
- solara/widgets/__init__.py +1 -0
- solara/widgets/vue/gridlayout.vue +107 -0
- solara/widgets/vue/html.vue +4 -0
- solara/widgets/vue/navigator.vue +134 -0
- solara/widgets/vue/vegalite.vue +130 -0
- solara/widgets/widgets.py +74 -0
- solara_ui-1.45.0.data/data/etc/jupyter/jupyter_notebook_config.d/solara.json +7 -0
- solara_ui-1.45.0.data/data/etc/jupyter/jupyter_server_config.d/solara.json +7 -0
- solara_ui-1.45.0.dist-info/METADATA +162 -0
- solara_ui-1.45.0.dist-info/RECORD +464 -0
- solara_ui-1.45.0.dist-info/WHEEL +4 -0
- solara_ui-1.45.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
import html
|
|
3
|
+
import logging
|
|
4
|
+
import textwrap
|
|
5
|
+
import traceback
|
|
6
|
+
import warnings
|
|
7
|
+
from typing import Any, Callable, Dict, List, Optional, Union, cast
|
|
8
|
+
import typing
|
|
9
|
+
|
|
10
|
+
import ipyvuetify as v
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
import pymdownx.emoji
|
|
14
|
+
import pymdownx.highlight
|
|
15
|
+
import pymdownx.superfences
|
|
16
|
+
|
|
17
|
+
has_pymdownx = True
|
|
18
|
+
except ModuleNotFoundError:
|
|
19
|
+
has_pymdownx = False
|
|
20
|
+
import reacton.core
|
|
21
|
+
|
|
22
|
+
import solara
|
|
23
|
+
import solara.components.applayout
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
import pygments
|
|
27
|
+
|
|
28
|
+
has_pygments = True
|
|
29
|
+
except ModuleNotFoundError:
|
|
30
|
+
has_pygments = False
|
|
31
|
+
else:
|
|
32
|
+
from pygments.formatters import HtmlFormatter
|
|
33
|
+
from pygments.lexers import get_lexer_by_name
|
|
34
|
+
|
|
35
|
+
if typing.TYPE_CHECKING:
|
|
36
|
+
import markdown
|
|
37
|
+
|
|
38
|
+
logger = logging.getLogger(__name__)
|
|
39
|
+
|
|
40
|
+
html_no_execute_enabled = "<div><i>Solara execution is not enabled</i></div>"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@solara.component
|
|
44
|
+
def ExceptionGuard(children=[]):
|
|
45
|
+
exception, clear_exception = solara.use_exception()
|
|
46
|
+
if exception:
|
|
47
|
+
solara.Error(f"Oops, an error occurred: {str(exception)}")
|
|
48
|
+
with solara.Details("Exception details"):
|
|
49
|
+
error = "".join(traceback.format_exception(None, exception, exception.__traceback__))
|
|
50
|
+
solara.Preformatted(error)
|
|
51
|
+
else:
|
|
52
|
+
if len(children) == 1:
|
|
53
|
+
return children[0]
|
|
54
|
+
else:
|
|
55
|
+
solara.Column(children=children)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _run_solara(code, cleanups):
|
|
59
|
+
ast = compile(code, "markdown", "exec")
|
|
60
|
+
local_scope: Dict[Any, Any] = {}
|
|
61
|
+
exec(ast, local_scope)
|
|
62
|
+
app = None
|
|
63
|
+
if "app" in local_scope:
|
|
64
|
+
app = local_scope["app"]
|
|
65
|
+
elif "Page" in local_scope:
|
|
66
|
+
Page = local_scope["Page"]
|
|
67
|
+
app = solara.components.applayout._AppLayoutEmbed(children=[ExceptionGuard(children=[Page()])])
|
|
68
|
+
else:
|
|
69
|
+
raise NameError("No Page or app defined")
|
|
70
|
+
box = v.Html(tag="div")
|
|
71
|
+
|
|
72
|
+
rc: reacton.core.RenderContext
|
|
73
|
+
|
|
74
|
+
def cleanup():
|
|
75
|
+
rc.close()
|
|
76
|
+
|
|
77
|
+
cleanups.append(cleanup)
|
|
78
|
+
box, rc = solara.render(cast(solara.Element, app), container=box) # type: ignore
|
|
79
|
+
widget_id = box._model_id
|
|
80
|
+
return (
|
|
81
|
+
'<div class="solara-markdown-output v-card v-sheet elevation-7">'
|
|
82
|
+
f'<jupyter-widget widget="IPY_MODEL_{widget_id}">loading widget...</jupyter-widget>'
|
|
83
|
+
'<div class="v-messages">Live output</div></div>'
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _markdown_template(
|
|
88
|
+
html,
|
|
89
|
+
style="",
|
|
90
|
+
):
|
|
91
|
+
cdn = None
|
|
92
|
+
import solara.settings
|
|
93
|
+
|
|
94
|
+
if not solara.settings.assets.proxy:
|
|
95
|
+
cdn = solara.settings.assets.cdn
|
|
96
|
+
|
|
97
|
+
template = (
|
|
98
|
+
"""
|
|
99
|
+
<template>
|
|
100
|
+
<div class="solara-markdown rendered_html jp-RenderedHTMLCommon" style=\""""
|
|
101
|
+
+ style
|
|
102
|
+
+ """\">"""
|
|
103
|
+
+ html
|
|
104
|
+
+ r"""</div>
|
|
105
|
+
</template>
|
|
106
|
+
|
|
107
|
+
<script>
|
|
108
|
+
module.exports = {
|
|
109
|
+
async mounted() {
|
|
110
|
+
this.cdn = """
|
|
111
|
+
+ (rf"'{cdn}'" if cdn is not None else r"null")
|
|
112
|
+
+ r""";
|
|
113
|
+
await this.loadRequire();
|
|
114
|
+
this.mermaid = await this.loadMermaid();
|
|
115
|
+
this.mermaid.init();
|
|
116
|
+
this.latexSettings = {
|
|
117
|
+
delimiters: [
|
|
118
|
+
{left: "$$", right: "$$", display: true},
|
|
119
|
+
{left: "$", right: "$", display: false},
|
|
120
|
+
{left: "\\[", right: "\\]", display: true},
|
|
121
|
+
{left: "\\(", right: "\\)", display: false}
|
|
122
|
+
]
|
|
123
|
+
};
|
|
124
|
+
if (window.renderMathInElement) {
|
|
125
|
+
window.renderMathInElement(this.$el, this.latexSettings);
|
|
126
|
+
} else if (window.MathJax && MathJax.Hub) {
|
|
127
|
+
MathJax.Hub.Queue(['Typeset', MathJax.Hub, this.$el]);
|
|
128
|
+
} else {
|
|
129
|
+
window.renderMathInElement = await this.loadKatexExt();
|
|
130
|
+
window.renderMathInElement(this.$el, this.latexSettings);
|
|
131
|
+
}
|
|
132
|
+
this.$el.querySelectorAll("a").forEach(a => this.setupRouter(a))
|
|
133
|
+
window.md = this.$el
|
|
134
|
+
},
|
|
135
|
+
methods: {
|
|
136
|
+
setupRouter(a) {
|
|
137
|
+
let href = a.attributes['href'].value;
|
|
138
|
+
if(href.startsWith("./")) {
|
|
139
|
+
// TODO: should we really do this?
|
|
140
|
+
href = location.pathname + href.substr(1);
|
|
141
|
+
a.attributes['href'].href = href;
|
|
142
|
+
}
|
|
143
|
+
let authLink = href.startsWith("/_solara/auth/");
|
|
144
|
+
if( (href.startsWith("./") || href.startsWith("/")) && !authLink) {
|
|
145
|
+
a.onclick = e => {
|
|
146
|
+
console.log("clicked", href)
|
|
147
|
+
if(href.startsWith("./")) {
|
|
148
|
+
solara.router.push(href);
|
|
149
|
+
} else {
|
|
150
|
+
solara.router.push(href);
|
|
151
|
+
}
|
|
152
|
+
e.preventDefault()
|
|
153
|
+
}
|
|
154
|
+
} else if(href.startsWith("#")) {
|
|
155
|
+
href = location.pathname + href;
|
|
156
|
+
a.attributes['href'].value = href;
|
|
157
|
+
} else {
|
|
158
|
+
console.log("href", href, "is not a local link")
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
async loadKatex() {
|
|
162
|
+
require.config({
|
|
163
|
+
map: {
|
|
164
|
+
'*': {
|
|
165
|
+
'katex': `${this.getCdn()}/katex@0.16.9/dist/katex.min.js`,
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
const link = document.createElement('link');
|
|
170
|
+
link.type = "text/css";
|
|
171
|
+
link.rel = "stylesheet";
|
|
172
|
+
link.href = `${this.getCdn()}/katex@0.16.9/dist/katex.min.css`;
|
|
173
|
+
document.head.appendChild(link);
|
|
174
|
+
},
|
|
175
|
+
async loadKatexExt() {
|
|
176
|
+
this.loadKatex();
|
|
177
|
+
return (await this.import([`${this.getCdn()}/katex@0.16.9/dist/contrib/auto-render.min.js`]))[0]
|
|
178
|
+
},
|
|
179
|
+
async loadMermaid() {
|
|
180
|
+
return (await this.import([`${this.getCdn()}/mermaid@10.8.0/dist/mermaid.min.js`]))[0]
|
|
181
|
+
},
|
|
182
|
+
import(dependencies) {
|
|
183
|
+
return this.loadRequire().then(
|
|
184
|
+
() => {
|
|
185
|
+
if (window.jupyterVue) {
|
|
186
|
+
// in jupyterlab, we take Vue from ipyvue/jupyterVue
|
|
187
|
+
define("vue", [], () => window.jupyterVue.Vue);
|
|
188
|
+
} else {
|
|
189
|
+
define("vue", ['jupyter-vue'], jupyterVue => jupyterVue.Vue);
|
|
190
|
+
}
|
|
191
|
+
return new Promise((resolve, reject) => {
|
|
192
|
+
requirejs(dependencies, (...modules) => resolve(modules));
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
},
|
|
197
|
+
loadRequire() {
|
|
198
|
+
if (window.requirejs) {
|
|
199
|
+
return Promise.resolve();
|
|
200
|
+
}
|
|
201
|
+
return new Promise((resolve, reject) => {
|
|
202
|
+
const script = document.createElement('script');
|
|
203
|
+
script.src = `${this.getCdn()}/requirejs@2.3.6/require.min.js`;
|
|
204
|
+
script.onload = resolve;
|
|
205
|
+
script.onerror = reject;
|
|
206
|
+
document.head.appendChild(script);
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
getJupyterBaseUrl() {
|
|
210
|
+
// if base url is set, we use ./ for relative paths compared to the base url
|
|
211
|
+
if (document.getElementsByTagName("base").length) {
|
|
212
|
+
return "./";
|
|
213
|
+
}
|
|
214
|
+
const labConfigData = document.getElementById('jupyter-config-data');
|
|
215
|
+
if (labConfigData) {
|
|
216
|
+
/* lab and Voila */
|
|
217
|
+
return JSON.parse(labConfigData.textContent).baseUrl;
|
|
218
|
+
}
|
|
219
|
+
let base = document.body.dataset.baseUrl || document.baseURI;
|
|
220
|
+
if (!base.endsWith('/')) {
|
|
221
|
+
base += '/';
|
|
222
|
+
}
|
|
223
|
+
return base
|
|
224
|
+
},
|
|
225
|
+
getCdn() {
|
|
226
|
+
return this.cdn || (window.solara ? window.solara.cdn : `${this.getJupyterBaseUrl()}_solara/cdn`);
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
updated() {
|
|
230
|
+
// if the html gets update, re-run mermaid
|
|
231
|
+
this.mermaid.init();
|
|
232
|
+
|
|
233
|
+
if(window.MathJax && MathJax.Hub) {
|
|
234
|
+
MathJax.Hub.Queue(['Typeset', MathJax.Hub, this.$el]);
|
|
235
|
+
} else {
|
|
236
|
+
window.renderMathInElement(this.$el, this.latexSettings);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
</script>
|
|
241
|
+
"""
|
|
242
|
+
)
|
|
243
|
+
return template
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def _highlight(src, language, class_name=None, options=None, md=None, unsafe_solara_execute=False, cleanups=None, **kwargs):
|
|
247
|
+
"""Highlight a block of code"""
|
|
248
|
+
if not has_pygments:
|
|
249
|
+
warnings.warn("Pygments is not installed, code highlighting will not work, use pip install pygments to install it.")
|
|
250
|
+
src_safe = html.escape(src)
|
|
251
|
+
return f"<pre><code>{src_safe}</code></pre>"
|
|
252
|
+
|
|
253
|
+
run_src_with_solara = False
|
|
254
|
+
if language == "solara":
|
|
255
|
+
run_src_with_solara = True
|
|
256
|
+
language = "python"
|
|
257
|
+
|
|
258
|
+
lexer = get_lexer_by_name(language)
|
|
259
|
+
formatter = HtmlFormatter()
|
|
260
|
+
src_html = pygments.highlight(src, lexer, formatter)
|
|
261
|
+
|
|
262
|
+
if run_src_with_solara:
|
|
263
|
+
if unsafe_solara_execute:
|
|
264
|
+
html_widget = _run_solara(src, cleanups)
|
|
265
|
+
return src_html + html_widget
|
|
266
|
+
else:
|
|
267
|
+
return src_html + html_no_execute_enabled
|
|
268
|
+
else:
|
|
269
|
+
return src_html
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def formatter(unsafe_solara_execute: bool, cleanups: List[Callable[[], None]]):
|
|
273
|
+
def wrapper(*args, **kwargs):
|
|
274
|
+
try:
|
|
275
|
+
kwargs["unsafe_solara_execute"] = unsafe_solara_execute
|
|
276
|
+
kwargs["cleanups"] = cleanups
|
|
277
|
+
return _highlight(*args, **kwargs)
|
|
278
|
+
except Exception as e:
|
|
279
|
+
logger.exception("Error while highlighting code")
|
|
280
|
+
raise e
|
|
281
|
+
|
|
282
|
+
return wrapper
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
@solara.component
|
|
286
|
+
def MarkdownIt(md_text: str, highlight: List[int] = [], unsafe_solara_execute: bool = False):
|
|
287
|
+
md_text = textwrap.dedent(md_text)
|
|
288
|
+
|
|
289
|
+
from markdown_it import MarkdownIt as MarkdownItMod
|
|
290
|
+
from mdit_py_plugins import container, deflist # noqa: F401
|
|
291
|
+
from mdit_py_plugins.footnote import footnote_plugin # noqa: F401
|
|
292
|
+
from mdit_py_plugins.front_matter import front_matter_plugin # noqa: F401
|
|
293
|
+
|
|
294
|
+
cleanups = solara.use_ref(cast(List[Callable[[], None]], []))
|
|
295
|
+
|
|
296
|
+
def highlight_code(code, name, attrs):
|
|
297
|
+
return _highlight(cleanups.current, code, name, unsafe_solara_execute, attrs)
|
|
298
|
+
|
|
299
|
+
md = MarkdownItMod(
|
|
300
|
+
"js-default",
|
|
301
|
+
{
|
|
302
|
+
"html": True,
|
|
303
|
+
"typographer": True,
|
|
304
|
+
"highlight": highlight_code,
|
|
305
|
+
},
|
|
306
|
+
)
|
|
307
|
+
md = md.use(container.container_plugin, name="note")
|
|
308
|
+
html = md.render(md_text)
|
|
309
|
+
hash = hashlib.sha256((html + str(unsafe_solara_execute) + repr(highlight)).encode("utf-8")).hexdigest()
|
|
310
|
+
|
|
311
|
+
def cleanup_wrapper():
|
|
312
|
+
def cleanup():
|
|
313
|
+
for cleanup in cleanups.current:
|
|
314
|
+
cleanup()
|
|
315
|
+
|
|
316
|
+
return cleanup
|
|
317
|
+
|
|
318
|
+
solara.use_effect(cleanup_wrapper)
|
|
319
|
+
return v.VuetifyTemplate.element(template=_markdown_template(html)).key(hash)
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
if has_pymdownx:
|
|
323
|
+
_index = pymdownx.emoji.emojione(None, None)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def _no_deep_copy_emojione(options, md):
|
|
327
|
+
return _index
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
@solara.component
|
|
331
|
+
def Markdown(md_text: str, unsafe_solara_execute=False, style: Union[str, Dict, None] = None, md_parser: Optional["markdown.Markdown"] = None):
|
|
332
|
+
"""Renders markdown text
|
|
333
|
+
|
|
334
|
+
Renders markdown using https://python-markdown.github.io/
|
|
335
|
+
|
|
336
|
+
Math rendering is done using Latex syntax, using https://katex.org/.
|
|
337
|
+
|
|
338
|
+
## Examples
|
|
339
|
+
|
|
340
|
+
### Basic
|
|
341
|
+
|
|
342
|
+
```solara
|
|
343
|
+
import solara
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
@solara.component
|
|
347
|
+
def Page():
|
|
348
|
+
return solara.Markdown(r'''
|
|
349
|
+
# This is a title
|
|
350
|
+
|
|
351
|
+
## This is a subtitle
|
|
352
|
+
This is a markdown text, **bold** and *italic* text is supported.
|
|
353
|
+
|
|
354
|
+
## Math
|
|
355
|
+
Also, $x^2$ is rendered as math.
|
|
356
|
+
|
|
357
|
+
Or multiline math:
|
|
358
|
+
$$
|
|
359
|
+
\\int_0^1 x^2 dx = \\frac{1}{3}
|
|
360
|
+
$$
|
|
361
|
+
|
|
362
|
+
''')
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Arguments
|
|
366
|
+
|
|
367
|
+
* `md_text`: The markdown text to render
|
|
368
|
+
* `unsafe_solara_execute`: If True, code marked with language "solara" will be executed. This is potentially unsafe
|
|
369
|
+
if the markdown text can come from user input and should only be used for trusted markdown.
|
|
370
|
+
* `style`: A string or dict of css styles to apply to the rendered markdown.
|
|
371
|
+
* `md_parser`: A markdown object to use for rendering. If not provided, a markdown object will be created.
|
|
372
|
+
|
|
373
|
+
"""
|
|
374
|
+
import markdown
|
|
375
|
+
|
|
376
|
+
md_text = textwrap.dedent(md_text)
|
|
377
|
+
style = solara.util._flatten_style(style)
|
|
378
|
+
cleanups = solara.use_ref(cast(List[Callable[[], None]], []))
|
|
379
|
+
|
|
380
|
+
def make_markdown_object():
|
|
381
|
+
if md_parser is not None:
|
|
382
|
+
# we won't use the use_memo
|
|
383
|
+
return None
|
|
384
|
+
if has_pymdownx:
|
|
385
|
+
return markdown.Markdown( # type: ignore
|
|
386
|
+
extensions=[
|
|
387
|
+
"pymdownx.highlight",
|
|
388
|
+
"pymdownx.superfences",
|
|
389
|
+
"pymdownx.emoji",
|
|
390
|
+
"toc", # so we get anchors for h1 h2 etc
|
|
391
|
+
"tables",
|
|
392
|
+
],
|
|
393
|
+
extension_configs={
|
|
394
|
+
"pymdownx.emoji": {
|
|
395
|
+
"emoji_index": _no_deep_copy_emojione,
|
|
396
|
+
},
|
|
397
|
+
"pymdownx.superfences": {
|
|
398
|
+
"custom_fences": [
|
|
399
|
+
{
|
|
400
|
+
"name": "mermaid",
|
|
401
|
+
"class": "mermaid",
|
|
402
|
+
"format": pymdownx.superfences.fence_div_format,
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
"name": "solara",
|
|
406
|
+
"class": "",
|
|
407
|
+
"format": formatter(unsafe_solara_execute, cleanups=cleanups.current),
|
|
408
|
+
},
|
|
409
|
+
],
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
)
|
|
413
|
+
else:
|
|
414
|
+
logger.warning("Pymdownx not installed, using default markdown. For a better experience, install pymdownx.")
|
|
415
|
+
return markdown.Markdown( # type: ignore
|
|
416
|
+
extensions=[
|
|
417
|
+
"fenced_code",
|
|
418
|
+
"codehilite",
|
|
419
|
+
"toc",
|
|
420
|
+
"tables",
|
|
421
|
+
],
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
md_self = solara.use_memo(make_markdown_object, dependencies=[unsafe_solara_execute])
|
|
425
|
+
if md_parser is None:
|
|
426
|
+
assert md_self is not None
|
|
427
|
+
md_parser = md_self
|
|
428
|
+
html = md_parser.convert(md_text)
|
|
429
|
+
|
|
430
|
+
def cleanup_wrapper():
|
|
431
|
+
def cleanup():
|
|
432
|
+
for cleanup in cleanups.current:
|
|
433
|
+
cleanup()
|
|
434
|
+
|
|
435
|
+
return cleanup
|
|
436
|
+
|
|
437
|
+
solara.use_effect(cleanup_wrapper, [])
|
|
438
|
+
# if we update the template value, the whole vue tree will rerender (ipvue/ipyvuetify issue)
|
|
439
|
+
# however, using the hash we simply generate a new widget each time
|
|
440
|
+
hash = hashlib.sha256((html + str(unsafe_solara_execute)).encode("utf-8")).hexdigest()
|
|
441
|
+
return v.VuetifyTemplate.element(template=_markdown_template(html, style)).key(hash)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
|
|
3
|
+
import ipyvuetify
|
|
4
|
+
import traitlets
|
|
5
|
+
|
|
6
|
+
import solara
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class MarkdownEditorWidget(ipyvuetify.VuetifyTemplate):
|
|
10
|
+
template_file = (__file__, "markdown_editor.vue")
|
|
11
|
+
|
|
12
|
+
value = traitlets.Unicode("").tag(sync=True)
|
|
13
|
+
height = traitlets.Unicode("180px").tag(sync=True)
|
|
14
|
+
cdn = traitlets.Unicode(None, allow_none=True).tag(sync=True)
|
|
15
|
+
|
|
16
|
+
@traitlets.default("cdn")
|
|
17
|
+
def _cdn(self):
|
|
18
|
+
import solara.settings
|
|
19
|
+
|
|
20
|
+
if not solara.settings.assets.proxy:
|
|
21
|
+
return solara.settings.assets.cdn
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@solara.component
|
|
25
|
+
def MarkdownEditor(value: str = "", on_value: Callable[[str], None] = None):
|
|
26
|
+
"""WYSIWYG (visual) Markdown editor.
|
|
27
|
+
|
|
28
|
+
## Arguments
|
|
29
|
+
|
|
30
|
+
* value: Markdown text
|
|
31
|
+
* on_value: Callback function that is called when the text is changed
|
|
32
|
+
"""
|
|
33
|
+
return MarkdownEditorWidget.element(value=value, on_value=on_value)
|