streamlit-nightly 1.38.1.dev20240925__py2.py3-none-any.whl → 1.38.1.dev20240926__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.
@@ -100,7 +100,7 @@ def parse_selection_mode(
100
100
  return set(parsed_selection_modes)
101
101
 
102
102
 
103
- class LayerSelectionState(TypedDict, total=False):
103
+ class PydeckSelectionState(TypedDict, total=False):
104
104
  """
105
105
  The schema for the PyDeck Layer Selection State
106
106
 
@@ -124,11 +124,11 @@ class PydeckState(TypedDict, total=False):
124
124
 
125
125
  Attributes
126
126
  ----------
127
- selection : LayerSelectionState
127
+ selection : PydeckSelectionState
128
128
  The selection state of the PyDeck layers.
129
129
  """
130
130
 
131
- selection: LayerSelectionState
131
+ selection: PydeckSelectionState
132
132
 
133
133
 
134
134
  @dataclass
@@ -166,6 +166,8 @@ class PydeckMixin:
166
166
  pydeck_obj: Deck | None = None,
167
167
  *,
168
168
  use_container_width: bool = False,
169
+ width: int | None = None,
170
+ height: int | None = None,
169
171
  selection_mode: Literal[
170
172
  "single-object"
171
173
  ], # Selection mode will only be activated by on_select param, this is a default value here to make it work with mypy
@@ -179,6 +181,8 @@ class PydeckMixin:
179
181
  pydeck_obj: Deck | None = None,
180
182
  *,
181
183
  use_container_width: bool = False,
184
+ width: int | None = None,
185
+ height: int | None = None,
182
186
  selection_mode: SelectionMode = "single-object",
183
187
  on_select: Literal["rerun"] | WidgetCallback = "rerun",
184
188
  key: Key | None = None,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.5513bd04.css",
4
- "main.js": "./static/js/main.e9d8ce9e.js",
4
+ "main.js": "./static/js/main.45415ac9.js",
5
5
  "static/js/6679.265ca09c.chunk.js": "./static/js/6679.265ca09c.chunk.js",
6
6
  "static/js/9464.7e9a3c0a.chunk.js": "./static/js/9464.7e9a3c0a.chunk.js",
7
7
  "static/js/9077.e0a8db2a.chunk.js": "./static/js/9077.e0a8db2a.chunk.js",
@@ -12,7 +12,7 @@
12
12
  "static/js/5711.229cb7d0.chunk.js": "./static/js/5711.229cb7d0.chunk.js",
13
13
  "static/js/3861.0dedcd19.chunk.js": "./static/js/3861.0dedcd19.chunk.js",
14
14
  "static/js/8642.58110d15.chunk.js": "./static/js/8642.58110d15.chunk.js",
15
- "static/js/3710.d73e609f.chunk.js": "./static/js/3710.d73e609f.chunk.js",
15
+ "static/js/3710.b80be2b0.chunk.js": "./static/js/3710.b80be2b0.chunk.js",
16
16
  "static/js/8148.f51df66c.chunk.js": "./static/js/8148.f51df66c.chunk.js",
17
17
  "static/js/84.414fa87b.chunk.js": "./static/js/84.414fa87b.chunk.js",
18
18
  "static/js/9923.7061d124.chunk.js": "./static/js/9923.7061d124.chunk.js",
@@ -156,6 +156,6 @@
156
156
  },
157
157
  "entrypoints": [
158
158
  "static/css/main.5513bd04.css",
159
- "static/js/main.e9d8ce9e.js"
159
+ "static/js/main.45415ac9.js"
160
160
  ]
161
161
  }
