streamlit-nightly 1.36.1.dev20240720__py2.py3-none-any.whl → 1.36.1.dev20240722__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.
Files changed (40) hide show
  1. streamlit/commands/execution_control.py +17 -12
  2. streamlit/config.py +8 -4
  3. streamlit/elements/alert.py +6 -6
  4. streamlit/elements/dialog_decorator.py +1 -0
  5. streamlit/elements/heading.py +29 -52
  6. streamlit/elements/layouts.py +44 -83
  7. streamlit/elements/markdown.py +12 -17
  8. streamlit/elements/metric.py +19 -24
  9. streamlit/elements/progress.py +10 -20
  10. streamlit/elements/toast.py +6 -16
  11. streamlit/elements/vega_charts.py +49 -12
  12. streamlit/elements/widgets/button.py +74 -81
  13. streamlit/elements/widgets/button_group.py +50 -22
  14. streamlit/elements/widgets/camera_input.py +12 -21
  15. streamlit/elements/widgets/checkbox.py +40 -42
  16. streamlit/elements/widgets/color_picker.py +20 -21
  17. streamlit/elements/widgets/file_uploader.py +13 -21
  18. streamlit/elements/widgets/multiselect.py +24 -22
  19. streamlit/elements/widgets/number_input.py +31 -25
  20. streamlit/elements/widgets/radio.py +24 -21
  21. streamlit/elements/widgets/select_slider.py +22 -21
  22. streamlit/elements/widgets/selectbox.py +23 -21
  23. streamlit/elements/widgets/slider.py +24 -21
  24. streamlit/elements/widgets/text_widgets.py +48 -43
  25. streamlit/elements/widgets/time_widgets.py +44 -42
  26. streamlit/runtime/context.py +55 -7
  27. streamlit/runtime/fragment.py +3 -4
  28. streamlit/static/asset-manifest.json +3 -3
  29. streamlit/static/index.html +1 -1
  30. streamlit/static/static/js/7175.2779947a.chunk.js +1 -0
  31. streamlit/static/static/js/{main.d55f6a3c.js → main.35bc5645.js} +2 -2
  32. streamlit/testing/v1/app_test.py +10 -0
  33. {streamlit_nightly-1.36.1.dev20240720.dist-info → streamlit_nightly-1.36.1.dev20240722.dist-info}/METADATA +1 -1
  34. {streamlit_nightly-1.36.1.dev20240720.dist-info → streamlit_nightly-1.36.1.dev20240722.dist-info}/RECORD +39 -39
  35. {streamlit_nightly-1.36.1.dev20240720.dist-info → streamlit_nightly-1.36.1.dev20240722.dist-info}/WHEEL +1 -1
  36. streamlit/static/static/js/7175.4cdaec13.chunk.js +0 -1
  37. /streamlit/static/static/js/{main.d55f6a3c.js.LICENSE.txt → main.35bc5645.js.LICENSE.txt} +0 -0
  38. {streamlit_nightly-1.36.1.dev20240720.data → streamlit_nightly-1.36.1.dev20240722.data}/scripts/streamlit.cmd +0 -0
  39. {streamlit_nightly-1.36.1.dev20240720.dist-info → streamlit_nightly-1.36.1.dev20240722.dist-info}/entry_points.txt +0 -0
  40. {streamlit_nightly-1.36.1.dev20240720.dist-info → streamlit_nightly-1.36.1.dev20240722.dist-info}/top_level.txt +0 -0
@@ -122,16 +122,48 @@ class StreamlitCookies(Mapping[str, str]):
122
122
 
123
123
 
124
124
  class ContextProxy:
125
- """An interface to context about the current user session. Context is exposed as
126
- properties on `st.context`, such as `st.context.headers` or `st.context.cookies`.
127
- Each property description explains more about the contents."""
125
+ """An interface to access user session context.
126
+
127
+ ``st.context`` provides a read-only interface to access headers and cookies
128
+ for the current user session.
129
+
130
+ Each property (``st.context.headers`` and ``st.context.cookies``) returns
131
+ a dictionary of named values.
132
+
133
+ """
128
134
 
129
135
  @property
130
136
  @gather_metrics("context.headers")
131
137
  def headers(self) -> StreamlitHeaders:
