streamlit-nightly 1.42.3.dev20250226__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.
- streamlit/commands/navigation.py +16 -4
- streamlit/commands/page_config.py +1 -2
- streamlit/elements/widgets/button.py +5 -7
- streamlit/elements/widgets/chat.py +2 -1
- streamlit/errors.py +11 -9
- streamlit/navigation/page.py +2 -10
- streamlit/proto/ChatInput_pb2.py +6 -6
- streamlit/proto/ChatInput_pb2.pyi +5 -1
- streamlit/proto/ForwardMsg_pb2.py +12 -10
- streamlit/proto/PagesChanged_pb2.pyi +3 -1
- streamlit/runtime/app_session.py +1 -13
- streamlit/runtime/pages_manager.py +61 -232
- streamlit/runtime/scriptrunner/script_runner.py +49 -2
- streamlit/runtime/scriptrunner_utils/script_run_context.py +1 -1
- streamlit/source_util.py +4 -90
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{FileDownload.esm.CWn5B5ZN.js → FileDownload.esm.rdZtCw5-.js} +1 -1
- streamlit/static/static/js/FileHelper.BztOEKJy.js +5 -0
- streamlit/static/static/js/{FormClearHelper.BlCIuWCo.js → FormClearHelper.Drd1fMJc.js} +1 -1
- streamlit/static/static/js/{Hooks.DURid8_V.js → Hooks.DWd0hyk4.js} +1 -1
- streamlit/static/static/js/{InputInstructions.gFFpIc6i.js → InputInstructions.B7xrWTG0.js} +1 -1
- streamlit/static/static/js/{ProgressBar.CtXtbXhv.js → ProgressBar.CBgJiTH-.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.DKWNQmbm.js → RenderInPortalIfExists.US28tQOn.js} +1 -1
- streamlit/static/static/js/{Toolbar.CKKwksQV.js → Toolbar.CAOt-xaL.js} +1 -1
- streamlit/static/static/js/{base-input.BUY9TLqO.js → base-input.CauNaJqr.js} +1 -1
- streamlit/static/static/js/{checkbox.C4L_5Z9H.js → checkbox.ChzWCtre.js} +1 -1
- streamlit/static/static/js/{createSuper.DprEKsA6.js → createSuper.D_39RJB6.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.BArvtwSg.js → data-grid-overlay-editor.rIelkOVS.js} +1 -1
- streamlit/static/static/js/{downloader.C5pxkE2v.js → downloader.Dz5I28nG.js} +1 -1
- streamlit/static/static/js/{es6.DmKjMqyQ.js → es6.DwnEjMMn.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.DhqbXIl1.js → iframeResizer.contentWindow.BRiRifwd.js} +1 -1
- streamlit/static/static/js/{index.BEnZZwfW.js → index.BE6MTF-B.js} +1 -1
- streamlit/static/static/js/{index.c_V1HXTs.js → index.BUdhIGhT.js} +1 -1
- streamlit/static/static/js/{index.B-S4HX7x.js → index.BWeYb5ES.js} +1 -1
- streamlit/static/static/js/{index.CTqvpoOz.js → index.Bb4OB39A.js} +1 -1
- streamlit/static/static/js/{index.BoBCblDb.js → index.BrAW6bFJ.js} +1 -1
- streamlit/static/static/js/{index.CXpOPWFV.js → index.CAHGh74D.js} +1 -1
- streamlit/static/static/js/{index.UE_L1IEZ.js → index.CBre8Aui.js} +1 -1
- streamlit/static/static/js/{index.B-vrwvgD.js → index.CM12P2T1.js} +1 -1
- streamlit/static/static/js/{index.Cd03IYkG.js → index.CO3dZWKG.js} +1 -1
- streamlit/static/static/js/{index.CvNhwseQ.js → index.CUz1_nAm.js} +1 -1
- streamlit/static/static/js/{index.BVHfAEko.js → index.C_C365T5.js} +1 -1
- streamlit/static/static/js/{index.NKOzzX__.js → index.CmYiLKNX.js} +1 -1
- streamlit/static/static/js/{index.RFfgDsnM.js → index.CoUzNoRf.js} +1 -1
- streamlit/static/static/js/{index.RrEbViHi.js → index.Ct7MPsA3.js} +1 -1
- streamlit/static/static/js/{index.D2G24Udm.js → index.D1K6NCBQ.js} +1 -1
- streamlit/static/static/js/{index.CoQjULdH.js → index.D2xM-XzG.js} +1 -1
- streamlit/static/static/js/{index.D2-IYCcZ.js → index.D9rv1PQ0.js} +1 -1
- streamlit/static/static/js/{index.ChEJa75P.js → index.DIeegLbv.js} +1 -1
- streamlit/static/static/js/{index.oPGa5nFU.js → index.DJvwxFLn.js} +1 -1
- streamlit/static/static/js/{index.DtIKjlNZ.js → index.DKuQg2D4.js} +1 -1
- streamlit/static/static/js/{index.Bk3A478D.js → index.DWFLx6Tc.js} +6 -6
- streamlit/static/static/js/{index.WAlW9lgW.js → index.DYUhWSq6.js} +1 -1
- streamlit/static/static/js/{index.Bds7Anva.js → index.Db3jGJxa.js} +1 -1
- streamlit/static/static/js/{index.KPwXWqBk.js → index.DfNAkKAr.js} +145 -145
- streamlit/static/static/js/{index.EIkP6R_d.js → index.DgNQKEeQ.js} +1 -1
- streamlit/static/static/js/{index.BmnSGdtS.js → index.Dj91melR.js} +1 -1
- streamlit/static/static/js/{index.C3l2zbST.js → index.DkKZlAsv.js} +1 -1
- streamlit/static/static/js/index.DkgVNhWs.js +1 -0
- streamlit/static/static/js/{index.DNr2W0gq.js → index.Dzp8iBkF.js} +1 -1
- streamlit/static/static/js/index.LL2DLZZA.js +201 -0
- streamlit/static/static/js/index.ORHz8Y8P.js +4537 -0
- streamlit/static/static/js/{index.O5-Wn4Yr.js → index.V3Vj2d9m.js} +1 -1
- streamlit/static/static/js/{index.BUnWa5Cg.js → index.YNWoT4uW.js} +1 -1
- streamlit/static/static/js/index.aL_kqyvR.js +1 -0
- streamlit/static/static/js/{index.BSczaRDm.js → index.fP6rBxlc.js} +1 -1
- streamlit/static/static/js/{index.xTncca7J.js → index.pvQjxG7y.js} +1 -1
- streamlit/static/static/js/{index.doRPQ8od.js → index.wxpL02VY.js} +1 -1
- streamlit/static/static/js/{input.EkJ_AsTP.js → input.D_dn5-2t.js} +1 -1
- streamlit/static/static/js/{memory.BFs17dZE.js → memory.pnMTtWQR.js} +1 -1
- streamlit/static/static/js/{mergeWith.B4u0whL-.js → mergeWith.CRrYodeI.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.DwazN43x.js → number-overlay-editor.C65GBS2P.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.CZfYLVBb.js → possibleConstructorReturn.BnQk7lq_.js} +1 -1
- streamlit/static/static/js/{sandbox.PjijA1v1.js → sandbox.CrxXt1li.js} +1 -1
- streamlit/static/static/js/{textarea.BGGnQXtw.js → textarea.DiFyO5JY.js} +1 -1
- streamlit/static/static/js/{timepicker.eLEnk1tw.js → timepicker.B1Y7LIk4.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.CgKj9NUY.js → toConsumableArray.BWpBUK-j.js} +1 -1
- streamlit/static/static/js/{uniqueId.CPmOGhdZ.js → uniqueId.7ecIUkUs.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.Bw_fxTtX.js → useBasicWidgetState.deG0KPm0.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.D8qi7pm4.js → useOnInputChange.CQ7sD7CO.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.BjVufR9b.js → withFullScreenWrapper.D0wnBu3k.js} +1 -1
- streamlit/testing/v1/app_test.py +8 -10
- {streamlit_nightly-1.42.3.dev20250226.dist-info → streamlit_nightly-1.42.3.dev20250227.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.42.3.dev20250226.dist-info → streamlit_nightly-1.42.3.dev20250227.dist-info}/RECORD +88 -88
- streamlit/static/static/js/FileHelper.Bii_mi1A.js +0 -5
- streamlit/static/static/js/index.BAfr2RC0.js +0 -3865
- streamlit/static/static/js/index.BCErGZwr.js +0 -1
- streamlit/static/static/js/index.DhcYAj3f.js +0 -1
- streamlit/static/static/js/index.u1gL_Cm_.js +0 -201
- {streamlit_nightly-1.42.3.dev20250226.data → streamlit_nightly-1.42.3.dev20250227.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.42.3.dev20250226.dist-info → streamlit_nightly-1.42.3.dev20250227.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.42.3.dev20250226.dist-info → streamlit_nightly-1.42.3.dev20250227.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.42.3.dev20250226.dist-info → streamlit_nightly-1.42.3.dev20250227.dist-info}/top_level.txt +0 -0
@@ -1 +0,0 @@
|
|
1
|
-
import{r as s,E as $,_ as N,n as u,A as ht,y as j,j as n,ba as J,bv as ft,B as S,bq as Q,b5 as Z,bp as U,a$ as mt,bG as vt,bk as yt,bH as I,bt as wt,F as tt,bh as Ct,bI as It,L,bm as xt,bl as bt}from"./index.KPwXWqBk.js";import{g as St,F as zt,C as Ft,I as Et,E as Ut,u as Ht,a as Tt}from"./FileHelper.Bii_mi1A.js";import{I as Dt}from"./InputInstructions.gFFpIc6i.js";import{i as Bt}from"./inputUtils.CQWz5UKz.js";import{a as Y}from"./index.DW_MHI2K.js";import{U as V}from"./UploadFileInfo.C-jY39rj.js";import{T as Lt}from"./textarea.BGGnQXtw.js";import"./base-input.BUY9TLqO.js";var et=s.forwardRef(function(t,e){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return s.createElement($,N({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),s.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),s.createElement("path",{d:"M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5a2.5 2.5 0 015 0v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5a2.5 2.5 0 005 0V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z"}))});et.displayName="AttachFile";var ot=s.forwardRef(function(t,e){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return s.createElement($,N({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),s.createElement("path",{d:"M11 15h2v2h-2v-2zm0-8h2v6h-2V7zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}))});ot.displayName="ErrorOutline";var nt=s.forwardRef(function(t,e){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return s.createElement($,N({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),s.createElement("rect",{width:24,height:24,fill:"none"}),s.createElement("path",{d:"M3 5.51v3.71c0 .46.31.86.76.97L11 12l-7.24 1.81c-.45.11-.76.51-.76.97v3.71c0 .72.73 1.2 1.39.92l15.42-6.49c.82-.34.82-1.5 0-1.84L4.39 4.58C3.73 4.31 3 4.79 3 5.51z"}))});nt.displayName="Send";const Rt=u("div",{target:"e1togvvn0"})("border:none;position:relative;display:flex;"),kt=u("div",{target:"e1togvvn1"})(({theme:t,extended:e})=>({border:`${t.sizes.borderWidth} solid`,borderColor:t.colors.widgetBorderColor??t.colors.transparent,borderRadius:t.radii.chatInput,backgroundColor:t.colors.secondaryBg,position:"relative",flexGrow:1,display:"flex",alignItems:"center",paddingLeft:t.spacing.lg,maxHeight:e?"none":t.sizes.minElementHeight,gap:t.spacing.sm,overflow:"hidden",":focus-within":{borderColor:t.colors.primary}})),Mt=u("button",{target:"e1togvvn2"})(({theme:t,disabled:e,extended:l})=>{const d=ht(t),[f,g]=d?[t.colors.gray60,t.colors.gray80]:[t.colors.gray80,t.colors.gray40];return{border:"none",backgroundColor:t.colors.transparent,borderTopRightRadius:l?"0":t.radii.chatInput,borderTopLeftRadius:l?t.radii.default:"0",borderBottomRightRadius:t.radii.chatInput,display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:t.lineHeights.none,margin:t.spacing.none,padding:t.spacing.sm,color:e?f:g,pointerEvents:"auto","&:focus":{outline:"none"},":focus":{outline:"none"},"&:focus-visible":{backgroundColor:d?t.colors.gray10:t.colors.gray90},"&:hover":{color:t.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{backgroundColor:t.colors.transparent,borderColor:t.colors.transparent,color:t.colors.gray,cursor:"not-allowed"}}}),Vt=u("div",{target:"e1togvvn3"})(({theme:t})=>({display:"flex",alignItems:"flex-end",height:"100%",position:"absolute",right:0,marginBottom:`-${t.sizes.borderWidth}`,pointerEvents:"none"})),$t=u("div",{target:"e1togvvn4"})(({theme:t})=>({position:"absolute",bottom:"0px",right:`calc(${t.iconSizes.xl} + 2 * ${t.spacing.sm} + ${t.spacing.sm})`})),Nt=u("div",{target:"ewqvugz0"})(({theme:t,height:e})=>({backgroundColor:t.colors.transparent,position:"absolute",left:0,bottom:0,minHeight:`max(${t.sizes.emptyDropdownHeight}, ${e})`,width:"100%",zIndex:t.zIndices.priority})),At=u("div",{target:"ewqvugz1"})(({theme:t,height:e})=>({border:`${t.sizes.borderWidth} solid`,borderColor:t.colors.primary,borderRadius:t.radii.chatInput,backgroundColor:t.colors.secondaryBg,color:t.colors.primary,display:"flex",alignItems:"center",justifyContent:"center",height:e,width:"100%",fontWeight:t.fontWeights.bold})),Wt=u("div",{target:"ewqvugz2"})(({theme:t,disabled:e})=>({display:"flex",alignItems:"top",height:"100%",marginTop:`-${t.sizes.borderWidth}`,cursor:e?"not-allowed":"auto"})),qt=u("div",{target:"ewqvugz3"})(({disabled:t})=>({pointerEvents:t?"none":"auto"})),Pt=u("div",{target:"ewqvugz4"})(({theme:t})=>({marginTop:"0.625em",marginLeft:t.spacing.sm,height:t.spacing.xl,width:t.sizes.borderWidth,backgroundColor:t.colors.fadedText20})),Ot=u("div",{target:"ewqvugz5"})(({theme:t})=>({left:0,right:0,lineHeight:t.lineHeights.tight,paddingLeft:t.spacing.sm,paddingRight:t.spacing.sm,overflowX:"auto"})),Kt=u("div",{target:"ewqvugz6"})(({})=>({display:"flex"})),_t=u("div",{target:"ewqvugz7"})(({})=>({flex:"0 0 auto"})),Xt=u("div",{target:"ewqvugz8"})(({theme:t})=>({display:"flex",alignItems:"center",padding:t.spacing.sm,gap:t.spacing.twoXS})),Gt=u("div",{target:"ewqvugz9"})(({theme:t})=>({color:t.colors.fadedText60})),Yt=u("div",{target:"ewqvugz10"})(({theme:t,fileStatus:e})=>({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:e.type==="uploaded"?t.colors.bodyText:t.colors.fadedText60})),jt=u("div",{target:"ewqvugz11"})(({theme:t})=>({marginRight:t.spacing.md,color:t.colors.fadedText60})),Jt=u("small",{target:"ewqvugz12"})(({theme:t})=>({display:"flex",alignItems:"center",maxHeight:t.sizes.smallElementHeight,color:t.colors.fadedText60,"& :hover":{color:t.colors.bodyText}}));function Qt({children:t,content:e}){const l=j();return n(ft,{content:e,placement:J.TOP,overrides:{Body:{style:{top:`-${l.sizes.minElementHeight}`}}},children:t})}const Zt=({fileInfo:t})=>{const{type:e}=t.status;switch(e){case"uploading":return n(vt,{usingCustomTheme:!1,"data-testid":"stChatInputFileIconSpinner",size:"lg",margin:"0",padding:"0"});case"error":return n(Qt,{content:t.status.errorMessage,children:n(U,{content:ot,size:"lg"})});case"uploaded":return n(U,{content:Et,size:"lg"});default:return mt(e),null}},te=({fileInfo:t,onDelete:e})=>S(Xt,{className:"stChatInputFile","data-testid":"stChatInputFile",children:[n(Gt,{children:n(Zt,{fileInfo:t})}),n(Yt,{className:"stChatInputFileName","data-testid":"stChatInputFileName",title:t.name,fileStatus:t.status,children:t.name}),n(jt,{children:St(t.size,zt.Byte)}),n(Jt,{"data-testid":"stChatInputDeleteBtn",children:n(Q,{onClick:()=>e(t.id),kind:Z.MINIMAL,children:n(U,{content:Ft,size:"lg"})})})]}),ee=({items:t,onDelete:e})=>n(Ot,{"data-testid":"stChatUploadedFiles",children:n(Kt,{children:t.map(l=>n(_t,{children:n(te,{fileInfo:l,onDelete:e})},l.id))})}),oe=({getNextLocalFileId:t,addFiles:e,updateFile:l,uploadClient:d,element:f,onUploadProgress:g,onUploadComplete:m})=>(y,h)=>{const v=Y.CancelToken.source(),c=new V(h.name,h.size,t(),{type:"uploading",cancelToken:v,progress:1});e([c]),d.uploadFile({formId:"",...f},y.uploadUrl,h,p=>g(p,c.id),v.token).then(()=>m(c.id,y)).catch(p=>{Y.isCancel(p)||l(c.id,c.setStatus({type:"error",errorMessage:p?p.toString():"Unknown error"}))})},ne=({acceptMultipleFiles:t,uploadClient:e,uploadFile:l,addFiles:d,getNextLocalFileId:f,deleteExistingFiles:g,onUploadComplete:m})=>(y,h)=>{if(!t&&y.length===0&&h.length>1){const v=h.findIndex(c=>{var p;return((p=c.errors)==null?void 0:p[0].code)===Ut.TooManyFiles});v>=0&&(y.push(h[v].file),h.splice(v,1))}if(!t&&y.length>0&&g(),e.fetchFileURLs(y).then(v=>{yt(v,y).forEach(([c,p])=>{l(c,p)})}).catch(v=>{d(y.map(c=>new V(c.name,c.size,f(),{type:"error",errorMessage:v})))}),h.length>0){const v=h.map(c=>new V(c.file.name,c.file.size,f(),{type:"error",errorMessage:c.errors.map(p=>p.message).filter(p=>!!p).join(", ")}));d(v)}m()},re=({getRootProps:t,getInputProps:e,acceptFile:l,disabled:d,theme:f})=>S(Wt,{disabled:d,children:[S(qt,{"data-testid":"stChatInputFileUploadButton",disabled:d,...t(),children:[n("input",{...e()}),n(wt,{content:`Upload or drag and drop ${l===I.Multiple?"files":"a file"}`,placement:J.TOP,onMouseEnterDelay:500,children:n(Q,{kind:Z.MINIMAL,disabled:d,children:n(U,{content:et,size:"lg",color:d?f.colors.fadedText40:f.colors.fadedText60})})})]}),n(Pt,{})]}),ae=({getRootProps:t,getInputProps:e,acceptFile:l,inputHeight:d})=>S(tt,{children:[n(Nt,{height:d,...t(),children:n("input",{...e()})}),n(At,{height:d,children:`Drag and drop ${l===I.Multiple?"files":"a file"} here`})]}),ie=6.5,R=1,k=(t,e,l)=>l.map(d=>d.id===t?e:d),M=(t,e)=>e.find(l=>l.id===t);function se({disabled:t,element:e,widgetMgr:l,fragmentId:d,uploadClient:f}){const g=j(),m=s.useRef(null),y=s.useRef(0),h=s.useRef({minHeight:0,maxHeight:0}),{values:[v],elementRef:c}=Ct(s.useMemo(()=>["width"],[])),[p,T]=s.useState(!1),[z,D]=s.useState(e.default),[F,A]=s.useState(0),[H,rt]=s.useState(!1),[x,b]=s.useState([]),[E,B]=s.useState(!1),C=It(e.acceptFile),W=s.useCallback(o=>b(r=>[...r,...o]),[]),q=s.useCallback(o=>{b(r=>{const i=M(o,r);return L(i)?r:(i.status.type==="uploading"&&i.status.cancelToken.cancel(),i.status.type==="uploaded"&&i.status.fileUrls.deleteUrl&&f.deleteFile(i.status.fileUrls.deleteUrl),r.filter(a=>a.id!==o))})},[f]),at=()=>{const o=x.filter(r=>r.status.type==="uploaded").map(r=>{const{name:i,size:a,status:w}=r,{fileId:ut,fileUrls:gt}=w;return new xt({fileId:ut,fileUrls:gt,name:i,size:a})});return new bt({uploadedFileInfo:o})},P=()=>y.current++,it=ne({acceptMultipleFiles:C===I.Multiple,uploadClient:f,uploadFile:oe({getNextLocalFileId:P,addFiles:W,updateFile:(o,r)=>{b(i=>k(o,r,i))},uploadClient:f,element:e,onUploadProgress:(o,r)=>{b(i=>{const a=M(r,i);if(L(a)||a.status.type!=="uploading")return i;const w=Math.round(o.loaded*100/o.total);return a.status.progress===w?i:k(r,a.setStatus({type:"uploading",cancelToken:a.status.cancelToken,progress:w}),i)})},onUploadComplete:(o,r)=>{b(i=>{const a=M(o,i);return L(a)||a.status.type!=="uploading"?i:k(a.id,a.setStatus({type:"uploaded",fileId:r.fileId,fileUrls:r}),i)})}}),addFiles:W,getNextLocalFileId:P,deleteExistingFiles:()=>x.forEach(o=>q(o.id)),onUploadComplete:()=>{m.current&&m.current.focus()}}),{getRootProps:O,getInputProps:K}=Ht({onDrop:it,multiple:C===I.Multiple,accept:Tt(e.fileType)}),st=()=>{let o=0;const{current:r}=m;if(r){const i=r.placeholder;r.placeholder="",r.style.height="auto",o=r.scrollHeight,r.placeholder=i,r.style.height=""}return o},_=()=>{if(m.current&&m.current.focus(),!p||t)return;const o={data:z,fileUploaderState:at()};l.setChatInputValue(e,o,{fromUi:!0},d),T(!1),b([]),D(""),A(0)},lt=o=>{const{metaKey:r,ctrlKey:i,shiftKey:a}=o;Bt(o)&&!a&&!i&&!r&&(o.preventDefault(),_())},dt=o=>{const{value:r}=o.target,{maxChars:i}=e;i!==0&&r.length>i||(D(r),A(st()))};s.useEffect(()=>x.some(o=>o.status.type==="uploading")?T(!1):T(z!==""||x.length>0),[x,z]),s.useEffect(()=>{if(e.setValue){e.setValue=!1;const o=e.value||"";D(o)}},[e]),s.useEffect(()=>{if(m.current){const{offsetHeight:o}=m.current;h.current.minHeight=o,h.current.maxHeight=o*ie}},[m]),s.useEffect(()=>{const o=a=>{var w;a.preventDefault(),a.stopPropagation(),!E&&((w=a.dataTransfer)!=null&&w.types.includes("Files"))&&B(!0)},r=a=>{a.preventDefault(),a.stopPropagation(),E&&(a.clientX<=0&&a.clientY<=0||a.clientX>=window.innerWidth&&a.clientY>=window.innerHeight)&&B(!1)},i=a=>{a.preventDefault(),a.stopPropagation(),E&&B(!1)};return window.addEventListener("dragover",o),window.addEventListener("drop",i),window.addEventListener("dragleave",r),()=>{window.removeEventListener("dragover",o),window.removeEventListener("drop",i),window.removeEventListener("dragleave",r)}},[E]),s.useEffect(()=>{const{minHeight:o}=h.current;rt(F>0&&m.current?Math.abs(F-o)>R:!1)},[F]);const{placeholder:X,maxChars:ct}=e,{maxHeight:G}=h.current,pt=C!==I.None&&E;return S(tt,{children:[C===I.None?null:n(ee,{items:[...x],onDelete:q}),n(Rt,{className:"stChatInput","data-testid":"stChatInput",ref:c,children:pt?n(ae,{getRootProps:O,getInputProps:K,acceptFile:C,inputHeight:H?`${F+R}px`:g.sizes.minElementHeight}):S(kt,{extended:H,children:[C===I.None?null:n(re,{getRootProps:O,getInputProps:K,acceptFile:C,disabled:t,theme:g}),n(Lt,{inputRef:m,value:z,placeholder:X,onChange:dt,onKeyDown:lt,"aria-label":X,disabled:t,rows:1,overrides:{Root:{style:{minHeight:g.sizes.minElementHeight,outline:"none",borderLeftWidth:"0",borderRightWidth:"0",borderTopWidth:"0",borderBottomWidth:"0"}},Input:{props:{"data-testid":"stChatInputTextArea"},style:{lineHeight:g.lineHeights.inputWidget,"::placeholder":{opacity:"0.7"},height:H?`${F+R}px`:"auto",maxHeight:G?`${G}px`:"none",paddingLeft:g.spacing.none,paddingBottom:g.spacing.sm,paddingTop:g.spacing.sm,paddingRight:`calc(${g.iconSizes.xl} + 2 * ${g.spacing.sm} + ${g.spacing.sm})`}}}}),v>g.breakpoints.hideWidgetDetails&&n($t,{children:n(Dt,{dirty:p,value:z,maxLength:ct,type:"chat",inForm:!1})}),n(Vt,{children:n(Mt,{onClick:_,disabled:!p||t,extended:H,"data-testid":"stChatInputSubmitButton",children:n(U,{content:nt,size:"xl",color:"inherit"})})})]})})]})}const me=s.memo(se);export{me as default};
|
@@ -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.KPwXWqBk.js";import{a as I}from"./index.DW_MHI2K.js";import{F as ne}from"./FormClearHelper.BlCIuWCo.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.Bii_mi1A.js";import{S as ge,P as ue}from"./ProgressBar.CtXtbXhv.js";import{u as he}from"./Hooks.DURid8_V.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};
|