@@ -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.e9d8ce9e.js"></script><link href="./static/css/main.5513bd04.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
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.45415ac9.js"></script><link href="./static/css/main.5513bd04.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
@@ -0,0 +1 @@
1
+ (self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[3710],{40223:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>xe});var i=o(58878),r=o(6334),n=o(72192),l=o(59353),a=o(78025),s=o(43338),c=o(8151),d=o(68994),h=o(58144),u=o(85850),g=o(22044),m=o(29669);var p=o(53124),b=o.n(p),f=o(32782),y=o(67253),v=o(1780),w=o(84152),S=o(6240),x=o(90782);const j=e=>{let{error:t,width:o,deltaType:i}=e;return t instanceof C?(0,x.jsx)(S.A,{width:o,name:"No Mapbox token provided",message:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)("p",{children:["To use ",(0,x.jsxs)("code",{children:["st.",i]})," or ",(0,x.jsx)("code",{children:"st.map"})," you need to set up a Mapbox access token."]}),(0,x.jsxs)("p",{children:["To get a token, create an account at"," ",(0,x.jsx)("a",{href:"https://mapbox.com",children:"https://mapbox.com"}),". It's free for moderate usage levels!"]}),(0,x.jsxs)("p",{children:["Once you have a token, just set it using the Streamlit config option ",(0,x.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,x.jsxs)("p",{children:["See"," ",(0,x.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 k?(0,x.jsx)(S.A,{width:o,name:"Error fetching Streamlit Mapbox token",message:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("p",{children:"This app requires an internet connection."}),(0,x.jsx)("p",{children:"Please check your connection and try again."}),(0,x.jsxs)("p",{children:["If you think this is a bug, please file bug report"," ",(0,x.jsx)("a",{href:"https://github.com/streamlit/streamlit/issues/new/choose",children:"here"}),"."]})]})}):(0,x.jsx)(S.A,{width:o,name:"Error fetching Streamlit Mapbox token",message:t.message})};class C extends Error{}class k extends Error{}const A="https://data.streamlit.io/tokens.json",F="mapbox",M=e=>t=>{class o extends i.PureComponent{constructor(o){super(o),this.context=void 0,this.initMapboxToken=async()=>{try{const e=await f.A.get(A),{[F]:t}=e.data;if(!t)throw new Error(`Missing token ${F}`);this.setState({mapboxToken:t,isFetching:!1})}catch(e){const t=(0,y.$)(e);throw this.setState({mapboxTokenError:t,isFetching:!1}),new k(`${t.message} (${A})`)}},this.render=()=>{const{mapboxToken:o,mapboxTokenError:i,isFetching:r}=this.state,{width:n}=this.props;return i?(0,x.jsx)(j,{width:n,error:i,deltaType:e}):r?(0,x.jsx)(v.E,{element:m.EA.create({style:m.EA.SkeletonStyle.ELEMENT})}):(0,x.jsx)(t,{...this.props,mapboxToken:o,width:n})},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 o.displayName=`withMapboxToken(${t.displayName||t.name})`,o.contextType=w.n,b()(o,t)};var T=o(89653);const N=(0,T.A)("div",{target:"e1az0zs51"})((e=>{let{width:t,height:o}=e;return{position:"relative",height:o,width:t}}),""),E=(0,T.A)("div",{target:"e1az0zs50"})((e=>{let{theme:t}=e;return{position:"absolute",right:"2.625rem",top:t.spacing.md,zIndex:1,".mapboxgl-ctrl.mapboxgl-ctrl-group":{overflow:"hidden",background:t.colors.bgColor},"button:not(:disabled)":{background:t.colors.bgColor,"& + button":{borderTopColor:t.colors.secondaryBg},"&.mapboxgl-ctrl-icon:hover":{backgroundColor:(0,h.iq)(t)?"":t.colors.darkenedBgMix25},"& span":{filter:(0,h.iq)(t)?"":"invert(100%)"}}}}),"");var I=o(21640),O=o(71034),V=o.n(O),$=o(32735);var W=o(3101),D=o(14251),U=o(86202),P=o(26592),_=o(64639),z=o(73417),J=o(27126),B=o(38287);const L={classes:{...z,...o(19720),...B,...o(14249),CartoLayer:D.A},functions:{colorBins:U.A,colorCategories:P.A,colorContinuous:_.A}},q=new J.A({configuration:L});var G=o(44605),X=o(24983),Z=o(68212),K=o(20302),R=o(52265),H=o(60152),Q=o(70023),Y=o(6934),ee=o(34676),te=o(36217),oe=o(79579),ie=o(5830),re=o(74839),ne=o(16554),le=o(10762),ae=o(71749),se=o(45310),ce=o(26642),de=o(38610),he=o(41881);const ue={[ie.A.layerName]:["getFillColor"],[re.A.layerName]:["getFillColor"],[ne.Ay.layerName]:["getFillColor"],[le.A.layerName]:["getFillColor"],[ae.A.layerName]:["getFillColor"],[se.A.layerName]:["getFillColor"],[ce.A.layerName]:["getColor"],[G.A.layerName]:["getTargetColor","getSourceColor"],[X.A.layerName]:["getFillColor"],[Z.A.layerName]:["getFillColor"],[K.A.layerName]:["getColor"],[R.A.layerName]:["getColor"],[H.A.layerName]:["getColor"],[Q.A.layerName]:["getColor"],[Y.A.layerName]:["getFillColor"],[ee.A.layerName]:["getFillColor","getColor","getLineColor"],[te.A.layerName]:["getFillColor"],[oe.A.layerName]:["getColor"],[de.A.layerName]:["getColor"],[he.A.layerName]:["getColor"]},ge=e=>{let{isSelected:t,object:o,objectInfo:i,opacity:r,originalFillFunction:n}=e;const l=(e=>{let{object:t,objectInfo:o,originalFillFunction:i}=e;const r="function"===typeof i?i(t,o):i;if(Array.isArray(r))return[r[0]||0,r[1]||0,r[2]||0,r[3]||255];if("string"===typeof r&&r.startsWith("@@=")){const e=q.convert({originalColor:r}).originalColor(t);return[e[0]||0,e[1]||0,e[2]||0,e[3]||255]}return null})({object:o,objectInfo:i,originalFillFunction:n});if(!l)return null;let a=0;return a=t?Math.max("number"===typeof l[3]?l[3]:r,r):Math.min("number"===typeof l[3]?l[3]:r,r),[l[0]||0,l[1]||0,l[2]||0,a]},me={selection:{indices:{},objects:{}}},pe=(e,t)=>{const o=t.match(/{(.*?)}/g);return o&&o.forEach((o=>{const i=o.substring(1,o.length-1);e.object.hasOwnProperty(i)?t=t.replace(o,e.object[i]):e.object.hasOwnProperty("properties")&&e.object.properties.hasOwnProperty(i)&&(t=t.replace(o,e.object.properties[i]))})),t};function be(e,t){if(!t.id)return me;const o=e.getElementState(t.id,"selection");return null!==o&&void 0!==o?o:me}function fe(e,t){if(!t.id)return me;const o=e.getStringValue(t),i=o?I.A.parse(o):null;return null!==i&&void 0!==i?i:me}function ye(e,t,o,i){e.id&&t.setStringValue(e,JSON.stringify(o.value),{fromUi:o.fromUi},i)}const ve=e=>{var t;const{element:o,fragmentId:r,height:n,isFullScreen:l,isLightTheme:a,theme:s,widgetMgr:c,width:d}=e,{selectionMode:h,tooltip:u,useContainerWidth:g}=o,m=null!==l&&void 0!==l&&l,[p,b]=(0,W._)({element:o,getDefaultState:be,getStateFromWidgetMgr:fe,updateWidgetMgrState:ye,widgetMgr:c,fragmentId:r}),[f,y]=(0,i.useState)({bearing:0,pitch:0,zoom:11}),{height:v,width:w}=(e=>{let{container:t,element:o,heightFallback:r="auto",isFullScreen:n,shouldUseContainerWidth:l,widthFallback:a="auto"}=e;return{width:(0,i.useMemo)((()=>l||n?"100%":o.width||t.width||a),[t.width,o.width,n,l,a]),height:(0,i.useMemo)((()=>n&&t.height?t.height:o.height||t.height||r),[n,o.height,t.height,r])}})({element:o,isFullScreen:m,shouldUseContainerWidth:g,container:{height:n,width:d},heightFallback:(null===(t=f.initialViewState)||void 0===t?void 0:t.height)||500}),[S,x]=(0,i.useState)({}),j=h[0],C=void 0!==j,k=C&&Object.keys(p.selection.indices).length>0,A=(0,i.useMemo)((()=>Object.freeze(I.A.parse(o.json))),[m,a,o.json]),F=(0,i.useMemo)((()=>{const e={...A};if(e.mapStyle||(e.mapStyle=`mapbox://styles/mapbox/${a?"light":"dark"}-v9`),m?Object.assign(e.initialViewState,{width:w,height:v}):(e.initialViewState.height||(e.initialViewState.height=500),g&&(e.initialViewState.width=w)),e.layers){const t=Object.values(p.selection.indices).some((e=>null===e||void 0===e?void 0:e.length)),o=e.layers.some((e=>Object.hasOwn(e,"pickable")));e.layers=e.layers.map((e=>{var i,r;if(!e||Array.isArray(e)||!C)return e;o||(e.pickable=!0);const n=`${e.id||null}`,l=(null===p||void 0===p||null===(i=p.selection)||void 0===i||null===(r=i.indices)||void 0===r?void 0:r[n])||[],a=ue[e["@@type"]];if(!a)return e;const c={...e};return a.forEach((o=>{var i;c.updateTriggers={[o]:[...(null===(i=c.updateTriggers)||void 0===i?void 0:i[o])||[],l,t]};const r=!t,n=e[o];if(r||!n)return c;const a=Math.floor(102),d=(0,$.Du)(s.colors.primary),h=[d[0],d[1],d[2],255],u=(0,$.Du)(s.colors.gray20),g=[u[0],u[1],u[2],a];c[o]=(e,t)=>(e=>{let{isSelected:t,object:o,objectInfo:i,originalFillFunction:r,selectedColor:n,selectedOpacity:l=255,unselectedColor:a,unselectedOpacity:s=Math.floor(102)}=e;return t?ge({opacity:l,isSelected:!0,object:o,objectInfo:i,originalFillFunction:r})||n:ge({opacity:s,isSelected:!1,object:o,objectInfo:i,originalFillFunction:r})||a})({isSelected:l.includes(t.index),object:e,objectInfo:t,originalFillFunction:n,selectedColor:h,unselectedColor:g,selectedOpacity:255,unselectedOpacity:a})})),c}))}return null===e||void 0===e||delete e.views,q.convert(e)}),[p.selection.indices,v,m,a,C,A,g,s.colors.gray20,s.colors.primary,w]);(0,i.useEffect)((()=>{if(!V()(F.initialViewState,S)){const e=Object.keys(F.initialViewState).reduce(((e,t)=>F.initialViewState[t]===S[t]?e:{...e,[t]:F.initialViewState[t]}),{});y({...f,...e}),x(F.initialViewState)}}),[F.initialViewState,S,f]);const M=(0,i.useCallback)((e=>{if(!e||!e.object||!u)return null;const t=I.A.parse(u);return t.html?t.html=pe(e,t.html):t.text=pe(e,t.text),t}),[u]),T=(0,i.useCallback)((e=>{let{viewState:t}=e;y(t)}),[y]);return{createTooltip:M,data:p,deck:F,hasActiveSelection:k,height:v,isSelectionModeActivated:C,onViewStateChange:T,selectionMode:j,setSelection:b,viewState:f,width:w}};o(93298);(0,s.mk)([l.y,a.B]);const we=me.selection,Se=[],xe=M("st.pydeck_chart")((0,g.A)((e=>{const{collapse:t,disabled:o,disableFullscreenMode:l,element:a,expand:s,fragmentId:g,height:p,isFullScreen:b,mapboxToken:f,widgetMgr:y,width:v}=e,{mapboxToken:w}=a,S=(0,c.u)(),{createTooltip:j,data:C,deck:k,hasActiveSelection:A,height:F,isSelectionModeActivated:M,onViewStateChange:T,selectionMode:I,setSelection:O,viewState:V,width:$}=ve({element:a,fragmentId:g,height:p,isFullScreen:b,isLightTheme:(0,h.iq)(S),theme:S,widgetMgr:y,width:v}),[W,D]=(0,i.useState)(!1);(0,i.useEffect)((()=>{D(!0)}),[]);const U=(0,i.useCallback)((e=>{var t;if(void 0===I)return;const{index:o,object:i}=e,r=`${(null===(t=e.layer)||void 0===t?void 0:t.id)||null}`,n=C,l=-1===o,a=(()=>{if(l)return we;switch(I){case m.Xw.SelectionMode.SINGLE_OBJECT:var e;return(null===(e=n.selection.indices[r])||void 0===e?void 0:e[0])===o?we:{indices:{[`${r}`]:[o]},objects:{[`${r}`]:[i]}};case m.Xw.SelectionMode.MULTI_OBJECT:{const e=new Map(((null===n||void 0===n||null===(t=n.selection)||void 0===t||null===(a=t.indices)||void 0===a?void 0:a[r])||[]).map(((e,t)=>{var o,i,l;return[e,null===(o=n.selection)||void 0===o||null===(i=o.objects)||void 0===i||null===(l=i[r])||void 0===l?void 0:l[t]]})));if(e.has(o)?e.delete(o):e.set(o,i),0===e.size){const{[r]:e,...t}=n.selection.indices,{[r]:o,...i}=n.selection.objects;return{indices:t,objects:i}}return{indices:{...n.selection.indices,[`${r}`]:Array.from(e.keys())},objects:{...n.selection.objects,[`${r}`]:Array.from(e.values())}}}default:throw(e=>{throw new Error(`Reached a branch with non-exhaustive item: ${e}`)})(I),new Error("Invalid selection mode")}var t,a})();JSON.stringify(a)!==JSON.stringify(n.selection)&&O({fromUi:!0,value:{selection:a}})}),[I,C,O]),P=(0,i.useCallback)((()=>{O({value:{selection:we},fromUi:!0})}),[O]);return(0,x.jsxs)(N,{className:"stDeckGlJsonChart","data-testid":"stDeckGlJsonChart",width:$,height:F,children:[(0,x.jsx)(u.A,{isFullScreen:b,disableFullscreenMode:l,onExpand:s,onCollapse:t,target:N,locked:!(!A||o)||void 0,children:A&&!o&&(0,x.jsx)(u.K,{label:"Clear selection",onClick:P,icon:d.b})}),(0,x.jsxs)(r.A,{viewState:V,onViewStateChange:T,height:F,width:$,layers:W?k.layers:Se,getTooltip:j,ContextProvider:n.wZ.Provider,controller:!0,onClick:M&&!o?U:void 0,children:[(0,x.jsx)(n.b,{height:F,width:$,mapStyle:k.mapStyle&&("string"===typeof k.mapStyle?k.mapStyle:k.mapStyle[0]),mapboxApiAccessToken:w||f}),(0,x.jsx)(E,{children:(0,x.jsx)(n.ov,{"data-testid":"stDeckGlJsonChartZoomButton",showCompass:!1})})]})]})}),!0))},3101:(e,t,o)=>{"use strict";o.d(t,{_:()=>l,t:()=>a});var i=o(58878),r=o(34752),n=o(25571);function l(e){let{getStateFromWidgetMgr:t,getDefaultState:o,updateWidgetMgrState:l,element:a,widgetMgr:s,fragmentId:c}=e;const[d,h]=(0,i.useState)((()=>{var e;return null!==(e=t(s,a))&&void 0!==e?e:o(s,a)})),[u,g]=(0,i.useState)({value:d,fromUi:!1});(0,i.useEffect)((()=>{(0,n.hX)(u)||(g(null),h(u.value),l(a,s,u,c))}),[u,l,a,s,c]);const m=(0,i.useCallback)((()=>{g({value:o(s,a),fromUi:!0})}),[g,a,o,s]);return(0,r.X)({widgetMgr:s,element:a,onFormCleared:m}),[d,g]}function a(e){let{getStateFromWidgetMgr:t,getDefaultStateFromProto:o,getCurrStateFromProto:r,updateWidgetMgrState:n,element:a,widgetMgr:s,fragmentId:c}=e;const d=(0,i.useCallback)(((e,t)=>o(t)),[o]),[h,u]=l({getStateFromWidgetMgr:t,getDefaultState:d,updateWidgetMgrState:n,element:a,widgetMgr:s,fragmentId:c});return(0,i.useEffect)((()=>{a.setValue&&(a.setValue=!1,u({value:r(a),fromUi:!1}))}),[a,r,u]),[h,u]}},63872:()=>{},35111:()=>{}}]);