streamlit-nightly 1.42.3.dev20250225__py2.py3-none-any.whl → 1.42.3.dev20250227__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 (101) hide show
  1. streamlit/commands/navigation.py +16 -4
  2. streamlit/commands/page_config.py +1 -2
  3. streamlit/config.py +11 -4
  4. streamlit/elements/widgets/button.py +5 -7
  5. streamlit/elements/widgets/chat.py +101 -18
  6. streamlit/elements/widgets/file_uploader.py +20 -10
  7. streamlit/errors.py +11 -9
  8. streamlit/navigation/page.py +2 -10
  9. streamlit/proto/ChatInput_pb2.py +6 -6
  10. streamlit/proto/ChatInput_pb2.pyi +5 -1
  11. streamlit/proto/ClientState_pb2.py +5 -3
  12. streamlit/proto/ClientState_pb2.pyi +29 -2
  13. streamlit/proto/ForwardMsg_pb2.py +12 -10
  14. streamlit/proto/NewSession_pb2.py +16 -16
  15. streamlit/proto/NewSession_pb2.pyi +9 -9
  16. streamlit/proto/PagesChanged_pb2.pyi +3 -1
  17. streamlit/runtime/app_session.py +6 -13
  18. streamlit/runtime/context.py +19 -0
  19. streamlit/runtime/pages_manager.py +61 -232
  20. streamlit/runtime/scriptrunner/script_runner.py +51 -2
  21. streamlit/runtime/scriptrunner_utils/script_requests.py +7 -1
  22. streamlit/runtime/scriptrunner_utils/script_run_context.py +5 -1
  23. streamlit/source_util.py +4 -90
  24. streamlit/static/index.html +1 -1
  25. streamlit/static/static/js/{FileDownload.esm.BlYgQAwd.js → FileDownload.esm.rdZtCw5-.js} +1 -1
  26. streamlit/static/static/js/FileHelper.BztOEKJy.js +5 -0
  27. streamlit/static/static/js/{FormClearHelper.B4WYSqDL.js → FormClearHelper.Drd1fMJc.js} +1 -1
  28. streamlit/static/static/js/{Hooks.BoeFlDaA.js → Hooks.DWd0hyk4.js} +1 -1
  29. streamlit/static/static/js/{InputInstructions.DiPa6u6x.js → InputInstructions.B7xrWTG0.js} +1 -1
  30. streamlit/static/static/js/{ProgressBar.B-iCNc1a.js → ProgressBar.CBgJiTH-.js} +1 -1
  31. streamlit/static/static/js/{RenderInPortalIfExists.DPgp77ia.js → RenderInPortalIfExists.US28tQOn.js} +1 -1
  32. streamlit/static/static/js/{Toolbar.9G2Er6_r.js → Toolbar.CAOt-xaL.js} +1 -1
  33. streamlit/static/static/js/{base-input.z22leTiB.js → base-input.CauNaJqr.js} +1 -1
  34. streamlit/static/static/js/{checkbox.DT5JbCKx.js → checkbox.ChzWCtre.js} +1 -1
  35. streamlit/static/static/js/{createSuper.9dngDO4F.js → createSuper.D_39RJB6.js} +1 -1
  36. streamlit/static/static/js/{data-grid-overlay-editor.DnBgrJEy.js → data-grid-overlay-editor.rIelkOVS.js} +1 -1
  37. streamlit/static/static/js/{downloader.BgiOz4Dy.js → downloader.Dz5I28nG.js} +1 -1
  38. streamlit/static/static/js/{es6.C2nbxS8x.js → es6.DwnEjMMn.js} +2 -2
  39. streamlit/static/static/js/{iframeResizer.contentWindow.XvWZp7Dg.js → iframeResizer.contentWindow.BRiRifwd.js} +1 -1
  40. streamlit/static/static/js/{index.DkwDCuk1.js → index.BE6MTF-B.js} +1 -1
  41. streamlit/static/static/js/{index.DMreumKF.js → index.BUdhIGhT.js} +1 -1
  42. streamlit/static/static/js/{index.Bgn4z-Mp.js → index.BWeYb5ES.js} +1 -1
  43. streamlit/static/static/js/{index.exPoJHIW.js → index.Bb4OB39A.js} +1 -1
  44. streamlit/static/static/js/{index.T5vKsEVA.js → index.BrAW6bFJ.js} +1 -1
  45. streamlit/static/static/js/{index.D5wciRNz.js → index.CAHGh74D.js} +1 -1
  46. streamlit/static/static/js/{index.CrNuA-BG.js → index.CBre8Aui.js} +1 -1
  47. streamlit/static/static/js/{index.CMvo7Iwl.js → index.CM12P2T1.js} +1 -1
  48. streamlit/static/static/js/{index.DZ_FHOJd.js → index.CO3dZWKG.js} +1 -1
  49. streamlit/static/static/js/{index.BFYGskaf.js → index.CUz1_nAm.js} +1 -1
  50. streamlit/static/static/js/{index.DTP3exjF.js → index.C_C365T5.js} +1 -1
  51. streamlit/static/static/js/{index.CAC6FyHh.js → index.CmYiLKNX.js} +1 -1
  52. streamlit/static/static/js/{index.bDDanN90.js → index.CoUzNoRf.js} +1 -1
  53. streamlit/static/static/js/{index.DcXXaGYK.js → index.Ct7MPsA3.js} +1 -1
  54. streamlit/static/static/js/{index.UrE-Phqy.js → index.D1K6NCBQ.js} +1 -1
  55. streamlit/static/static/js/{index.D9bqDCB_.js → index.D2xM-XzG.js} +1 -1
  56. streamlit/static/static/js/{index.BTK3gx3H.js → index.D9rv1PQ0.js} +1 -1
  57. streamlit/static/static/js/{index.BdtKHTgl.js → index.DIeegLbv.js} +1 -1
  58. streamlit/static/static/js/{index.pWHQEj0Q.js → index.DJvwxFLn.js} +1 -1
  59. streamlit/static/static/js/{index.CBoIJv6M.js → index.DKuQg2D4.js} +1 -1
  60. streamlit/static/static/js/{index.DjTdTgti.js → index.DWFLx6Tc.js} +11 -11
  61. streamlit/static/static/js/{index.DC6PJYZU.js → index.DYUhWSq6.js} +1 -1
  62. streamlit/static/static/js/{index.rECpAXqX.js → index.Db3jGJxa.js} +1 -1
  63. streamlit/static/static/js/{index.BDSGWkr0.js → index.DfNAkKAr.js} +145 -145
  64. streamlit/static/static/js/{index.C5bx6jEW.js → index.DgNQKEeQ.js} +1 -1
  65. streamlit/static/static/js/{index.BkyYp5Em.js → index.Dj91melR.js} +1 -1
  66. streamlit/static/static/js/{index.Hnms5TSS.js → index.DkKZlAsv.js} +1 -1
  67. streamlit/static/static/js/index.DkgVNhWs.js +1 -0
  68. streamlit/static/static/js/{index.D-9nQW74.js → index.Dzp8iBkF.js} +1 -1
  69. streamlit/static/static/js/index.LL2DLZZA.js +201 -0
  70. streamlit/static/static/js/index.ORHz8Y8P.js +4537 -0
  71. streamlit/static/static/js/{index.CBYIbEuv.js → index.V3Vj2d9m.js} +1 -1
  72. streamlit/static/static/js/{index.B5-iXfzx.js → index.YNWoT4uW.js} +1 -1
  73. streamlit/static/static/js/index.aL_kqyvR.js +1 -0
  74. streamlit/static/static/js/{index.JgS0whqe.js → index.fP6rBxlc.js} +1 -1
  75. streamlit/static/static/js/{index.BxYliQ9c.js → index.pvQjxG7y.js} +1 -1
  76. streamlit/static/static/js/{index.BNc20KTN.js → index.wxpL02VY.js} +1 -1
  77. streamlit/static/static/js/{input.mCBQrtCY.js → input.D_dn5-2t.js} +1 -1
  78. streamlit/static/static/js/{memory.Te_zHgq3.js → memory.pnMTtWQR.js} +1 -1
  79. streamlit/static/static/js/{mergeWith.Di9Yv3PE.js → mergeWith.CRrYodeI.js} +1 -1
  80. streamlit/static/static/js/{number-overlay-editor.Du6B2U8c.js → number-overlay-editor.C65GBS2P.js} +1 -1
  81. streamlit/static/static/js/{possibleConstructorReturn.DqqPe-iu.js → possibleConstructorReturn.BnQk7lq_.js} +1 -1
  82. streamlit/static/static/js/{sandbox.iqWXuowq.js → sandbox.CrxXt1li.js} +1 -1
  83. streamlit/static/static/js/{textarea.DUN7d2zN.js → textarea.DiFyO5JY.js} +1 -1
  84. streamlit/static/static/js/{timepicker.BkmEJ-b8.js → timepicker.B1Y7LIk4.js} +1 -1
  85. streamlit/static/static/js/{toConsumableArray.D4OFzlWy.js → toConsumableArray.BWpBUK-j.js} +1 -1
  86. streamlit/static/static/js/{uniqueId.6OlKTkzK.js → uniqueId.7ecIUkUs.js} +1 -1
  87. streamlit/static/static/js/{useBasicWidgetState.Btr3rzhN.js → useBasicWidgetState.deG0KPm0.js} +1 -1
  88. streamlit/static/static/js/{useOnInputChange.BM7LVpC-.js → useOnInputChange.CQ7sD7CO.js} +1 -1
  89. streamlit/static/static/js/{withFullScreenWrapper.BCTIo1o2.js → withFullScreenWrapper.D0wnBu3k.js} +1 -1
  90. streamlit/testing/v1/app_test.py +8 -10
  91. {streamlit_nightly-1.42.3.dev20250225.dist-info → streamlit_nightly-1.42.3.dev20250227.dist-info}/METADATA +1 -1
  92. {streamlit_nightly-1.42.3.dev20250225.dist-info → streamlit_nightly-1.42.3.dev20250227.dist-info}/RECORD +96 -96
  93. {streamlit_nightly-1.42.3.dev20250225.dist-info → streamlit_nightly-1.42.3.dev20250227.dist-info}/WHEEL +1 -1
  94. streamlit/static/static/js/FileHelper.Da-FUCX4.js +0 -5
  95. streamlit/static/static/js/index.BiPYzGZi.js +0 -1
  96. streamlit/static/static/js/index.DV46EgCO.js +0 -201
  97. streamlit/static/static/js/index.DyyHt_xV.js +0 -1
  98. streamlit/static/static/js/index.qC8qMz0q.js +0 -3865
  99. {streamlit_nightly-1.42.3.dev20250225.data → streamlit_nightly-1.42.3.dev20250227.data}/scripts/streamlit.cmd +0 -0
  100. {streamlit_nightly-1.42.3.dev20250225.dist-info → streamlit_nightly-1.42.3.dev20250227.dist-info}/entry_points.txt +0 -0
  101. {streamlit_nightly-1.42.3.dev20250225.dist-info → streamlit_nightly-1.42.3.dev20250227.dist-info}/top_level.txt +0 -0