132
- """A read-only, dict-like access to headers sent in the initial request.
133
- Keys are case-insensitive. Use get_all() to see all values if the same header
134
- is set multiple times.
138
+ """A read-only, dict-like object containing headers sent in the initial request.
139
+
140
+ Keys are case-insensitive and may be repeated. When keys are repeated,
141
+ dict-like methods will only return the last instance of each key. Use
142
+ ``.get_all(key="your_repeated_key")`` to see all values if the same
143
+ header is set multiple times.
144
+
145
+ Examples
146
+ --------
147
+ Show a dictionary of headers (with only the last instance of any
148
+ repeated key):
149
+
150
+ >>> import streamlit as st
151
+ >>>
152
+ >>> st.context.headers
153
+
154
+ Show the value of a specific header (or the last instance if it's
155
+ repeated):
156
+
157
+ >>> import streamlit as st
158
+ >>>
159
+ >>> st.context.headers["host"]
160
+
161
+ Show of list of all headers for a given key:
162
+
163
+ >>> import streamlit as st
164
+ >>>
165
+ >>> st.context.headers.get_all("pragma")
166
+
135
167
  """
136
168
  # We have a docstring in line above as one-liner, to have a correct docstring
137
169
  # in the st.write(st,context) call.
@@ -145,7 +177,23 @@ class ContextProxy:
145
177
  @property
146
178
  @gather_metrics("context.cookies")
147
179
  def cookies(self) -> StreamlitCookies:
148
- """A read-only, dict-like access to cookies sent in the initial request."""
180
+ """A read-only, dict-like object containing cookies sent in the initial request.
181
+
182
+ Examples
183
+ --------
184
+ Show a dictionary of cookies:
185
+
186
+ >>> import streamlit as st
187
+ >>>
188
+ >>> st.context.cookies
189
+
190
+ Show the value of a specific cookie:
191
+
192
+ >>> import streamlit as st
193
+ >>>
194
+ >>> st.context.cookies["_ga"]
195
+
196
+ """
149
197
  # We have a docstring in line above as one-liner, to have a correct docstring
150
198
  # in the st.write(st,context) call.
151
199
  session_client_request = _get_request()
@@ -306,8 +306,9 @@ def fragment(
306
306
  interacting with your app.
307
307
 
308
308
  To trigger an app rerun from inside a fragment, call ``st.rerun()``
309
- directly. Any values from the fragment that need to be accessed from
310
- the wider app should generally be stored in Session State.
309
+ directly. To trigger a fragment rerun from within itself, call
310
+ ``st.rerun(scope="fragment")``. Any values from the fragment that need to
311
+ be accessed from the wider app should generally be stored in Session State.
311
312
 
312
313
  When Streamlit element commands are called directly in a fragment, the
313
314
  elements are cleared and redrawn on each fragment rerun, just like all
@@ -327,8 +328,6 @@ def fragment(
327
328
  responsible for handling any side effects of that behavior.
328
329
 
329
330
  .. warning::
330
- - Fragments can't contain other fragments. Additionally, using
331
- fragments in widget callback functions is not supported.
332
331
 
333
332
  - Fragments can only contain widgets in their main body. Fragments
334
333
  can't render widgets to externally created containers.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.29bca1b5.css",
4
- "main.js": "./static/js/main.d55f6a3c.js",
4
+ "main.js": "./static/js/main.35bc5645.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.7d516fcc.chunk.js": "./static/js/2736.7d516fcc.chunk.js",
@@ -39,7 +39,7 @@
39
39
  "static/js/3599.565b1eba.chunk.js": "./static/js/3599.565b1eba.chunk.js",
40
40
  "static/js/8691.cb9c04cf.chunk.js": "./static/js/8691.cb9c04cf.chunk.js",
41
41
  "static/js/6718.2e6586ef.chunk.js": "./static/js/6718.2e6586ef.chunk.js",
42
- "static/js/7175.4cdaec13.chunk.js": "./static/js/7175.4cdaec13.chunk.js",
42
+ "static/js/7175.2779947a.chunk.js": "./static/js/7175.2779947a.chunk.js",
43
43
  "static/js/5345.73d26e5d.chunk.js": "./static/js/5345.73d26e5d.chunk.js",
44
44
  "static/js/9865.fd93213d.chunk.js": "./static/js/9865.fd93213d.chunk.js",
45
45
  "static/js/6405.ac5a6f23.chunk.js": "./static/js/6405.ac5a6f23.chunk.js",
@@ -152,6 +152,6 @@
152
152
  },
153
153
  "entrypoints": [
154
154
  "static/css/main.29bca1b5.css",
155
- "static/js/main.d55f6a3c.js"
155
+ "static/js/main.35bc5645.js"
156
156
  ]
157
157
  }
@@ -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.d55f6a3c.js"></script><link href="./static/css/main.29bca1b5.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.35bc5645.js"></script><link href="./static/css/main.29bca1b5.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
+ "use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[7175],{79986:(e,t,r)=>{r.d(t,{Z:()=>c});r(66845);var o,n=r(50641),l=r(86659),a=r(50669),i=r(1515);const s=(0,r(7865).F4)(o||(o=(0,a.Z)(["\n 50% {\n color: rgba(0, 0, 0, 0);\n }\n"]))),d=(0,i.Z)("span",{target:"edlqvik0"})((e=>{let{includeDot:t,shouldBlink:r,theme:o}=e;return{...t?{"&::before":{opacity:1,content:'"\u2022"',animation:"none",color:o.colors.gray,margin:"0 5px"}}:{},...r?{color:o.colors.red,animationName:"".concat(s),animationDuration:"0.5s",animationIterationCount:5}:{}}}),"");var u=r(40864);const c=e=>{let{dirty:t,value:r,maxLength:o,className:a,type:i="single",inForm:s}=e;const c=[],p=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];c.push((0,u.jsx)(d,{includeDot:c.length>0,shouldBlink:t,children:e},c.length))};if(t){const e=s?"submit form":"apply";if("multiline"===i){const t=(0,n.Ge)()?"\u2318":"Ctrl";p("Press ".concat(t,"+Enter to ").concat(e))}else"single"===i&&p("Press Enter to ".concat(e))}return o&&("chat"!==i||t)&&p("".concat(r.length,"/").concat(o),t&&r.length>=o),(0,u.jsx)(l.X7,{"data-testid":"InputInstructions",className:a,children:c})}},87814:(e,t,r)=>{r.d(t,{K:()=>n});var o=r(50641);class n{constructor(){this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}manageFormClearListener(e,t,r){null!=this.formClearListener&&this.lastWidgetMgr===e&&this.lastFormId===t||(this.disconnect(),(0,o.bM)(t)&&(this.formClearListener=e.addFormClearedListener(t,r),this.lastWidgetMgr=e,this.lastFormId=t))}disconnect(){var e;null===(e=this.formClearListener)||void 0===e||e.disconnect(),this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}}},67175:(e,t,r)=>{r.r(t),r.d(t,{default:()=>j});var o=r(66845),n=r(20607),l=r(89997),a=r(25621),i=r(52347),s=r(87814),d=r(23849),u=r(16295),c=r(48266),p=r(8879),m=r(68411),g=r(46927),h=r(82534),b=r(79986),f=r(98478),v=r(86659),y=r(50641),I=r(1515);const x=(0,I.Z)("div",{target:"e116k4er3"})((e=>{let{theme:t}=e;return{display:"flex",flexDirection:"row",flexWrap:"nowrap",alignItems:"center",height:t.sizes.minElementHeight,borderWidth:t.sizes.borderWidth,borderStyle:"solid",borderColor:t.colors.widgetBorderColor||t.colors.widgetBackgroundColor||t.colors.bgColor,transitionDuration:"200ms",transitionProperty:"border",transitionTimingFunction:"cubic-bezier(0.2, 0.8, 0.4, 1)",borderRadius:t.radii.default,overflow:"hidden","&.focused":{borderColor:t.colors.primary},input:{MozAppearance:"textfield","&::-webkit-inner-spin-button, &::-webkit-outer-spin-button":{WebkitAppearance:"none",margin:t.spacing.none}}}}),""),w=(0,I.Z)("div",{target:"e116k4er2"})({name:"76z9jo",styles:"display:flex;flex-direction:row;align-self:stretch"}),C=(0,I.Z)("button",{target:"e116k4er1"})((e=>{let{theme:t}=e;return{margin:t.spacing.none,border:"none",height:t.sizes.full,display:"flex",alignItems:"center",width:"".concat(32,"px"),justifyContent:"center",color:t.colors.bodyText,transition:"color 300ms, backgroundColor 300ms",backgroundColor:t.colors.widgetBackgroundColor||t.colors.secondaryBg,"&:hover:enabled, &:focus:enabled":{color:t.colors.white,backgroundColor:t.colors.primary,transition:"none",outline:"none"},"&:active":{outline:"none",border:"none"},"&:last-of-type":{borderTopRightRadius:t.radii.default,borderBottomRightRadius:t.radii.default},"&:disabled":{cursor:"not-allowed",color:t.colors.fadedText40}}}),""),T=(0,I.Z)("div",{target:"e116k4er0"})((e=>{let{theme:t,clearable:r}=e;return{position:"absolute",marginRight:t.spacing.twoXS,left:0,right:"".concat(64+(r?12:0),"px")}}),"");var k=r(70479),R=r.n(k),D=r(40864);const F=e=>{let{step:t,dataType:r}=e;return t||(r===u.Y2.DataType.INT?1:.01)},N=e=>{let{value:t,format:r,step:o,dataType:n}=e;if((0,y.le)(t))return null;let l=function(e){return null==e||""===e?void 0:e}(r);if(null==l&&null!=o){const e=o.toString();if(n===u.Y2.DataType.FLOAT&&0!==o&&e.includes(".")){const t=e.split(".")[1].length;l="%0.".concat(t,"f")}}if(null==l)return t.toString();try{return(0,i.sprintf)(l,t)}catch(a){return(0,d.KE)("Error in sprintf(".concat(l,", ").concat(t,"): ").concat(a)),String(t)}},j=(0,a.b)((e=>{var t;let{disabled:r,element:a,widgetMgr:i,width:d,theme:I,fragmentId:k}=e;const{dataType:j,id:W,formId:L,default:S,format:B}=a,M=a.hasMin?a.min:-1/0,Z=a.hasMax?a.max:1/0,[E,V]=o.useState(F(a)),U=(e=>{var t;const r=e.element.dataType===u.Y2.DataType.INT?e.widgetMgr.getIntValue(e.element):e.widgetMgr.getDoubleValue(e.element);return null!==(t=null!==r&&void 0!==r?r:e.element.default)&&void 0!==t?t:null})({element:a,widgetMgr:i}),[z,A]=o.useState(!1),[_,Y]=o.useState(U),[K,O]=o.useState(N({value:U,...a,step:E})),[P,H]=o.useState(!1),G=o.useRef(null),X=o.useRef(new s.K),$=o.useRef(R()("number_input_")),q=((e,t,r)=>!(0,y.le)(e)&&e-t>=r)(_,E,M),J=((e,t,r)=>!(0,y.le)(e)&&e+t<=r)(_,E,Z);o.useEffect((()=>{V(F({step:a.step,dataType:a.dataType}))}),[a.dataType,a.step]);const Q=o.useCallback((e=>{let{value:t,source:r}=e;if((0,y.bb)(t)&&(M>t||t>Z)){var o;null===(o=G.current)||void 0===o||o.reportValidity()}else{var n;const e=null!==(n=null!==t&&void 0!==t?t:S)&&void 0!==n?n:null;switch(j){case u.Y2.DataType.INT:i.setIntValue({id:W,formId:L},e,r,k);break;case u.Y2.DataType.FLOAT:i.setDoubleValue({id:W,formId:L},e,r,k);break;default:throw new Error("Invalid data type")}A(!1),Y(e),O(N({value:e,dataType:j,format:B,step:E}))}}),[M,Z,G,i,k,E,j,W,L,S,B]),ee=()=>{const{value:e}=a;a.setValue=!1,Y(null!==e&&void 0!==e?e:null),O(N({value:null!==e&&void 0!==e?e:null,...a,step:E})),Q({value:null!==e&&void 0!==e?e:null,source:{fromUi:!1}})};o.useEffect((()=>{const e=X.current;return a.setValue?ee():Q({value:_,source:{fromUi:!1}}),()=>{e.disconnect()}}),[]),a.setValue&&ee();const te=(0,y.le)(a.default)&&!r;X.current.manageFormClearListener(i,a.formId,(()=>{var e;Y(null!==(e=a.default)&&void 0!==e?e:null),Q({value:_,source:{fromUi:!0}})}));const re=o.useCallback((()=>{J&&(A(!0),Q({value:(null!==_&&void 0!==_?_:M)+E,source:{fromUi:!0}}))}),[_,M,E,J]),oe=o.useCallback((()=>{q&&(A(!0),Q({value:(null!==_&&void 0!==_?_:Z)-E,source:{fromUi:!0}}))}),[_,Z,E,q]),ne=o.useCallback((e=>{const{key:t}=e;switch(t){case"ArrowUp":e.preventDefault(),re();break;case"ArrowDown":e.preventDefault(),oe()}}),[re,oe]),le=o.useCallback((e=>{"Enter"===e.key&&(z&&Q({value:_,source:{fromUi:!0}}),(0,y.$b)({formId:L})&&i.submitForm(L,k))}),[z,_,Q,i,L,k]);return(0,D.jsxs)("div",{className:"stNumberInput","data-testid":"stNumberInput",style:{width:d},children:[(0,D.jsx)(f.O,{label:a.label,disabled:r,labelVisibility:(0,y.iF)(null===(t=a.labelVisibility)||void 0===t?void 0:t.value),htmlFor:$.current,children:a.help&&(0,D.jsx)(v.dT,{children:(0,D.jsx)(p.Z,{content:a.help,placement:m.u.TOP_RIGHT})})}),(0,D.jsxs)(x,{className:P?"focused":"","data-testid":"stNumberInputContainer",children:[(0,D.jsx)(h.Z,{type:"number",inputRef:G,value:null!==K&&void 0!==K?K:"",placeholder:a.placeholder,onBlur:()=>(z&&Q({value:_,source:{fromUi:!0}}),void H(!1)),onFocus:()=>{H(!0)},onChange:e=>(e=>{const{value:t}=e.target;if(""===t)A(!0),Y(null),O(null);else{let e;e=a.dataType===u.Y2.DataType.INT?parseInt(t,10):parseFloat(t),A(!0),Y(e),O(t)}})(e),onKeyPress:e=>le(e),onKeyDown:e=>ne(e),clearable:te,clearOnEscape:te,disabled:r,"aria-label":a.label,id:$.current,overrides:{ClearIcon:{props:{overrides:{Svg:{style:{color:I.colors.darkGray,transform:"scale(1.4)",width:I.spacing.twoXL,marginRight:"-1.25em",":hover":{fill:I.colors.bodyText}}}}}},Input:{props:{"data-testid":"stNumberInput-Input",step:E,min:M,max:Z},style:{lineHeight:I.lineHeights.inputWidget,paddingRight:I.spacing.sm,paddingLeft:I.spacing.sm,paddingBottom:I.spacing.sm,paddingTop:I.spacing.sm}},InputContainer:{style:()=>({borderTopRightRadius:0,borderBottomRightRadius:0})},Root:{style:()=>({borderTopRightRadius:0,borderBottomRightRadius:0,borderLeftWidth:0,borderRightWidth:0,borderTopWidth:0,borderBottomWidth:0})}}}),d>c.A.hideNumberInputControls&&(0,D.jsxs)(w,{children:[(0,D.jsx)(C,{className:"step-down","data-testid":"stNumberInput-StepDown",onClick:oe,disabled:!q||r,tabIndex:-1,children:(0,D.jsx)(g.Z,{content:n.W,size:"xs",color:q?"inherit":"disabled"})}),(0,D.jsx)(C,{className:"step-up","data-testid":"stNumberInput-StepUp",onClick:re,disabled:!J||r,tabIndex:-1,children:(0,D.jsx)(g.Z,{content:l.v,size:"xs",color:J?"inherit":"disabled"})})]})]}),d>c.A.hideWidgetDetails&&(0,D.jsx)(T,{clearable:te,children:(0,D.jsx)(b.Z,{dirty:z,value:null!==K&&void 0!==K?K:"",inForm:(0,y.$b)({formId:a.formId})})})]})}))}}]);