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,333 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
from typing import Any, Callable, Dict, List, Union
|
|
3
|
+
|
|
4
|
+
import reacton
|
|
5
|
+
import reacton.ipyvuetify as v
|
|
6
|
+
import solara
|
|
7
|
+
import solara.widgets
|
|
8
|
+
from solara.util import _combine_classes
|
|
9
|
+
|
|
10
|
+
Navigator = reacton.core.ComponentWidget(solara.widgets.Navigator)
|
|
11
|
+
GridDraggable = reacton.core.ComponentWidget(solara.widgets.GridLayout)
|
|
12
|
+
# keep the old name for a while
|
|
13
|
+
GridLayout = GridDraggable
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@solara.component
|
|
17
|
+
def ListItem(title, icon_name: str = None, children=[], value=None):
|
|
18
|
+
if value is None:
|
|
19
|
+
value = title
|
|
20
|
+
if children:
|
|
21
|
+
with v.ListItemContent() as main:
|
|
22
|
+
v.ListItemTitle(children=[title])
|
|
23
|
+
if icon_name is not None:
|
|
24
|
+
with v.ListItemIcon():
|
|
25
|
+
v.Icon(children=[icon_name or ""])
|
|
26
|
+
return v.ListGroup(children=children, v_slots=[{"name": "activator", "children": main}], no_action=True, value=True, append_icon=icon_name)
|
|
27
|
+
else:
|
|
28
|
+
with v.ListItem(value=value) as main:
|
|
29
|
+
if icon_name is not None:
|
|
30
|
+
with v.ListItemIcon():
|
|
31
|
+
v.Icon(children=[icon_name or ""])
|
|
32
|
+
with v.ListItemContent():
|
|
33
|
+
v.ListItemTitle(children=[title])
|
|
34
|
+
return main
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def ui_dropdown(label, value=None, options=["foo", "bar"], key=None, disabled=False, **kwargs):
|
|
38
|
+
key = key or str(value) + str(label) + str(options)
|
|
39
|
+
value, set_value = solara.use_state(value, key)
|
|
40
|
+
|
|
41
|
+
def set_index(index):
|
|
42
|
+
set_value(options[index])
|
|
43
|
+
|
|
44
|
+
v.Select(v_model=value, label=label, items=options, on_v_model=set_value, clearable=True, disabled=disabled, **kwargs)
|
|
45
|
+
return value
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def ui_text(label, value="", key=None, clearable=False, hint="", disabled=False, **kwargs):
|
|
49
|
+
key = key or str(value) + str(label) + str(hint)
|
|
50
|
+
value, set_value = solara.use_state(value, key)
|
|
51
|
+
v.TextField(v_model=value, label=label, on_v_model=set_value, clearable=clearable, hint=hint, disabled=disabled, **kwargs)
|
|
52
|
+
return value
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def ui_checkbox(label, value=True, key=None, disabled=False, **kwargs):
|
|
56
|
+
key = key or str(value) + str(label)
|
|
57
|
+
value, set_value = solara.use_state(value, key)
|
|
58
|
+
v.Checkbox(v_model=value, label=label, on_v_model=set_value, **kwargs)
|
|
59
|
+
return value
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def ui_slider(value=1, label="", min=0, max=100, key=None, tick_labels=None, thumb_label=None, disabled=False, **kwargs):
|
|
63
|
+
key = key or str(value) + str(label)
|
|
64
|
+
value, set_value = solara.use_state(value, key)
|
|
65
|
+
v.Slider(
|
|
66
|
+
v_model=value,
|
|
67
|
+
label=label,
|
|
68
|
+
min=min,
|
|
69
|
+
max=max,
|
|
70
|
+
on_v_model=set_value,
|
|
71
|
+
ticks=tick_labels is not None,
|
|
72
|
+
tick_labels=tick_labels,
|
|
73
|
+
thumb_label=thumb_label,
|
|
74
|
+
disabled=disabled,
|
|
75
|
+
**kwargs,
|
|
76
|
+
)
|
|
77
|
+
return value
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@solara.component
|
|
81
|
+
def Text(text, style: Union[str, Dict[str, str], None] = None, classes: List[str] = []):
|
|
82
|
+
style_flat = solara.util._flatten_style(style)
|
|
83
|
+
return v.Html(tag="span", class_=_combine_classes(classes), style_=style_flat, children=[text])
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@solara.component
|
|
87
|
+
def Div(children=[], classes: List[str] = [], style: Union[str, Dict[str, str], None] = None, **kwargs):
|
|
88
|
+
style_flat = solara.util._flatten_style(style)
|
|
89
|
+
classes = classes.copy()
|
|
90
|
+
kwargs = kwargs.copy()
|
|
91
|
+
if "class_" in kwargs:
|
|
92
|
+
classes.append(kwargs.pop("class_"))
|
|
93
|
+
if "style_" in kwargs:
|
|
94
|
+
style_flat += kwargs.pop("style_")
|
|
95
|
+
class_ = _combine_classes(classes)
|
|
96
|
+
|
|
97
|
+
return v.Html(tag="div", children=children, class_=class_, style_=style_flat, **kwargs)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@solara.component
|
|
101
|
+
def Preformatted(text, **kwargs):
|
|
102
|
+
return v.Html(tag="pre", children=[text], **kwargs)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@solara.component
|
|
106
|
+
def IconButton(icon_name: str = None, on_click=Callable[[], None], children: list = [], click_event="click", **kwargs):
|
|
107
|
+
return solara.Button(icon_name=icon_name, on_click=on_click, children=children, icon=True, click_event=click_event, **kwargs)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
@solara.component
|
|
111
|
+
def HTML(tag="div", unsafe_innerHTML=None, style: str = None, classes: List[str] = [], attributes=None, class_: str = None):
|
|
112
|
+
"""Render an HTML tag with optional raw HTML text inside.
|
|
113
|
+
|
|
114
|
+
# Arguments
|
|
115
|
+
|
|
116
|
+
* `tag`: HTML tag name for the top level element (default: `div`)
|
|
117
|
+
* `unsafe_innerHTML`: HTML string to be rendered inside the tag.
|
|
118
|
+
Note that this is not sanitized, so be careful this cannot include JavaScript from user input!
|
|
119
|
+
* `style`: CSS style string to be applied to the top level element.
|
|
120
|
+
* `classes`: List of CSS classes to be applied to the top level element.
|
|
121
|
+
* `attributes`: Dictionary of attributes to be applied to the top level element.
|
|
122
|
+
* `class_`: (deprecated) CSS class to be applied to the top level element.
|
|
123
|
+
|
|
124
|
+
"""
|
|
125
|
+
if attributes is None:
|
|
126
|
+
attributes = {}
|
|
127
|
+
else:
|
|
128
|
+
attributes = attributes.copy()
|
|
129
|
+
if style:
|
|
130
|
+
attributes["style"] = style
|
|
131
|
+
if class_ or classes:
|
|
132
|
+
class_ = _combine_classes([*classes, *([] if class_ is None else [class_])])
|
|
133
|
+
attributes["class"] = class_
|
|
134
|
+
return solara.widgets.HTML.element(tag=tag, unsafe_innerHTML=unsafe_innerHTML, attributes=attributes)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@solara.component
|
|
138
|
+
def VBox(children=[], grow=True, align_items="stretch", classes: List[str] = []):
|
|
139
|
+
"""Deprecated. Use `Column` instead."""
|
|
140
|
+
style = f"flex-direction: column; align-items: {align_items};"
|
|
141
|
+
if grow:
|
|
142
|
+
style += "flex-grow: 1;"
|
|
143
|
+
class_ = _combine_classes(["d-flex", *classes])
|
|
144
|
+
return v.Sheet(class_=class_, style_=style, elevation=0, children=children)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
@solara.component
|
|
148
|
+
def HBox(children=[], grow=True, align_items="stretch", classes: List[str] = []):
|
|
149
|
+
"""Deprecated. Use `Row` instead."""
|
|
150
|
+
style = f"flex-direction: row; align-items: {align_items}; "
|
|
151
|
+
if grow:
|
|
152
|
+
style += "flex-grow: 1;"
|
|
153
|
+
class_ = _combine_classes(["d-flex", *classes])
|
|
154
|
+
return v.Sheet(class_=class_, style_=style, elevation=0, children=children)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
@solara.component
|
|
158
|
+
def Row(children=[], gap="12px", justify="start", margin: int = 0, classes: List[str] = [], style: Union[str, Dict[str, str], None] = None):
|
|
159
|
+
"""Lays out children in a row, side by side, with the given gap between them.
|
|
160
|
+
|
|
161
|
+
See also [Column](/documentation/components/layout/column).
|
|
162
|
+
|
|
163
|
+
Example with three children side by side:
|
|
164
|
+
|
|
165
|
+
```solara
|
|
166
|
+
import solara
|
|
167
|
+
|
|
168
|
+
@solara.component
|
|
169
|
+
def Page():
|
|
170
|
+
with solara.Row(gap="10px", justify="space-around"):
|
|
171
|
+
solara.Text("On the left")
|
|
172
|
+
solara.Text("In the middle")
|
|
173
|
+
solara.Text("On the right")
|
|
174
|
+
```
|
|
175
|
+
## Arguments
|
|
176
|
+
|
|
177
|
+
* `children`: List of children to render in the column.
|
|
178
|
+
* `gap`: The gap between each child, as a CSS string.
|
|
179
|
+
* `justify`: How children are distributed along the x/horizontal-axis, can be "start" (default), "center", "end", "space-around",
|
|
180
|
+
"space-between" or "space-evenly".
|
|
181
|
+
(*Note: this translates to justify-content in CSS*).
|
|
182
|
+
* `margin`: The margin around the column, translate to 4*margin pixels.
|
|
183
|
+
* `classes`: List of CSS classes to apply to the column.
|
|
184
|
+
* `style`: CSS style to apply to the column.
|
|
185
|
+
|
|
186
|
+
"""
|
|
187
|
+
align_items = "stretch"
|
|
188
|
+
style_flat = solara.util._flatten_style(style)
|
|
189
|
+
style_flat = f"flex-direction: row; align-items: {align_items}; justify-content: {justify}; column-gap: {gap};" + style_flat + ";"
|
|
190
|
+
# valid css values, but we don't list them as options to avoid confusion
|
|
191
|
+
extra_justify_options = ["left", "right", "flex-start", "flex-end"]
|
|
192
|
+
if justify not in (["start", "center", "end", "space-around", "space-between", "space-evenly"] + extra_justify_options):
|
|
193
|
+
warnings.warn(f"Invalid value for justify: {justify}, possible values are: start, center, end, space-around, space-between, space-evenly")
|
|
194
|
+
class_ = _combine_classes(["d-flex", f"ma-{margin}", *classes])
|
|
195
|
+
return v.Sheet(class_=class_, style_=style_flat, elevation=0, children=children)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@solara.component
|
|
199
|
+
def Column(children=[], gap="12px", align="stretch", margin: int = 0, classes: List[str] = [], style: Union[str, Dict[str, str], None] = None):
|
|
200
|
+
"""Lays out children in a column on top of each other, with the given gap between them.
|
|
201
|
+
|
|
202
|
+
See also [Row](/documentation/components/layout/row).
|
|
203
|
+
|
|
204
|
+
Example with three children on top of each other:
|
|
205
|
+
|
|
206
|
+
```solara
|
|
207
|
+
import solara
|
|
208
|
+
|
|
209
|
+
@solara.component
|
|
210
|
+
def Page():
|
|
211
|
+
with solara.Column(gap="10px"):
|
|
212
|
+
solara.Text("On top")
|
|
213
|
+
solara.Text("In the middle")
|
|
214
|
+
solara.Text("On bottom")
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Arguments
|
|
218
|
+
|
|
219
|
+
* `children`: List of children to render in the column.
|
|
220
|
+
* `gap`: The gap between each child, as a CSS string.
|
|
221
|
+
* `align`: The alignment of the children, can be "start", "center", "end", "stretch" (default).
|
|
222
|
+
(*Note: this translates to align-items in CSS*).
|
|
223
|
+
* `margin`: The margin around the column, translate to 4*margin pixels.
|
|
224
|
+
* `classes`: List of CSS classes to apply to the column.
|
|
225
|
+
* `style`: CSS style to apply to the column.
|
|
226
|
+
|
|
227
|
+
"""
|
|
228
|
+
if align == "left":
|
|
229
|
+
warnings.warn("align='left' does not exists, you probably want align='start' instead")
|
|
230
|
+
align = "start"
|
|
231
|
+
if align == "right":
|
|
232
|
+
warnings.warn("align='right' does not exists, you probably want align='end' instead")
|
|
233
|
+
align = "end"
|
|
234
|
+
# valid css options, but we don't list them as options to avoid confusion
|
|
235
|
+
extra_align_options = ["flex-start", "flex-end", "self-start", "self-end", "baseline"]
|
|
236
|
+
if align not in (["start", "center", "end", "stretch"] + extra_align_options):
|
|
237
|
+
warnings.warn(f"Invalid value for align: {align}, possible values are 'start', 'center', 'end' or 'stretch'")
|
|
238
|
+
style_flat = solara.util._flatten_style(style)
|
|
239
|
+
style_flat = f"flex-direction: column; align-items: {align}; row-gap: {gap};" + style_flat + ";"
|
|
240
|
+
class_ = _combine_classes(["d-flex", f"ma-{margin}", *classes])
|
|
241
|
+
return v.Sheet(class_=class_, style_=style_flat, elevation=0, children=children)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
@solara.component
|
|
245
|
+
def GridFixed(columns=4, column_gap="10px", row_gap="10px", children=[], align_items="stretch", justify_items="stretch"):
|
|
246
|
+
"""
|
|
247
|
+
|
|
248
|
+
See css grid spec:
|
|
249
|
+
https://css-tricks.com/snippets/css/complete-guide-grid/
|
|
250
|
+
"""
|
|
251
|
+
style = (
|
|
252
|
+
f"display: grid; grid-template-columns: repeat({columns}, minmax(0, 1fr)); "
|
|
253
|
+
+ f"grid-column-gap: {column_gap}; grid-row-gap: {row_gap}; align-items: {align_items}; justify-items: {justify_items}"
|
|
254
|
+
)
|
|
255
|
+
return Div(style_=style, children=children)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
@solara.component
|
|
259
|
+
def Padding(size, children=[], grow=True):
|
|
260
|
+
style = "flex-direction: row;"
|
|
261
|
+
if grow:
|
|
262
|
+
style += "flex-grow: 1;"
|
|
263
|
+
return v.Sheet(class_=f"pa-{size}", style_=style, elevation=0, children=children)
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
@solara.component
|
|
267
|
+
def FigurePlotly(
|
|
268
|
+
fig,
|
|
269
|
+
on_selection: Callable[[Any], None] = None,
|
|
270
|
+
on_deselect: Callable[[Any], None] = None,
|
|
271
|
+
on_click: Callable[[Any], None] = None,
|
|
272
|
+
on_hover: Callable[[Any], None] = None,
|
|
273
|
+
on_unhover: Callable[[Any], None] = None,
|
|
274
|
+
on_relayout: Callable[[Any], None] = None,
|
|
275
|
+
dependencies=None,
|
|
276
|
+
):
|
|
277
|
+
from plotly.graph_objs._figurewidget import FigureWidget
|
|
278
|
+
|
|
279
|
+
def on_points_callback(data):
|
|
280
|
+
if not data:
|
|
281
|
+
return
|
|
282
|
+
|
|
283
|
+
event_type = data["event_type"]
|
|
284
|
+
event_mapping = {
|
|
285
|
+
"plotly_click": on_click,
|
|
286
|
+
"plotly_hover": on_hover,
|
|
287
|
+
"plotly_unhover": on_unhover,
|
|
288
|
+
"plotly_selected": on_selection,
|
|
289
|
+
"plotly_deselect": on_deselect,
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
callback = event_mapping.get(event_type)
|
|
293
|
+
if callback:
|
|
294
|
+
callback(data)
|
|
295
|
+
|
|
296
|
+
fig_element = FigureWidget.element(on__js2py_pointsCallback=on_points_callback, on__js2py_relayout=on_relayout)
|
|
297
|
+
|
|
298
|
+
def update_data():
|
|
299
|
+
fig_widget: FigureWidget = solara.get_widget(fig_element)
|
|
300
|
+
fig_widget.layout = fig.layout
|
|
301
|
+
|
|
302
|
+
length = len(fig_widget.data)
|
|
303
|
+
fig_widget.add_traces(fig.data)
|
|
304
|
+
data = list(fig_widget.data)
|
|
305
|
+
fig_widget.data = data[length:]
|
|
306
|
+
|
|
307
|
+
solara.use_effect(update_data, dependencies or fig)
|
|
308
|
+
return fig_element
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
@solara.component
|
|
312
|
+
def Code(path, path_header=None):
|
|
313
|
+
path_header = path_header or path
|
|
314
|
+
with open(path) as f:
|
|
315
|
+
code = f.read()
|
|
316
|
+
md = solara.Markdown(
|
|
317
|
+
f"""
|
|
318
|
+
### {path_header}
|
|
319
|
+
|
|
320
|
+
```python
|
|
321
|
+
{code}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
"""
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
with v.ExpansionPanels() as main:
|
|
328
|
+
with v.ExpansionPanel():
|
|
329
|
+
with v.ExpansionPanelHeader(children=["View source"]):
|
|
330
|
+
pass
|
|
331
|
+
with v.ExpansionPanelContent(children=[md]):
|
|
332
|
+
pass
|
|
333
|
+
return main
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import operator
|
|
2
|
+
import os
|
|
3
|
+
from functools import reduce
|
|
4
|
+
from typing import Any, Callable, Dict, List, NoReturn
|
|
5
|
+
|
|
6
|
+
import ipyvuetify as v
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
import numpy as np
|
|
10
|
+
except ModuleNotFoundError:
|
|
11
|
+
np = None # type: ignore
|
|
12
|
+
import traitlets
|
|
13
|
+
|
|
14
|
+
import solara
|
|
15
|
+
from solara.alias import rv
|
|
16
|
+
from solara.lab.hooks.dataframe import use_df_column_names
|
|
17
|
+
|
|
18
|
+
cardheight = "100%"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class PivotTableWidget(v.VuetifyTemplate):
|
|
22
|
+
template_file = os.path.realpath(os.path.join(os.path.dirname(__file__), "pivot_table.vue"))
|
|
23
|
+
d = traitlets.Dict(default_value={"no": "data"}).tag(sync=True)
|
|
24
|
+
selected = traitlets.Dict(default_value={}).tag(sync=True)
|
|
25
|
+
style_ = traitlets.Unicode("").tag(sync=True)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def assert_never(value) -> NoReturn:
|
|
29
|
+
# This also works at runtime as well
|
|
30
|
+
assert False, f"This code should never be reached, got: {value}"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def translate_agg_to_vaex(aggregation: solara.Aggregation, filter=None):
|
|
34
|
+
if aggregation["type"] == "count":
|
|
35
|
+
import vaex
|
|
36
|
+
|
|
37
|
+
return vaex.agg.count(selection=filter) if filter else vaex.agg.count()
|
|
38
|
+
assert_never(aggregation)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def df_aggregate_vaex(df, columns: List[str], aggregations: Dict[str, solara.Aggregation], filter=None):
|
|
42
|
+
aggs = {key: translate_agg_to_vaex(agg, filter) for key, agg in aggregations.items()}
|
|
43
|
+
return df.groupby(columns, sort=True).agg(aggs)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def df_aggregate_pivot_vaex(df, x: List[str], y: List[str], aggregation: solara.Aggregation, filter=None) -> solara.PivotTableData:
|
|
47
|
+
agg_name = aggregation["type"]
|
|
48
|
+
|
|
49
|
+
columns = [*x, *y]
|
|
50
|
+
agg_column = "agg_count__"
|
|
51
|
+
row_index = "__row_index__"
|
|
52
|
+
|
|
53
|
+
aggregations = {agg_column: aggregation}
|
|
54
|
+
if x and y:
|
|
55
|
+
dfg = df_aggregate_vaex(df, columns, aggregations, filter=filter)
|
|
56
|
+
else:
|
|
57
|
+
dfg = None
|
|
58
|
+
if x:
|
|
59
|
+
dfgx = df_aggregate_vaex(df, x, aggregations, filter=filter)
|
|
60
|
+
dfgx[row_index] = np.arange(len(dfgx), dtype="int64")
|
|
61
|
+
else:
|
|
62
|
+
dfgx = None
|
|
63
|
+
if y:
|
|
64
|
+
dfgy = df_aggregate_vaex(df, y, aggregations, filter=filter)
|
|
65
|
+
dfgy[row_index] = np.arange(len(dfgy), dtype="int64")
|
|
66
|
+
else:
|
|
67
|
+
dfgy = None
|
|
68
|
+
dfg_total = df._agg(translate_agg_to_vaex(aggregations[agg_column], filter=filter))
|
|
69
|
+
|
|
70
|
+
def formatter(value):
|
|
71
|
+
if isinstance(value, float):
|
|
72
|
+
return f"{value:,.2f}"
|
|
73
|
+
else:
|
|
74
|
+
return f"{value:,d}"
|
|
75
|
+
|
|
76
|
+
if x and y:
|
|
77
|
+
values: List[List[solara.JsonType]] = [[None] * len(dfgy) for _ in range(len(dfgx))]
|
|
78
|
+
else:
|
|
79
|
+
values = [[]]
|
|
80
|
+
if x:
|
|
81
|
+
values_x = list(map(formatter, dfgx[agg_column].tolist()))
|
|
82
|
+
headers_x = [dfgx[k].tolist() for k in x]
|
|
83
|
+
counts_x = len(dfgx)
|
|
84
|
+
else:
|
|
85
|
+
values_x = []
|
|
86
|
+
headers_x = []
|
|
87
|
+
counts_x = 0
|
|
88
|
+
if y:
|
|
89
|
+
values_y = list(map(formatter, dfgy[agg_column].tolist()))
|
|
90
|
+
headers_y = [dfgy[k].tolist() for k in y]
|
|
91
|
+
counts_y = len(dfgy)
|
|
92
|
+
else:
|
|
93
|
+
values_y = []
|
|
94
|
+
headers_y = []
|
|
95
|
+
counts_y = 0
|
|
96
|
+
total = formatter(dfg_total)
|
|
97
|
+
|
|
98
|
+
if x and y:
|
|
99
|
+
for row in dfg.to_records():
|
|
100
|
+
dfs = {"x": dfgx, "y": dfgy}
|
|
101
|
+
for column in columns:
|
|
102
|
+
axis_name = "x" if column in x else "y"
|
|
103
|
+
df_axis = dfs[axis_name]
|
|
104
|
+
if row[column] is None:
|
|
105
|
+
df_axis = df_axis[df[column].ismissing()]
|
|
106
|
+
else:
|
|
107
|
+
df_axis = df_axis[df_axis[column] == row[column]]
|
|
108
|
+
dfs[axis_name] = df_axis
|
|
109
|
+
assert len(dfs["x"])
|
|
110
|
+
assert len(dfs["y"])
|
|
111
|
+
xi = dfs["x"][row_index].tolist()[0]
|
|
112
|
+
yi = dfs["y"][row_index].tolist()[0]
|
|
113
|
+
value = row[agg_column]
|
|
114
|
+
values[xi][yi] = formatter(value)
|
|
115
|
+
|
|
116
|
+
data: solara.PivotTableData = {
|
|
117
|
+
"x": x,
|
|
118
|
+
"y": y,
|
|
119
|
+
"agg": agg_name,
|
|
120
|
+
"values": values,
|
|
121
|
+
"values_x": values_x,
|
|
122
|
+
"values_y": values_y,
|
|
123
|
+
"headers_x": headers_x,
|
|
124
|
+
"headers_y": headers_y,
|
|
125
|
+
"counts_x": counts_x,
|
|
126
|
+
"counts_y": counts_y,
|
|
127
|
+
"total": total,
|
|
128
|
+
}
|
|
129
|
+
return data
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def use_df_pivot_data(df, x: List[str], y: List[str], aggregation: solara.Aggregation, filter=None) -> solara.Result[solara.PivotTableData]:
|
|
133
|
+
return solara.use_thread(lambda: df_aggregate_pivot_vaex(df, x, y, aggregation, filter=filter), dependencies=[*x, *y, aggregation, filter])
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@solara.component
|
|
137
|
+
def PivotTableView(data: solara.PivotTableData, selected: Dict[str, Any] = {}, on_selected: Callable[[Dict[str, Any]], None] = None, style=""):
|
|
138
|
+
return PivotTableWidget.element(d=data, selected=selected, on_selected=on_selected, style_=style)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
@solara.component
|
|
142
|
+
def PivotTable(
|
|
143
|
+
df,
|
|
144
|
+
x: List[str] = [],
|
|
145
|
+
y: List[str] = [],
|
|
146
|
+
aggregation: solara.Aggregation = solara.AggregationCount(type="count"),
|
|
147
|
+
selected: Dict[str, Any] = {},
|
|
148
|
+
on_selected: Callable[[Dict[str, Any]], None] = None,
|
|
149
|
+
):
|
|
150
|
+
x = x.copy()
|
|
151
|
+
y = y.copy()
|
|
152
|
+
filter, set_filter = solara.use_cross_filter(id(df), "pivottable")
|
|
153
|
+
dff = df
|
|
154
|
+
data_result = use_df_pivot_data(dff, x, y, aggregation, filter=filter)
|
|
155
|
+
previous = solara.use_previous(data_result.value, condition=data_result.state == solara.ResultState.FINISHED)
|
|
156
|
+
selected, set_selected = solara.use_state_or_update(selected.copy())
|
|
157
|
+
|
|
158
|
+
def set_filter_from_pivot_selection(selection):
|
|
159
|
+
set_selected(selection)
|
|
160
|
+
if on_selected:
|
|
161
|
+
on_selected(selection)
|
|
162
|
+
data = data_result.value
|
|
163
|
+
if data is None:
|
|
164
|
+
return
|
|
165
|
+
# assert data is not None
|
|
166
|
+
filters = []
|
|
167
|
+
if "x" in selection:
|
|
168
|
+
sel = selection["x"]
|
|
169
|
+
for level in range(sel[0] + 1):
|
|
170
|
+
value = data["headers_x"][level][sel[1]]
|
|
171
|
+
column = data["x"][level]
|
|
172
|
+
if value is None:
|
|
173
|
+
filters.append(df[column].ismissing())
|
|
174
|
+
else:
|
|
175
|
+
filters.append(df[column] == value)
|
|
176
|
+
|
|
177
|
+
if "y" in selection:
|
|
178
|
+
sel = selection["y"]
|
|
179
|
+
for level in range(sel[0] + 1):
|
|
180
|
+
column = data["y"][level]
|
|
181
|
+
value = data["headers_y"][level][sel[1]]
|
|
182
|
+
if value is None:
|
|
183
|
+
filters.append(df[column].ismissing())
|
|
184
|
+
else:
|
|
185
|
+
filters.append(df[column] == value)
|
|
186
|
+
if filters:
|
|
187
|
+
filter = reduce(operator.and_, filters[1:], filters[0])
|
|
188
|
+
else:
|
|
189
|
+
filter = None
|
|
190
|
+
set_filter(filter if filter is not None else None)
|
|
191
|
+
|
|
192
|
+
# Bug in use_thread on state result we remember that state is finished
|
|
193
|
+
if data_result.state == solara.ResultState.FINISHED and data_result.value is not None:
|
|
194
|
+
with solara.VBox() as main:
|
|
195
|
+
rv.ProgressLinear(indeterminate=False, style_="visibility: hidden;")
|
|
196
|
+
PivotTableView(data=data_result.value, selected=selected, on_selected=set_filter_from_pivot_selection)
|
|
197
|
+
elif previous is not None:
|
|
198
|
+
with solara.VBox() as main:
|
|
199
|
+
rv.ProgressLinear(indeterminate=True)
|
|
200
|
+
PivotTableView(data=previous, selected=selected, on_selected=set_filter_from_pivot_selection, style="opacity: 0.3; pointer-events: none;")
|
|
201
|
+
elif data_result.state == solara.ResultState.ERROR:
|
|
202
|
+
return solara.Error(f"Oops: {data_result.error}")
|
|
203
|
+
else:
|
|
204
|
+
return solara.Info(f"Status: {data_result.state}")
|
|
205
|
+
return main
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
@solara.component
|
|
209
|
+
def PivotTableCard(
|
|
210
|
+
df,
|
|
211
|
+
x=[],
|
|
212
|
+
y=[],
|
|
213
|
+
selected: Dict[str, Any] = {},
|
|
214
|
+
on_selected: Callable[[Dict[str, Any]], None] = None,
|
|
215
|
+
):
|
|
216
|
+
items = use_df_column_names(df)
|
|
217
|
+
with rv.Card(elevation=2, style_="position: relative", height=cardheight) as main:
|
|
218
|
+
with rv.CardTitle(children=["Pivot table"]):
|
|
219
|
+
pass
|
|
220
|
+
with rv.CardText():
|
|
221
|
+
with rv.Btn(v_on="x.on", icon=True, absolute=True, style_="right: 10px; top: 10px") as btn:
|
|
222
|
+
rv.Icon(children=["mdi-settings"])
|
|
223
|
+
with rv.Dialog(v_slots=[{"name": "activator", "variable": "x", "children": btn}]):
|
|
224
|
+
with rv.Sheet():
|
|
225
|
+
with rv.Container(pa_4=True, ma_0=True):
|
|
226
|
+
with rv.Row():
|
|
227
|
+
with rv.Col():
|
|
228
|
+
with rv.Card(elevation=2):
|
|
229
|
+
with rv.CardTitle(children=["Rows"]):
|
|
230
|
+
pass
|
|
231
|
+
with rv.CardText():
|
|
232
|
+
for i in range(10):
|
|
233
|
+
col = solara.ui_dropdown(value=x[i] if i < len(x) else None, label=f"Row {i}", options=items)
|
|
234
|
+
if col is None:
|
|
235
|
+
break
|
|
236
|
+
else:
|
|
237
|
+
if i < len(x):
|
|
238
|
+
x[i] = col
|
|
239
|
+
else:
|
|
240
|
+
x.append(col)
|
|
241
|
+
with rv.Col():
|
|
242
|
+
with rv.Card(elevation=2):
|
|
243
|
+
with rv.CardTitle(children=["Columns"]):
|
|
244
|
+
pass
|
|
245
|
+
with rv.CardText():
|
|
246
|
+
for i in range(10):
|
|
247
|
+
col = solara.ui_dropdown(value=y[i] if i < len(y) else None, label=f"Column {i}", options=items)
|
|
248
|
+
if col is None:
|
|
249
|
+
break
|
|
250
|
+
else:
|
|
251
|
+
if i < len(y):
|
|
252
|
+
y[i] = col
|
|
253
|
+
else:
|
|
254
|
+
y.append(col)
|
|
255
|
+
|
|
256
|
+
PivotTable(df, x, y, selected=selected, on_selected=on_selected)
|
|
257
|
+
|
|
258
|
+
return main
|