@@ -1 +0,0 @@
1
- import{r as g,E as C,_ as b,n as d,G as $,B as p,j as n,bp as m,bq as F,b4 as O,b5 as S,cp as q,cq as G,aZ as _,F as K,bi as j,R as Y,aA as Z,bk as J,L as h,bm as Q,bl as ee,bs as te,bF as ie,bt as se,ba as le,bu as ae}from"./index.BDSGWkr0.js";import{a as I}from"./index.DW_MHI2K.js";import{F as ne}from"./FormClearHelper.B4WYSqDL.js";import{g as w,F as f,a as oe,D as re,I as de,C as ce,s as pe}from"./FileHelper.Da-FUCX4.js";import{S as ge,P as ue}from"./ProgressBar.B-iCNc1a.js";import{u as he}from"./Hooks.BoeFlDaA.js";import{U as y}from"./UploadFileInfo.C-jY39rj.js";var M=g.forwardRef(function(e,s){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return g.createElement(C,b({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:s}),g.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),g.createElement("path",{d:"M19.35 10.04A7.49 7.49 0 0012 4C9.11 4 6.6 5.64 5.35 8.04A5.994 5.994 0 000 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95A5.469 5.469 0 0112 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11A2.98 2.98 0 0122 15c0 1.65-1.35 3-3 3zM8 13h2.55v3h2.9v-3H16l-4-4z"}))});M.displayName="CloudUpload";var B=g.forwardRef(function(e,s){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return g.createElement(C,b({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:s}),g.createElement("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}))});B.displayName="Error";const V=d("section",{target:"e17y52ym0"})(({isDisabled:e,theme:s})=>({display:"flex",alignItems:"center",padding:s.spacing.lg,backgroundColor:s.colors.secondaryBg,borderRadius:s.radii.default,border:s.colors.widgetBorderColor?`${s.sizes.borderWidth} solid ${s.colors.widgetBorderColor}`:void 0,":focus":{outline:"none"},":focus-visible":{boxShadow:`0 0 0 1px ${s.colors.primary}`},color:e?s.colors.gray:s.colors.bodyText})),D=d("div",{target:"e17y52ym1"})({marginRight:"auto",alignItems:"center",display:"flex"}),P=d("span",{target:"e17y52ym2"})(({theme:e})=>({color:e.colors.darkenedBgMix100,marginRight:e.spacing.lg})),me=d("span",{target:"e17y52ym3"})(({theme:e})=>({marginBottom:e.spacing.twoXS})),fe=d("div",{target:"e17y52ym4"})({display:"flex",flexDirection:"column"}),L=d("div",{target:"e17y52ym5"})(({theme:e})=>({left:0,right:0,lineHeight:e.lineHeights.tight,paddingTop:e.spacing.md,paddingLeft:e.spacing.lg,paddingRight:e.spacing.lg})),ye=d("ul",{target:"e17y52ym6"})(({theme:e})=>({listStyleType:"none",margin:e.spacing.none,padding:e.spacing.none})),E=d("li",{target:"e17y52ym7"})(({theme:e})=>({margin:e.spacing.none,padding:e.spacing.none})),A=d("div",{target:"e17y52ym8"})(({theme:e})=>({display:"flex",alignItems:"baseline",flex:1,paddingLeft:e.spacing.lg,overflow:"hidden"})),W=d("div",{target:"e17y52ym9"})(({theme:e})=>({marginRight:e.spacing.sm,marginBottom:e.spacing.twoXS,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),k=d("div",{target:"e17y52ym10"})(({theme:e})=>({display:"flex",alignItems:"center",marginBottom:e.spacing.twoXS})),Fe=d("span",{target:"e17y52ym11"})(({theme:e})=>({marginRight:e.spacing.twoXS})),Se=d("div",{target:"e17y52ym12"})(({theme:e})=>({display:"flex",padding:e.spacing.twoXS,color:e.colors.darkenedBgMix100})),N=d("small",{target:"e17y52ym13"})(({theme:e})=>({color:e.colors.danger,fontSize:e.fontSizes.sm,height:e.fontSizes.sm,lineHeight:e.fontSizes.sm,display:"flex",alignItems:"center",whiteSpace:"nowrap"})),R=d("span",{target:"e17y52ym14"})({}),Ue=e=>({[V]:{display:"flex",flexDirection:"column",alignItems:"flex-start"},[D]:{marginBottom:e.spacing.lg},[P]:{display:"none"},[L]:{paddingRight:e.spacing.lg},[k]:{maxWidth:"inherit",flex:1,alignItems:"flex-start",marginBottom:e.spacing.sm},[W]:{width:e.sizes.full},[A]:{flexDirection:"column"},[N]:{height:"auto",whiteSpace:"initial"},[R]:{display:"none"},[E]:{margin:e.spacing.none,padding:e.spacing.none}}),we=d("div",{target:"e17y52ym15"})(({theme:e,width:s})=>{if(s<$("23rem"))return Ue(e)});var v;(function(e){e.DANGER="danger"})(v||(v={}));const x=d("small",{target:"ejh2rmr0"})(({kind:e,theme:s})=>{const{danger:t,fadedText60:i}=s.colors;return{color:e==="danger"?t:i,fontSize:s.fontSizes.sm,lineHeight:s.lineHeights.tight}}),xe=({multiple:e,acceptedExtensions:s,maxSizeBytes:t})=>p(D,{"data-testid":"stFileUploaderDropzoneInstructions",children:[n(P,{children:n(m,{content:M,size:"threeXL"})}),p(fe,{children:[p(me,{children:["Drag and drop file",e?"s":""," here"]}),p(x,{children:[`Limit ${w(t,f.Byte,0)} per file`,s.length?` • ${s.map(i=>i.replace(/^\./,"").toUpperCase()).join(", ")}`:null]})]})]}),Ie=({onDrop:e,multiple:s,acceptedExtensions:t,maxSizeBytes:i,disabled:l,label:o})=>n(re,{onDrop:e,multiple:s,accept:oe(t),maxSize:i,disabled:l,useFsAccessApi:!1,children:({getRootProps:a,getInputProps:r})=>p(V,{...a(),"data-testid":"stFileUploaderDropzone",isDisabled:l,"aria-label":o,children:[n("input",{"data-testid":"stFileUploaderDropzoneInput",...r()}),n(xe,{multiple:s,acceptedExtensions:t,maxSizeBytes:i}),n(F,{kind:S.SECONDARY,disabled:l,size:O.SMALL,children:"Browse files"})]})}),ve=d("div",{target:"egc9vxm0"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:e.spacing.twoXS,marginBottom:e.spacing.twoXS})),ze=d("div",{target:"egc9vxm1"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.colors.fadedText40})),Ce=({currentPage:e,totalPages:s,onNext:t,onPrevious:i})=>p(ve,{"data-testid":"stFileUploaderPagination",children:[n(x,{children:`Showing page ${e} of ${s}`}),p(ze,{children:[n(F,{onClick:i,kind:S.MINIMAL,children:n(m,{content:q,size:"xl"})}),n(F,{onClick:t,kind:S.MINIMAL,children:n(m,{content:G,size:"xl"})})]})]}),z=(e,s)=>Math.ceil(e.length/s),be=e=>_(({pageSize:t,items:i,resetOnAdd:l,...o})=>{const[a,r]=g.useState(0),[c,U]=g.useState(z(i,t)),u=he(i);g.useEffect(()=>{u&&u.length!==i.length&&U(z(i,t)),u&&u.length<i.length?l&&r(0):a+1>=c&&r(c-1)},[i,a,t,u,l,c]);const T=()=>{r(Math.min(a+1,c-1))},H=()=>{r(Math.max(0,a-1))},X=i.slice(a*t,a*t+t);return p(K,{children:[n(e,{items:X,...o}),i.length>t?n(Ce,{pageSize:t,totalPages:c,currentPage:a+1,onNext:T,onPrevious:H}):null]})},e),Me=({fileInfo:e})=>e.status.type==="uploading"?n(ue,{value:e.status.progress,size:ge.SMALL}):e.status.type==="error"?p(N,{children:[n(Fe,{"data-testid":"stFileUploaderFileErrorMessage",children:e.status.errorMessage}),n(R,{children:n(m,{content:B,size:"lg"})})]}):e.status.type==="uploaded"?n(x,{children:w(e.size,f.Byte)}):null,Be=({fileInfo:e,onDelete:s})=>p(k,{className:"stFileUploaderFile","data-testid":"stFileUploaderFile",children:[n(Se,{children:n(m,{content:de,size:"twoXL"})}),p(A,{className:"stFileUploaderFileData",children:[n(W,{className:"stFileUploaderFileName","data-testid":"stFileUploaderFileName",title:e.name,children:e.name}),n(Me,{fileInfo:e})]}),n("div",{"data-testid":"stFileUploaderDeleteBtn",children:n(F,{onClick:()=>s(e.id),kind:S.MINIMAL,children:n(m,{content:ce,size:"lg"})})})]}),Ve=({items:e,onDelete:s})=>n(ye,{children:e.map(t=>n(E,{children:n(Be,{fileInfo:t,onDelete:s})},t.id))}),De=be(Ve),Pe=e=>n(L,{children:n(De,{...e})});class Le extends Y.PureComponent{constructor(s){super(s),this.formClearHelper=new ne,this.localFileIdCounter=1,this.forceUpdatingStatus=!1,this.componentDidUpdate=()=>{if(this.status!=="ready")return;const t=this.createWidgetValue(),{element:i,widgetMgr:l,fragmentId:o}=this.props,a=l.getFileUploaderStateValue(i);Z(t,a)||l.setFileUploaderStateValue(i,t,{fromUi:!0},o)},this.reset=()=>{this.setState({files:[]})},this.dropHandler=(t,i)=>{const{element:l}=this.props,{multipleFiles:o}=l;if(!o&&t.length===0&&i.length>1){const a=i.findIndex(r=>r.errors.length===1&&r.errors[0].code==="too-many-files");a>=0&&(t.push(i[a].file),i.splice(a,1))}if(this.props.uploadClient.fetchFileURLs(t).then(a=>{if(!o&&t.length>0){const r=this.state.files.find(c=>c.status.type!=="error");r&&(this.forceUpdatingStatus=!0,this.deleteFile(r.id),this.forceUpdatingStatus=!1)}J(a,t).forEach(([r,c])=>{this.uploadFile(r,c)})}).catch(a=>{this.addFiles(t.map(r=>new y(r.name,r.size,this.nextLocalFileId(),{type:"error",errorMessage:a})))}),i.length>0){const a=i.map(r=>{const{file:c}=r;return new y(c.name,c.size,this.nextLocalFileId(),{type:"error",errorMessage:this.getErrorMessage(r.errors[0].code,r.file)})});this.addFiles(a)}},this.uploadFile=(t,i)=>{const l=I.CancelToken.source(),o=new y(i.name,i.size,this.nextLocalFileId(),{type:"uploading",cancelToken:l,progress:1});this.addFile(o),this.props.uploadClient.uploadFile(this.props.element,t.uploadUrl,i,a=>this.onUploadProgress(a,o.id),l.token).then(()=>this.onUploadComplete(o.id,t)).catch(a=>{I.isCancel(a)||this.updateFile(o.id,o.setStatus({type:"error",errorMessage:a?a.toString():"Unknown error"}))})},this.onUploadComplete=(t,i)=>{const l=this.getFile(t);h(l)||l.status.type!=="uploading"||this.updateFile(l.id,l.setStatus({type:"uploaded",fileId:i.fileId,fileUrls:i}))},this.getErrorMessage=(t,i)=>{switch(t){case"file-too-large":return`File must be ${w(this.maxUploadSizeInBytes,f.Byte)} or smaller.`;case"file-invalid-type":return`${i.type} files are not allowed.`;case"file-too-small":return"File size is too small.";case"too-many-files":return"Only one file is allowed.";default:return"Unexpected error. Please try again."}},this.deleteFile=t=>{const i=this.getFile(t);h(i)||(i.status.type==="uploading"&&i.status.cancelToken.cancel(),i.status.type==="uploaded"&&i.status.fileUrls.deleteUrl&&this.props.uploadClient.deleteFile(i.status.fileUrls.deleteUrl),this.removeFile(t))},this.addFile=t=>{this.setState(i=>({files:[...i.files,t]}))},this.addFiles=t=>{this.setState(i=>({files:[...i.files,...t]}))},this.removeFile=t=>{this.setState(i=>({files:i.files.filter(l=>l.id!==t)}))},this.getFile=t=>this.state.files.find(i=>i.id===t),this.updateFile=(t,i)=>{this.setState(l=>({files:l.files.map(o=>o.id===t?i:o)}))},this.onUploadProgress=(t,i)=>{const l=this.getFile(i);if(h(l)||l.status.type!=="uploading")return;const o=Math.round(t.loaded*100/t.total);l.status.progress!==o&&this.updateFile(i,l.setStatus({type:"uploading",cancelToken:l.status.cancelToken,progress:o}))},this.onFormCleared=()=>{this.setState({files:[]},()=>{const t=this.createWidgetValue();if(h(t))return;const{widgetMgr:i,element:l,fragmentId:o}=this.props;i.setFileUploaderStateValue(l,t,{fromUi:!0},o)})},this.state=this.initialValue}get initialValue(){const s={files:[],newestServerFileId:0},{widgetMgr:t,element:i}=this.props,l=t.getFileUploaderStateValue(i);if(h(l))return s;const{uploadedFileInfo:o}=l;return h(o)||o.length===0?s:{files:o.map(a=>{const r=a.name,c=a.size,U=a.fileId,u=a.fileUrls;return new y(r,c,this.nextLocalFileId(),{type:"uploaded",fileId:U,fileUrls:u})})}}componentWillUnmount(){this.formClearHelper.disconnect()}get maxUploadSizeInBytes(){const s=this.props.element.maxUploadSizeMb;return pe(s,f.Megabyte,f.Byte)}get status(){const s=t=>t.status.type==="uploading";return this.state.files.some(s)||this.forceUpdatingStatus?"updating":"ready"}componentDidMount(){const s=this.createWidgetValue(),{element:t,widgetMgr:i,fragmentId:l}=this.props;i.getFileUploaderStateValue(t)===void 0&&i.setFileUploaderStateValue(t,s,{fromUi:!1},l)}createWidgetValue(){const s=this.state.files.filter(t=>t.status.type==="uploaded").map(t=>{const{name:i,size:l,status:o}=t,{fileId:a,fileUrls:r}=o;return new Q({fileId:a,fileUrls:r,name:i,size:l})});return new ee({uploadedFileInfo:s})}render(){var c;const{files:s}=this.state,{element:t,disabled:i,widgetMgr:l,width:o}=this.props,a=t.type;this.formClearHelper.manageFormClearListener(l,t.formId,this.onFormCleared);const r=s.slice().reverse();return p(we,{className:"stFileUploader","data-testid":"stFileUploader",width:o,children:[n(ae,{label:t.label,disabled:i,labelVisibility:te((c=t.labelVisibility)==null?void 0:c.value),children:t.help&&n(ie,{children:n(se,{content:t.help,placement:le.TOP_RIGHT})})}),n(Ie,{onDrop:this.dropHandler,multiple:t.multipleFiles,acceptedExtensions:a,maxSizeBytes:this.maxUploadSizeInBytes,label:t.label,disabled:i}),r.length>0&&n(Pe,{items:r,pageSize:3,onDelete:this.deleteFile,resetOnAdd:!0})]})}nextLocalFileId(){return this.localFileIdCounter++}}const He=j(g.memo(Le));export{He as default};