streamlit-nightly 1.35.1.dev20240613__py2.py3-none-any.whl → 1.35.1.dev20240614__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/__init__.py +1 -1
- streamlit/commands/navigation.py +84 -18
- streamlit/components/v1/component_registry.py +24 -9
- streamlit/elements/arrow.py +17 -6
- streamlit/elements/deck_gl_json_chart.py +1 -1
- streamlit/elements/dialog_decorator.py +5 -3
- streamlit/elements/html.py +1 -9
- streamlit/elements/iframe.py +53 -10
- streamlit/elements/layouts.py +40 -4
- streamlit/elements/lib/column_types.py +1 -1
- streamlit/elements/map.py +1 -1
- streamlit/elements/markdown.py +18 -14
- streamlit/elements/plotly_chart.py +5 -2
- streamlit/elements/toast.py +1 -1
- streamlit/elements/vega_charts.py +93 -41
- streamlit/elements/widgets/button.py +6 -3
- streamlit/elements/widgets/data_editor.py +1 -1
- streamlit/elements/widgets/file_uploader.py +1 -1
- streamlit/elements/write.py +11 -10
- streamlit/hello/Mapping_Demo.py +1 -1
- streamlit/navigation/page.py +107 -19
- streamlit/runtime/caching/cache_data_api.py +5 -4
- streamlit/runtime/caching/cache_errors.py +1 -1
- streamlit/runtime/caching/cache_resource_api.py +5 -4
- streamlit/runtime/caching/legacy_cache_api.py +13 -12
- streamlit/runtime/fragment.py +57 -27
- streamlit/runtime/runtime_util.py +1 -1
- streamlit/runtime/scriptrunner/script_run_context.py +1 -1
- streamlit/runtime/secrets.py +2 -2
- streamlit/runtime/state/session_state.py +1 -1
- streamlit/runtime/state/session_state_proxy.py +1 -1
- streamlit/static/asset-manifest.json +4 -4
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{8427.59805a7f.chunk.js → 8427.5192ee0c.chunk.js} +1 -1
- streamlit/static/static/js/8536.f7b26b02.chunk.js +1 -0
- streamlit/static/static/js/{main.d4bbfd37.js → main.7994a814.js} +2 -2
- streamlit/testing/v1/app_test.py +4 -3
- streamlit/user_info.py +2 -4
- {streamlit_nightly-1.35.1.dev20240613.dist-info → streamlit_nightly-1.35.1.dev20240614.dist-info}/METADATA +9 -9
- {streamlit_nightly-1.35.1.dev20240613.dist-info → streamlit_nightly-1.35.1.dev20240614.dist-info}/RECORD +45 -45
- streamlit/static/static/js/8536.f8de3d9a.chunk.js +0 -1
- /streamlit/static/static/js/{main.d4bbfd37.js.LICENSE.txt → main.7994a814.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.35.1.dev20240613.data → streamlit_nightly-1.35.1.dev20240614.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.35.1.dev20240613.dist-info → streamlit_nightly-1.35.1.dev20240614.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.35.1.dev20240613.dist-info → streamlit_nightly-1.35.1.dev20240614.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.35.1.dev20240613.dist-info → streamlit_nightly-1.35.1.dev20240614.dist-info}/top_level.txt +0 -0
streamlit/runtime/fragment.py
CHANGED
@@ -227,34 +227,42 @@ def fragment(
|
|
227
227
|
run_every: int | float | timedelta | str | None = None,
|
228
228
|
) -> Callable[[F], F] | F:
|
229
229
|
"""Decorator to turn a function into a fragment which can rerun independently\
|
230
|
-
of the full
|
230
|
+
of the full app.
|
231
231
|
|
232
|
-
When a user interacts with an input widget created
|
233
|
-
only reruns the fragment instead of the full
|
234
|
-
Streamlit will also rerun the fragment at the
|
235
|
-
session is active, even if the user is not
|
232
|
+
When a user interacts with an input widget created inside a fragment,
|
233
|
+
Streamlit only reruns the fragment instead of the full app. If
|
234
|
+
``run_every`` is set, Streamlit will also rerun the fragment at the
|
235
|
+
specified interval while the session is active, even if the user is not
|
236
|
+
interacting with your app.
|
236
237
|
|
237
|
-
To trigger
|
238
|
+
To trigger an app rerun from inside a fragment, call ``st.rerun()``
|
238
239
|
directly. Any values from the fragment that need to be accessed from
|
239
240
|
the wider app should generally be stored in Session State.
|
240
241
|
|
241
242
|
When Streamlit element commands are called directly in a fragment, the
|
242
243
|
elements are cleared and redrawn on each fragment rerun, just like all
|
243
|
-
elements are redrawn on each
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
244
|
+
elements are redrawn on each app rerun. The rest of the app is persisted
|
245
|
+
during a fragment rerun. When a fragment renders elements into externally
|
246
|
+
created containers, the elements will not be cleared with each fragment
|
247
|
+
rerun. Instead, elements will accumulate in those containers with each
|
248
|
+
fragment rerun, until the next app rerun.
|
248
249
|
|
249
|
-
Calling
|
250
|
+
Calling ``st.sidebar`` in a fragment is not supported. To write elements to
|
250
251
|
the sidebar with a fragment, call your fragment function inside a
|
251
|
-
|
252
|
+
``with st.sidebar`` context manager.
|
252
253
|
|
253
254
|
Fragment code can interact with Session State, imported modules, and
|
254
255
|
other Streamlit elements created outside the fragment. Note that these
|
255
256
|
interactions are additive across multiple fragment reruns. You are
|
256
257
|
responsible for handling any side effects of that behavior.
|
257
258
|
|
259
|
+
.. warning::
|
260
|
+
- Fragments can't contain other fragments. Additionally, using
|
261
|
+
fragments in widget callback functions is not supported.
|
262
|
+
|
263
|
+
- Fragments can only contain widgets in their main body. Fragments
|
264
|
+
can't render widgets to externally created containers.
|
265
|
+
|
258
266
|
Parameters
|
259
267
|
----------
|
260
268
|
func: callable
|
@@ -278,18 +286,40 @@ def fragment(
|
|
278
286
|
|
279
287
|
Examples
|
280
288
|
--------
|
281
|
-
The following example demonstrates basic usage of
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
289
|
+
The following example demonstrates basic usage of
|
290
|
+
``@st.experimental_fragment``. As an anology, "inflating balloons" is a
|
291
|
+
slow process that happens outside of the fragment. "Releasing balloons" is
|
292
|
+
a quick process that happens inside of the fragment.
|
293
|
+
|
294
|
+
>>> import streamlit as st
|
295
|
+
>>> import time
|
296
|
+
>>>
|
297
|
+
>>> @st.experimental_fragment
|
298
|
+
>>> def release_the_balloons():
|
299
|
+
>>> st.button("Release the balloons", help="Fragment rerun")
|
300
|
+
>>> st.balloons()
|
301
|
+
>>>
|
302
|
+
>>> with st.spinner("Inflating balloons..."):
|
303
|
+
>>> time.sleep(5)
|
304
|
+
>>> release_the_balloons()
|
305
|
+
>>> st.button("Inflate more balloons", help="Full rerun")
|
306
|
+
|
307
|
+
.. output::
|
308
|
+
https://doc-fragment-balloons.streamlit.app/
|
309
|
+
height: 220px
|
310
|
+
|
311
|
+
This next example demonstrates how elements both inside and outside of a
|
312
|
+
fragement update with each app or fragment rerun. In this app, clicking
|
313
|
+
"Rerun full app" will increment both counters and update all values
|
314
|
+
displayed in the app. In contrast, clicking "Rerun fragment" will only
|
315
|
+
increment the counter within the fragment. In this case, the ``st.write``
|
316
|
+
command inside the fragment will update the app's frontend, but the two
|
317
|
+
``st.write`` commands outside the fragment will not update the frontend.
|
288
318
|
|
289
319
|
>>> import streamlit as st
|
290
320
|
>>>
|
291
|
-
>>> if "
|
292
|
-
>>> st.session_state.
|
321
|
+
>>> if "app_runs" not in st.session_state:
|
322
|
+
>>> st.session_state.app_runs = 0
|
293
323
|
>>> st.session_state.fragment_runs = 0
|
294
324
|
>>>
|
295
325
|
>>> @st.experimental_fragment
|
@@ -298,17 +328,17 @@ def fragment(
|
|
298
328
|
>>> st.button("Rerun fragment")
|
299
329
|
>>> st.write(f"Fragment says it ran {st.session_state.fragment_runs} times.")
|
300
330
|
>>>
|
301
|
-
>>> st.session_state.
|
331
|
+
>>> st.session_state.app_runs += 1
|
302
332
|
>>> fragment()
|
303
|
-
>>> st.button("Rerun full
|
304
|
-
>>> st.write(f"Full
|
305
|
-
>>> st.write(f"Full
|
333
|
+
>>> st.button("Rerun full app")
|
334
|
+
>>> st.write(f"Full app says it ran {st.session_state.app_runs} times.")
|
335
|
+
>>> st.write(f"Full app sees that fragment ran {st.session_state.fragment_runs} times.")
|
306
336
|
|
307
337
|
.. output::
|
308
338
|
https://doc-fragment.streamlit.app/
|
309
339
|
height: 400px
|
310
340
|
|
311
|
-
You can also trigger
|
341
|
+
You can also trigger an app rerun from inside a fragment by calling
|
312
342
|
``st.rerun``.
|
313
343
|
|
314
344
|
>>> import streamlit as st
|
@@ -41,7 +41,7 @@ class MessageSizeError(MarkdownFormattedException):
|
|
41
41
|
|
42
42
|
This is often caused by a large chart or dataframe. Please decrease the amount of data sent
|
43
43
|
to the browser, or increase the limit by setting the config option `server.maxMessageSize`.
|
44
|
-
[Click here to learn more about config options](https://docs.streamlit.io/
|
44
|
+
[Click here to learn more about config options](https://docs.streamlit.io/develop/api-reference/configuration/config.toml).
|
45
45
|
|
46
46
|
_Note that increasing the limit may lead to long loading times and large memory consumption
|
47
47
|
of the client's browser and the Streamlit server._
|
@@ -141,7 +141,7 @@ class ScriptRunContext:
|
|
141
141
|
"`set_page_config()` can only be called once per app page, "
|
142
142
|
"and must be called as the first Streamlit command in your script.\n\n"
|
143
143
|
"For more information refer to the [docs]"
|
144
|
-
"(https://docs.streamlit.io/
|
144
|
+
"(https://docs.streamlit.io/develop/api-reference/configuration/st.set_page_config)."
|
145
145
|
)
|
146
146
|
|
147
147
|
# We want to disallow set_page config if one of the following occurs:
|
streamlit/runtime/secrets.py
CHANGED
@@ -55,7 +55,7 @@ def _missing_attr_error_message(attr_name: str) -> str:
|
|
55
55
|
return (
|
56
56
|
f'st.secrets has no attribute "{attr_name}". '
|
57
57
|
f"Did you forget to add it to secrets.toml or the app settings on Streamlit Cloud? "
|
58
|
-
f"More info: https://docs.streamlit.io/streamlit-cloud/
|
58
|
+
f"More info: https://docs.streamlit.io/deploy/streamlit-community-cloud/deploy-your-app/secrets-management"
|
59
59
|
)
|
60
60
|
|
61
61
|
|
@@ -63,7 +63,7 @@ def _missing_key_error_message(key: str) -> str:
|
|
63
63
|
return (
|
64
64
|
f'st.secrets has no key "{key}". '
|
65
65
|
f"Did you forget to add it to secrets.toml or the app settings on Streamlit Cloud? "
|
66
|
-
f"More info: https://docs.streamlit.io/streamlit-cloud/
|
66
|
+
f"More info: https://docs.streamlit.io/deploy/streamlit-community-cloud/deploy-your-app/secrets-management"
|
67
67
|
)
|
68
68
|
|
69
69
|
|
@@ -274,7 +274,7 @@ class WStates(MutableMapping[str, Any]):
|
|
274
274
|
def _missing_key_error_message(key: str) -> str:
|
275
275
|
return (
|
276
276
|
f'st.session_state has no key "{key}". Did you forget to initialize it? '
|
277
|
-
f"More info: https://docs.streamlit.io/
|
277
|
+
f"More info: https://docs.streamlit.io/develop/concepts/architecture/session-state#initialization"
|
278
278
|
)
|
279
279
|
|
280
280
|
|
@@ -146,5 +146,5 @@ class SessionStateProxy(MutableMapping[Key, Any]):
|
|
146
146
|
def _missing_attr_error_message(attr_name: str) -> str:
|
147
147
|
return (
|
148
148
|
f'st.session_state has no attribute "{attr_name}". Did you forget to initialize it? '
|
149
|
-
f"More info: https://docs.streamlit.io/
|
149
|
+
f"More info: https://docs.streamlit.io/develop/concepts/architecture/session-state#initialization"
|
150
150
|
)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"files": {
|
3
3
|
"main.css": "./static/css/main.3aaaea00.css",
|
4
|
-
"main.js": "./static/js/main.
|
4
|
+
"main.js": "./static/js/main.7994a814.js",
|
5
5
|
"static/js/9336.3e046ad7.chunk.js": "./static/js/9336.3e046ad7.chunk.js",
|
6
6
|
"static/js/9330.2b4c99e0.chunk.js": "./static/js/9330.2b4c99e0.chunk.js",
|
7
7
|
"static/js/2736.4336e2b9.chunk.js": "./static/js/2736.4336e2b9.chunk.js",
|
@@ -10,9 +10,9 @@
|
|
10
10
|
"static/js/8148.1b2c085e.chunk.js": "./static/js/8148.1b2c085e.chunk.js",
|
11
11
|
"static/css/5441.e3b876c5.chunk.css": "./static/css/5441.e3b876c5.chunk.css",
|
12
12
|
"static/js/5441.324eb9ab.chunk.js": "./static/js/5441.324eb9ab.chunk.js",
|
13
|
-
"static/js/8427.
|
13
|
+
"static/js/8427.5192ee0c.chunk.js": "./static/js/8427.5192ee0c.chunk.js",
|
14
14
|
"static/js/7323.b74cc85b.chunk.js": "./static/js/7323.b74cc85b.chunk.js",
|
15
|
-
"static/js/8536.
|
15
|
+
"static/js/8536.f7b26b02.chunk.js": "./static/js/8536.f7b26b02.chunk.js",
|
16
16
|
"static/js/7805.acc6316a.chunk.js": "./static/js/7805.acc6316a.chunk.js",
|
17
17
|
"static/js/4500.be0eb305.chunk.js": "./static/js/4500.be0eb305.chunk.js",
|
18
18
|
"static/js/1307.36b77087.chunk.js": "./static/js/1307.36b77087.chunk.js",
|
@@ -151,6 +151,6 @@
|
|
151
151
|
},
|
152
152
|
"entrypoints": [
|
153
153
|
"static/css/main.3aaaea00.css",
|
154
|
-
"static/js/main.
|
154
|
+
"static/js/main.7994a814.js"
|
155
155
|
]
|
156
156
|
}
|
streamlit/static/index.html
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.7994a814.js"></script><link href="./static/css/main.3aaaea00.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[8427],{18427:(e,t,o)=>{o.r(t),o.d(t,{default:()=>
|
1
|
+
"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[8427],{18427:(e,t,o)=>{o.r(t),o.d(t,{default:()=>m});var i=o(66845),r=o(25621),s=o(69021),a=o(27466),n=o(63730),d=o(59033),l=o(36989),c=o(1515);const p=(0,c.Z)("button",{target:"elibz2u3"})((e=>{let{theme:t}=e;return{fontSize:t.fontSizes.sm,lineHeight:"1.4rem",color:t.colors.fadedText60,backgroundColor:t.colors.transparent,border:"none",boxShadow:"none",padding:"0px","&:hover, &:active, &:focus":{border:"none",outline:"none",boxShadow:"none"},"&:hover":{color:t.colors.primary}}}),""),u=(0,c.Z)("div",{target:"elibz2u2"})((e=>{let{theme:t}=e;return{display:"flex",flexDirection:"row",gap:t.spacing.lg,"> span":{marginTop:"0.25rem"}}}),""),g=(0,c.Z)("div",{target:"elibz2u0"})((e=>{let{theme:t}=e;return{display:"flex",flexDirection:"column",gap:t.spacing.sm,alignItems:"start",justifyContent:"center",overflow:"hidden",minHeight:"100%",fontSize:t.fontSizes.sm,lineHeight:t.lineHeights.base}}),"");var f=o(22704),h=o(40864);const m=(0,r.b)((function(e){let{theme:t,body:o,icon:r,width:c}=e;const m=function(e){if(e.length>104){let t=e.replace(/^(.{104}[^\s]*).*/,"$1");return t.length>104&&(t=t.substring(0,104).split(" ").slice(0,-1).join(" ")),t.trim()}return e}(o),b=o!==m,[x,w]=(0,i.useState)(!b),[y,v]=(0,i.useState)(0),S=(0,i.useCallback)((()=>{w(!x)}),[x]),T=(0,i.useMemo)((()=>function(e){const t=(0,a.Iy)(e);return{Body:{props:{"data-testid":"stToast"},style:{display:"flex",flexDirection:"row",gap:e.spacing.md,width:e.sizes.sidebar,marginTop:"8px",borderTopLeftRadius:e.radii.default,borderTopRightRadius:e.radii.default,borderBottomLeftRadius:e.radii.default,borderBottomRightRadius:e.radii.default,paddingTop:e.spacing.lg,paddingBottom:e.spacing.lg,paddingLeft:e.spacing.twoXL,paddingRight:e.spacing.twoXL,backgroundColor:t?e.colors.gray10:e.colors.gray90,color:e.colors.bodyText,boxShadow:t?"0px 4px 16px rgba(0, 0, 0, 0.16)":"0px 4px 16px rgba(0, 0, 0, 0.7)"}},CloseIcon:{style:{color:e.colors.fadedText40,width:e.fontSizes.lg,height:e.fontSizes.lg,marginRight:"calc(-1 * ".concat(e.spacing.lg," / 2)"),":hover":{color:e.colors.bodyText}}}}}(t)),[t]),z=(0,i.useMemo)((()=>(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(u,{expanded:x,children:[r&&(0,h.jsx)(f.p,{iconValue:r,size:"xl",testid:"stToastDynamicIcon"}),(0,h.jsxs)(g,{children:[(0,h.jsx)(n.ZP,{source:x?o:m,allowHTML:!1,isToast:!0}),b&&(0,h.jsx)(p,{"data-testid":"toastViewButton",className:"toastViewButton",onClick:S,children:x?"view less":"view more"})]})]})})),[b,x,o,r,m,S]);(0,i.useEffect)((()=>{if(t.inSidebar)return;const e=s.Z.info(z,{overrides:{...T}});return v(e),()=>{s.Z.update(e,{overrides:{Body:{style:{transitionDuration:0}}}}),s.Z.clear(e)}}),[]),(0,i.useEffect)((()=>{s.Z.update(y,{children:z,overrides:{...T}})}),[y,z,T]);const R=(0,h.jsx)(l.Z,{kind:d.h.ERROR,body:"Streamlit API Error: `st.toast` cannot be called directly on the sidebar with `st.sidebar.toast`. See our `st.toast` API [docs](https://docs.streamlit.io/develop/api-reference/status/st.toast) for more information.",width:c});return(0,h.jsx)(h.Fragment,{children:t.inSidebar&&R})}))}}]);
|
@@ -0,0 +1 @@
|
|
1
|
+
(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[8536],{72394:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>K});var o=i(66845),n=i(70145),s=i(97365),r=i(62813),a=i.n(r),l=i(3717),c=i(25621),h=i(27466),d=i(88766),p=i(699),m=i(96260),u=i(24002),g=i(29378),x=i(80248),w=i(87072),b=i(12879),y=i(47203),S=i(61355),v=i(56264),f=i(19754),k=i(23593),j=i(63765),T=i(13005),C=i.n(T),z=i(82309),V=i(40864);const E=e=>{let{error:t,width:i,deltaType:o}=e;return t instanceof D?(0,V.jsx)(z.Z,{width:i,name:"No Mapbox token provided",message:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)("p",{children:["To use ",(0,V.jsxs)("code",{children:["st.",o]})," or ",(0,V.jsx)("code",{children:"st.map"})," you need to set up a Mapbox access token."]}),(0,V.jsxs)("p",{children:["To get a token, create an account at"," ",(0,V.jsx)("a",{href:"https://mapbox.com",children:"https://mapbox.com"}),". It's free for moderate usage levels!"]}),(0,V.jsxs)("p",{children:["Once you have a token, just set it using the Streamlit config option ",(0,V.jsx)("code",{children:"mapbox.token"})," and don't forget to restart your Streamlit server at this point if it's still running, then reload this tab."]}),(0,V.jsxs)("p",{children:["See"," ",(0,V.jsx)("a",{href:"https://docs.streamlit.io/develop/api-reference/configuration/config.toml",children:"our documentation"})," ","for more info on how to set config options."]})]})}):t instanceof M?(0,V.jsx)(z.Z,{width:i,name:"Error fetching Streamlit Mapbox token",message:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)("p",{children:"This app requires an internet connection."}),(0,V.jsx)("p",{children:"Please check your connection and try again."}),(0,V.jsxs)("p",{children:["If you think this is a bug, please file bug report"," ",(0,V.jsx)("a",{href:"https://github.com/streamlit/streamlit/issues/new/choose",children:"here"}),"."]})]})}):(0,V.jsx)(z.Z,{width:i,name:"Error fetching Streamlit Mapbox token",message:t.message})};var F=i(18080),Z=i(16295),I=i(72012),O=i(66694);class D extends Error{}class M extends Error{}const P="https://data.streamlit.io/tokens.json",W="mapbox",J=e=>t=>{class i extends o.PureComponent{constructor(i){super(i),this.context=void 0,this.initMapboxToken=async()=>{try{const e=await F.Z.get(P),{[W]:t}=e.data;if(!t)throw new Error("Missing token ".concat(W));this.setState({mapboxToken:t,isFetching:!1})}catch(e){const t=(0,j.b)(e);throw this.setState({mapboxTokenError:t,isFetching:!1}),new M("".concat(t.message," (").concat(P,")"))}},this.render=()=>{const{mapboxToken:i,mapboxTokenError:o,isFetching:n}=this.state,{width:s}=this.props;return o?(0,V.jsx)(E,{width:s,error:o,deltaType:e}):n?(0,V.jsx)(I.O,{element:Z.Od.create({style:Z.Od.SkeletonStyle.ELEMENT})}):(0,V.jsx)(t,{...this.props,mapboxToken:i,width:s})},this.state={isFetching:!0,mapboxToken:void 0,mapboxTokenError:void 0}}componentDidMount(){const e=this.props.element.mapboxToken||this.context.libConfig.mapboxToken;e?this.setState({mapboxToken:e,isFetching:!1}):this.initMapboxToken()}}return i.displayName="withMapboxToken(".concat(t.displayName||t.name,")"),i.contextType=O.E,C()(i,t)};var L=i(1515);const N=(0,L.Z)("div",{target:"e1az0zs51"})((e=>{let{width:t,height:i,theme:o}=e;return{marginTop:o.spacing.sm,position:"relative",height:i,width:t}}),""),B=(0,L.Z)("div",{target:"e1az0zs50"})((e=>{let{theme:t}=e;return{position:"absolute",right:"2.625rem",top:t.spacing.md,zIndex:1,"button:not(:disabled)":{background:t.colors.bgColor,"& + button":{borderTopColor:t.colors.secondaryBg},"& span":{filter:(0,h.Iy)(t)?"":"invert(100%)"}}}}),"");i(79259);const _={classes:{...g,...b,...w,...y,CartoLayer:d.Z},functions:{colorBins:p.Z,colorCategories:m.Z,colorContinuous:u.Z}};(0,f.fh)([S.w,v.E]);const R=new x.Z({configuration:_});class H extends o.PureComponent{constructor(){super(...arguments),this.state={viewState:{bearing:0,pitch:0,zoom:11},initialized:!1,initialViewState:{},id:void 0,pydeckJson:void 0,isFullScreen:!1,isLightTheme:(0,h.Iy)(this.props.theme)},this.componentDidMount=()=>{this.setState({initialized:!0})},this.createTooltip=e=>{const{element:t}=this.props;if(!e||!e.object||!t.tooltip)return!1;const i=s.Z.parse(t.tooltip);return i.html?i.html=this.interpolate(e,i.html):i.text=this.interpolate(e,i.text),i},this.interpolate=(e,t)=>{const i=t.match(/{(.*?)}/g);return i&&i.forEach((i=>{const o=i.substring(1,i.length-1);e.object.hasOwnProperty(o)?t=t.replace(i,e.object[o]):e.object.hasOwnProperty("properties")&&e.object.properties.hasOwnProperty(o)&&(t=t.replace(i,e.object.properties[o]))})),t},this.onViewStateChange=e=>{let{viewState:t}=e;this.setState({viewState:t})}}static getDerivedStateFromProps(e,t){const i=H.getDeckObject(e,t);if(!a()(i.initialViewState,t.initialViewState)){const e=Object.keys(i.initialViewState).reduce(((e,o)=>i.initialViewState[o]===t.initialViewState[o]?e:{...e,[o]:i.initialViewState[o]}),{});return{viewState:{...t.viewState,...e},initialViewState:i.initialViewState}}return null}render(){const e=H.getDeckObject(this.props,this.state),{viewState:t}=this.state;return(0,V.jsx)(N,{className:"stDeckGlJsonChart",width:e.initialViewState.width,height:e.initialViewState.height,"data-testid":"stDeckGlJsonChart",children:(0,V.jsxs)(n.Z,{viewState:t,onViewStateChange:this.onViewStateChange,height:e.initialViewState.height,width:e.initialViewState.width,layers:this.state.initialized?e.layers:[],getTooltip:this.createTooltip,ContextProvider:l.X$.Provider,controller:!0,children:[(0,V.jsx)(l.Z3,{height:e.initialViewState.height,width:e.initialViewState.width,mapStyle:e.mapStyle&&("string"===typeof e.mapStyle?e.mapStyle:e.mapStyle[0]),mapboxApiAccessToken:this.props.element.mapboxToken||this.props.mapboxToken}),(0,V.jsx)(B,{children:(0,V.jsx)(l.Pv,{className:"zoomButton",showCompass:!1})})]})})}}H.getDeckObject=(e,t)=>{var i,o;const{element:n,width:r,height:a,theme:l,isFullScreen:c}=e,d=null!==c&&void 0!==c&&c;var p,m,u;(n.id===t.id&&t.isFullScreen===d&&t.isLightTheme===(0,h.Iy)(l)||(t.pydeckJson=s.Z.parse(n.json),t.id=n.id),null!==(i=t.pydeckJson)&&void 0!==i&&i.mapStyle||(t.pydeckJson.mapStyle="mapbox://styles/mapbox/".concat((0,h.Iy)(l)?"light":"dark","-v9")),c)?Object.assign(null===(p=t.pydeckJson)||void 0===p?void 0:p.initialViewState,{width:r,height:a}):(null!==(m=t.pydeckJson)&&void 0!==m&&null!==(u=m.initialViewState)&&void 0!==u&&u.height||(t.pydeckJson.initialViewState.height=500),n.useContainerWidth&&(t.pydeckJson.initialViewState.width=r));return t.isFullScreen=c,t.isLightTheme=(0,h.Iy)(l),null===(o=t.pydeckJson)||void 0===o||delete o.views,R.convert(t.pydeckJson)};const K=(0,c.b)(J("st.pydeck_chart")((0,k.Z)(H)))},23593:(e,t,i)=>{"use strict";i.d(t,{Z:()=>w});var o=i(66845),n=i(13005),s=i.n(n),r=i(25621),a=i(82218),l=i(97781),c=i(46927),h=i(66694),d=i(1515);const p=(0,d.Z)("button",{target:"e1vs0wn31"})((e=>{let{isExpanded:t,theme:i}=e;const o=t?{right:"0.4rem",top:"0.5rem",backgroundColor:"transparent"}:{right:"-3.0rem",top:"-0.375rem",opacity:0,transform:"scale(0)",backgroundColor:i.colors.lightenedBg05};return{position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",zIndex:i.zIndices.sidebar+1,height:"2.5rem",width:"2.5rem",transition:"opacity 300ms 150ms, transform 300ms 150ms",border:"none",color:i.colors.fadedText60,borderRadius:"50%",...o,"&:focus":{outline:"none"},"&:active, &:focus-visible, &:hover":{opacity:1,outline:"none",transform:"scale(1)",color:i.colors.bodyText,transition:"none"}}}),""),m=(0,d.Z)("div",{target:"e1vs0wn30"})((e=>{let{theme:t,isExpanded:i}=e;return{"&:hover":{[p]:{opacity:1,transform:"scale(1)",transition:"none"}},...i?{position:"fixed",top:0,left:0,bottom:0,right:0,background:t.colors.bgColor,zIndex:t.zIndices.fullscreenWrapper,padding:t.spacing.md,paddingTop:"2.875rem",overflow:["auto","overlay"],display:"flex",alignItems:"center",justifyContent:"center"}:{}}}),"");var u=i(40864);class g extends o.PureComponent{constructor(e){super(e),this.context=void 0,this.controlKeys=e=>{const{expanded:t}=this.state;27===e.keyCode&&t&&this.zoomOut()},this.zoomIn=()=>{document.body.style.overflow="hidden",this.context.setFullScreen(!0),this.setState({expanded:!0})},this.zoomOut=()=>{document.body.style.overflow="unset",this.context.setFullScreen(!1),this.setState({expanded:!1})},this.convertScssRemValueToPixels=e=>parseFloat(e)*parseFloat(getComputedStyle(document.documentElement).fontSize),this.getWindowDimensions=()=>{const e=this.convertScssRemValueToPixels(this.props.theme.spacing.md),t=this.convertScssRemValueToPixels("2.875rem");return{fullWidth:window.innerWidth-2*e,fullHeight:window.innerHeight-(e+t)}},this.updateWindowDimensions=()=>{this.setState(this.getWindowDimensions())},this.state={expanded:!1,...this.getWindowDimensions()}}componentDidMount(){window.addEventListener("resize",this.updateWindowDimensions),document.addEventListener("keydown",this.controlKeys,!1)}componentWillUnmount(){window.removeEventListener("resize",this.updateWindowDimensions),document.removeEventListener("keydown",this.controlKeys,!1)}render(){const{expanded:e,fullWidth:t,fullHeight:i}=this.state,{children:o,width:n,height:s,disableFullscreenMode:r}=this.props;let h=a.d,d=this.zoomIn,g="View fullscreen";return e&&(h=l.m,d=this.zoomOut,g="Exit fullscreen"),(0,u.jsxs)(m,{isExpanded:e,"data-testid":"stFullScreenFrame",children:[!r&&(0,u.jsx)(p,{"data-testid":"StyledFullScreenButton",onClick:d,title:g,isExpanded:e,children:(0,u.jsx)(c.Z,{content:h})}),o(e?{width:t,height:i,expanded:e,expand:this.zoomIn,collapse:this.zoomOut}:{width:n,height:s,expanded:e,expand:this.zoomIn,collapse:this.zoomOut})]})}}g.contextType=h.E;const x=(0,r.b)(g);const w=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];class i extends o.PureComponent{constructor(){super(...arguments),this.render=()=>{const{width:i,height:o,disableFullscreenMode:n}=this.props;return(0,u.jsx)(x,{width:i,height:o,disableFullscreenMode:t||n,children:t=>{let{width:i,height:o,expanded:n,expand:s,collapse:r}=t;return(0,u.jsx)(e,{...this.props,width:i,height:o,isFullScreen:n,expand:s,collapse:r})}})}}}return i.displayName="withFullScreenWrapper(".concat(e.displayName||e.name,")"),s()(i,e)}},72709:()=>{},72672:()=>{}}]);
|