streamlit-nightly 1.53.2.dev20260202__py3-none-any.whl → 1.53.2.dev20260203__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/logo.py +6 -10
- streamlit/components/v2/component_path_utils.py +17 -29
- streamlit/config.py +4 -2
- streamlit/path_security.py +98 -0
- streamlit/runtime/app_session.py +9 -1
- streamlit/static/index.html +1 -1
- streamlit/static/manifest.json +312 -312
- streamlit/static/static/js/{ErrorOutline.esm.CLuz0rSD.js → ErrorOutline.esm.C9uHPmIj.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.CO68LcnZ.js → FileDownload.esm.D-YPxF3t.js} +1 -1
- streamlit/static/static/js/{FileHelper.DAXgY6Ug.js → FileHelper.DQSH0zYW.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.zxJ53Nym.js → FormClearHelper.DQoXcOWo.js} +1 -1
- streamlit/static/static/js/{InputInstructions.CCbg8esE.js → InputInstructions.C7VMyGT7.js} +1 -1
- streamlit/static/static/js/{Particles.BJw0A-zv.js → Particles.BdQSRZde.js} +1 -1
- streamlit/static/static/js/{ProgressBar.BrrHeAEh.js → ProgressBar.DNF_pWKr.js} +1 -1
- streamlit/static/static/js/{StreamlitSyntaxHighlighter.DvPLy3zk.js → StreamlitSyntaxHighlighter.Cys9Bt18.js} +2 -2
- streamlit/static/static/js/{TableChart.esm.BawvAi5p.js → TableChart.esm.B9SMgSK4.js} +1 -1
- streamlit/static/static/js/{Toolbar.CbpscbNb.js → Toolbar.BXfC9Z-W.js} +1 -1
- streamlit/static/static/js/{WidgetLabelHelpIconInline.DA4S2HFP.js → WidgetLabelHelpIconInline.gkreC55g.js} +1 -1
- streamlit/static/static/js/{base-input.BKKl2eBF.js → base-input.iB32RS3w.js} +4 -4
- streamlit/static/static/js/{checkbox.CB43AKV4.js → checkbox.Bqz68SYq.js} +1 -1
- streamlit/static/static/js/{createDownloadLinkElement.jVwF96ey.js → createDownloadLinkElement.YxVC9Qur.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.CxQizSv7.js → data-grid-overlay-editor.sBsdk5Xg.js} +1 -1
- streamlit/static/static/js/{downloader.CKlIgsy5.js → downloader.Bzxqt3AW.js} +1 -1
- streamlit/static/static/js/{embed.BhRb_2n8.js → embed.CDzakah3.js} +1 -1
- streamlit/static/static/js/{es6.DPyfPmWm.js → es6.CxCc4bfn.js} +2 -2
- streamlit/static/static/js/{formatNumber.DtfMnnPx.js → formatNumber.L8T7D36k.js} +1 -1
- streamlit/static/static/js/{iconPosition.DkZAlu_k.js → iconPosition.C47DkA-1.js} +1 -1
- streamlit/static/static/js/{iframeResizer.contentWindow.l5sQWLra.js → iframeResizer.contentWindow.uEFLXEg3.js} +1 -1
- streamlit/static/static/js/{index.DDr-BLbJ.js → index.B3zULhHv.js} +1 -1
- streamlit/static/static/js/{index.LjqoQCm5.js → index.B60AZFRh.js} +1 -1
- streamlit/static/static/js/{index.BzO83wKm.js → index.BG4RxMOI.js} +1 -1
- streamlit/static/static/js/{index.y5HxPwg9.js → index.BHyzKS4e.js} +20 -20
- streamlit/static/static/js/{index.Bc_FQ4Wb.js → index.BVTW_o-a.js} +1 -1
- streamlit/static/static/js/{index.BUlT_mOL.js → index.BV_YgIHe.js} +1 -1
- streamlit/static/static/js/{index.WIMtx3m0.js → index.B_LfkwqU.js} +1 -1
- streamlit/static/static/js/{index.DiBeetOH.js → index.Ba8L-ulI.js} +1 -1
- streamlit/static/static/js/{index.CsEZTo6L.js → index.Bh5BZaHG.js} +1 -1
- streamlit/static/static/js/{index.DmWUXdjc.js → index.Bnwh8oZr.js} +16 -16
- streamlit/static/static/js/{index.CAoX2tlo.js → index.BrZtYm2A.js} +1 -1
- streamlit/static/static/js/{index.Y9wPTZIf.js → index.BsrhCS7f.js} +1 -1
- streamlit/static/static/js/{index.465nmxtO.js → index.BuJPJSD7.js} +1 -1
- streamlit/static/static/js/{index.BAK0CG1Q.js → index.BvHsyiyy.js} +1 -1
- streamlit/static/static/js/{index.DzdPUxsx.js → index.BwTkGOAy.js} +1 -1
- streamlit/static/static/js/{index.yHLCvUGh.js → index.BwvxzVOo.js} +1 -1
- streamlit/static/static/js/{index.Ck64OQhV.js → index.BzdcdLDK.js} +1 -1
- streamlit/static/static/js/{index.CiS4giQ2.js → index.C1d2QjTR.js} +1 -1
- streamlit/static/static/js/{index.CaU3Uv_L.js → index.C1uZrWog.js} +1 -1
- streamlit/static/static/js/{index.FioS1Y9m.js → index.C5-TpWis.js} +1 -1
- streamlit/static/static/js/{index.rvbQETlC.js → index.C6dhwBSe.js} +1 -1
- streamlit/static/static/js/{index.e6Ry6-Ft.js → index.CAbQaUvi.js} +1 -1
- streamlit/static/static/js/{index.Dac9Jib-.js → index.CAbafj7s.js} +1 -1
- streamlit/static/static/js/{index.CL_icBXS.js → index.CCLteRW6.js} +1 -1
- streamlit/static/static/js/{index.OizPL4jg.js → index.CQ713nQM.js} +1 -1
- streamlit/static/static/js/index.CcBYyLfq.js +2 -0
- streamlit/static/static/js/{index.DKoJr0Se.js → index.CjBDVb1a.js} +1 -1
- streamlit/static/static/js/{index.BLD3tJ2C.js → index.Ck0ZkOfK.js} +1 -1
- streamlit/static/static/js/{index.Ccye_uLl.js → index.CzwJzgQs.js} +1 -1
- streamlit/static/static/js/{index.CL7it7tU.js → index.D-9VyyiA.js} +1 -1
- streamlit/static/static/js/{index.b_f-McZ5.js → index.D2R3Co5f.js} +1 -1
- streamlit/static/static/js/{index.L9pOjBEn.js → index.D7L9gHlE.js} +2 -2
- streamlit/static/static/js/{index.YutgmD9x.js → index.DEKnCsY-.js} +2 -2
- streamlit/static/static/js/{index.CmbqbRMZ.js → index.DHrByikW.js} +1 -1
- streamlit/static/static/js/{index.DZOGT9vX.js → index.DN_oudQl.js} +1 -1
- streamlit/static/static/js/{index.DjuMEZ6m.js → index.DO55kRo5.js} +1 -1
- streamlit/static/static/js/{index.6J1N4is3.js → index.D_cvtSlg.js} +1 -1
- streamlit/static/static/js/{index.AZ9T4EqJ.js → index.DgqmsDCJ.js} +1 -1
- streamlit/static/static/js/{index.CsIENsKH.js → index.DjgdCvlK.js} +1 -1
- streamlit/static/static/js/{index.y0h42OXL.js → index.DqhZqWYB.js} +1 -1
- streamlit/static/static/js/{index.CBbYMKZp.js → index.Dtbj_oyb.js} +1 -1
- streamlit/static/static/js/{index.Cwg8nWw5.js → index.QXukCzoh.js} +1 -1
- streamlit/static/static/js/{index.DR6V0uBJ.js → index.XJY9qZ6a.js} +1 -1
- streamlit/static/static/js/{index.D83azq2w.js → index.aZRhdEuX.js} +1 -1
- streamlit/static/static/js/{index.DpSc4e1j.js → index.fUsWkW8E.js} +1 -1
- streamlit/static/static/js/index.h2N-W51I.js +11 -0
- streamlit/static/static/js/{index.hnu9U-5g.js → index.iUHLeAvv.js} +1 -1
- streamlit/static/static/js/{index.BpCj2-sQ.js → index.kBgXO7Vv.js} +1 -1
- streamlit/static/static/js/{index.Q2t_iBn0.js → index.kEL0HsUR.js} +1 -1
- streamlit/static/static/js/{input.CAtwSQ27.js → input.BCHJn1Cw.js} +1 -1
- streamlit/static/static/js/{main.VeMVx6VI.js → main.23ZP6f1E.js} +1 -1
- streamlit/static/static/js/{memory.CxS_lIUn.js → memory.D8f8Q4mO.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.CoqRgZW_.js → number-overlay-editor.ZWvSpjJ5.js} +1 -1
- streamlit/static/static/js/{pandasStylerUtils.DGWgd5sM.js → pandasStylerUtils.DlZ2GBs_.js} +1 -1
- streamlit/static/static/js/{sandbox.2mSqEau0.js → sandbox.BH6D3KL9.js} +1 -1
- streamlit/static/static/js/{sprintfjs.CsoVVZ9k.js → sprintfjs.CtrdaGLQ.js} +1 -1
- streamlit/static/static/js/{styled-components.BShfh7J8.js → styled-components.iD1HRMLc.js} +1 -1
- streamlit/static/static/js/{throttle.Fq1DQK4p.js → throttle.DR7d9vp_.js} +1 -1
- streamlit/static/static/js/{timepicker.DmyY-qtn.js → timepicker.Bd34xjcG.js} +4 -4
- streamlit/static/static/js/{toConsumableArray.Dvd9AIqV.js → toConsumableArray.BDTTq1c5.js} +2 -2
- streamlit/static/static/js/uniqueId.Bd_Iuzvc.js +1 -0
- streamlit/static/static/js/useBasicWidgetState.BXKaD8DQ.js +1 -0
- streamlit/static/static/js/{useIntlLocale.kdIj0ego.js → useIntlLocale.CysOvegI.js} +1 -1
- streamlit/static/static/js/{useTextInputAutoExpand.DkuG1C1S.js → useTextInputAutoExpand.CVd5Hf2S.js} +1 -1
- streamlit/static/static/js/{useUpdateUiValue.-UI_JsjT.js → useUpdateUiValue.CIUgfO8X.js} +1 -1
- streamlit/static/static/js/{useWaveformController.C5PTwL6I.js → useWaveformController.CDLqlnLv.js} +1 -1
- streamlit/static/static/js/{withCalculatedWidth.BREyS0pJ.js → withCalculatedWidth.Ce1Zblb2.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.DYDiEOrW.js → withFullScreenWrapper.DBm7N75M.js} +1 -1
- streamlit/web/server/app_static_file_handler.py +9 -0
- streamlit/web/server/bidi_component_request_handler.py +4 -4
- streamlit/web/server/component_file_utils.py +14 -6
- streamlit/web/server/component_request_handler.py +2 -2
- streamlit/web/server/starlette/starlette_app.py +7 -1
- streamlit/web/server/starlette/starlette_path_security_middleware.py +97 -0
- streamlit/web/server/starlette/starlette_routes.py +6 -3
- streamlit/web/server/starlette/starlette_static_routes.py +14 -4
- {streamlit_nightly-1.53.2.dev20260202.dist-info → streamlit_nightly-1.53.2.dev20260203.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.53.2.dev20260202.dist-info → streamlit_nightly-1.53.2.dev20260203.dist-info}/RECORD +109 -107
- streamlit/static/static/js/index.C_19KWNs.js +0 -2
- streamlit/static/static/js/index.DL_ywOgf.js +0 -11
- streamlit/static/static/js/uniqueId.CCajdEK8.js +0 -1
- streamlit/static/static/js/useBasicWidgetState.COLQ5AFB.js +0 -1
- {streamlit_nightly-1.53.2.dev20260202.dist-info → streamlit_nightly-1.53.2.dev20260203.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.53.2.dev20260202.dist-info → streamlit_nightly-1.53.2.dev20260203.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.53.2.dev20260202.dist-info → streamlit_nightly-1.53.2.dev20260203.dist-info}/top_level.txt +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,E as L,_ as k,z as p,ac as Se,o as x,j as a,az as I,b as V,c as ve,B as M,h as Ue,$ as Ce,k as be,al as ee,bv as Ie,e as D,bZ as Ee,p as Be,ad as De,ae as Le,bS as ke,bT as Ve}from"./index.y5HxPwg9.js";import{u as Me}from"./FormClearHelper.zxJ53Nym.js";import{g as oe,F as R,a as Re,D as Ae,I as Pe,s as Ne,b as Te}from"./FileHelper.DAXgY6Ug.js";import{S as We,P as He}from"./ProgressBar.BrrHeAEh.js";import{U as j}from"./UploadFileInfo.Dr-zDST7.js";const $e=e=>{const t=o.useRef();return o.useEffect(()=>{t.current=e},[e]),t.current};var ne=o.forwardRef(function(e,t){var n={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(L,k({iconAttrs:n,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),o.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),o.createElement("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12l4.58-4.59z"}))});ne.displayName="ChevronLeft";var le=o.forwardRef(function(e,t){var n={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(L,k({iconAttrs:n,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),o.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),o.createElement("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z"}))});le.displayName="ChevronRight";var se=o.forwardRef(function(e,t){var n={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(L,k({iconAttrs:n,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),o.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),o.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"}))});se.displayName="Clear";var ae=o.forwardRef(function(e,t){var n={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(L,k({iconAttrs:n,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),o.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),o.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"}))});ae.displayName="CloudUpload";var ie=o.forwardRef(function(e,t){var n={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(L,k({iconAttrs:n,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),o.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"}))});ie.displayName="Error";const re=p("section",{target:"ewslnz90"})(({isDisabled:e,theme:t})=>({display:"flex",gap:t.spacing.lg,alignItems:"center",padding:t.spacing.lg,backgroundColor:t.colors.secondaryBg,borderRadius:t.radii.default,border:t.colors.widgetBorderColor?`${t.sizes.borderWidth} solid ${t.colors.widgetBorderColor}`:void 0,height:t.sizes.largestElementHeight,":focus":{outline:"none"},":focus-visible":{boxShadow:t.shadows.focusRingOutline},cursor:e?"not-allowed":"pointer"})),je=p("div",{target:"ewslnz91"})(({theme:e})=>({marginRight:"auto",alignItems:"center",display:"flex",gap:e.spacing.lg,minWidth:0,width:"100%"})),ce=p("span",{target:"ewslnz92"})(({theme:e})=>({color:e.colors.darkenedBgMix100})),de=p("span",{target:"ewslnz93"})(({theme:e,disabled:t})=>({color:t?e.colors.fadedText40:e.colors.bodyText})),Xe=p("span",{target:"ewslnz94"})(({theme:e,disabled:t})=>({fontSize:e.fontSizes.sm,color:t?e.colors.fadedText40:e.colors.fadedText60,display:"block",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",maxWidth:"100%"})),Oe=p("div",{target:"ewslnz95"})({display:"flex",flexDirection:"column",minWidth:0,maxWidth:"100%"}),qe=p("span",{target:"ewslnz96"})({whiteSpace:"nowrap"}),pe=p("div",{target:"ewslnz97"})(({theme:e})=>({left:0,right:0,lineHeight:e.lineHeights.tight,paddingTop:e.spacing.md,paddingLeft:e.spacing.lg,paddingRight:e.spacing.lg})),_e=p("ul",{target:"ewslnz98"})(({theme:e})=>({listStyleType:"none",margin:e.spacing.none,padding:e.spacing.none})),ue=p("li",{target:"ewslnz99"})(({theme:e})=>({margin:e.spacing.none,padding:e.spacing.none})),ge=p("div",{target:"ewslnz910"})(({theme:e})=>({display:"flex",alignItems:"baseline",flex:1,paddingLeft:e.spacing.lg,overflow:"hidden"})),fe=p("div",{target:"ewslnz911"})(({theme:e,disabled:t})=>({marginRight:e.spacing.sm,marginBottom:e.spacing.twoXS,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:t?e.colors.fadedText40:e.colors.bodyText})),he=p("div",{target:"ewslnz912"})(({theme:e})=>({display:"flex",alignItems:"center",marginBottom:e.spacing.twoXS})),Ke=p("span",{target:"ewslnz913"})(({theme:e})=>({marginRight:e.spacing.twoXS})),Ye=p("div",{target:"ewslnz914"})(({theme:e,disabled:t})=>({display:"flex",padding:e.spacing.twoXS,color:t?e.colors.fadedText40:e.colors.darkenedBgMix100})),Fe=p("small",{target:"ewslnz915"})(({theme:e})=>({color:e.colors.redTextColor,fontSize:e.fontSizes.sm,height:e.fontSizes.sm,lineHeight:e.fontSizes.sm,display:"flex",alignItems:"center",whiteSpace:"nowrap"})),me=p("span",{target:"ewslnz916"})({}),Ze=e=>({[re]:{display:"flex",flexDirection:"column",alignItems:"flex-start",height:"auto",gap:e.spacing.sm},[ce]:{display:"none"},[de]:{marginBottom:e.spacing.twoXS},[pe]:{paddingRight:e.spacing.lg},[he]:{maxWidth:"inherit",flex:1,alignItems:"flex-start",marginBottom:e.spacing.sm},[fe]:{width:e.sizes.full},[ge]:{flexDirection:"column"},[Fe]:{height:"auto",whiteSpace:"initial"},[me]:{display:"none"},[ue]:{margin:e.spacing.none,padding:e.spacing.none}}),Ge=p("div",{target:"ewslnz917"})(({theme:e,width:t})=>{if(t<Se("23rem"))return Ze(e)}),Je=({multiple:e,acceptedExtensions:t,maxSizeBytes:n,acceptDirectory:i=!1,disabled:d})=>{const y=()=>i?"directories":e?"files":"file",c=()=>t.length?` • ${t.map(w=>w.replace(/^\./,"").toUpperCase()).join(", ")}`:null,F=()=>`Limit ${oe(n,R.Byte,0)} per file`;return x(je,{"data-testid":"stFileUploaderDropzoneInstructions",children:[a(ce,{children:a(I,{content:ae,size:"threeXL"})}),x(Oe,{children:[x(de,{disabled:d,children:["Drag and drop ",y()," here"]}),x(Xe,{disabled:d,children:[F(),c()]})]})]})},Qe=o.memo(Je),et=({onDrop:e,multiple:t,acceptedExtensions:n,maxSizeBytes:i,disabled:d,label:y,acceptDirectory:c=!1})=>a(Ae,{onDrop:e,multiple:t,accept:Re(n),maxSize:i,disabled:d,useFsAccessApi:!1,children:({getRootProps:F,getInputProps:w})=>{const v=w({multiple:t||!!c});return x(re,{...F(),"data-testid":"stFileUploaderDropzone",isDisabled:d,"aria-label":y,"aria-disabled":d,children:[a("input",{"data-testid":"stFileUploaderDropzoneInput",...v,...c&&{webkitdirectory:""}}),a(Qe,{multiple:t,acceptedExtensions:n,maxSizeBytes:i,acceptDirectory:c,disabled:d}),a(qe,{children:a(V,{kind:M.SECONDARY,disabled:d,size:ve.SMALL,children:c?"Browse directories":"Browse files"})})]})}}),tt=o.memo(et),we=p("small",{target:"e1xq3mgd0"})(({kind:e,disabled:t,theme:n})=>{const{redTextColor:i,fadedText60:d,fadedText40:y}=n.colors;let c=d;return t&&(c=y),e==="danger"&&(c=i),{color:c,fontSize:n.fontSizes.sm,lineHeight:n.lineHeights.tight}}),ot=({fileInfo:e,disabled:t})=>e.status.type==="uploading"?a(He,{value:e.status.progress,size:We.SMALL}):e.status.type==="error"?x(Fe,{children:[a(Ke,{"data-testid":"stFileUploaderFileErrorMessage",children:e.status.errorMessage}),a(me,{children:a(I,{content:ie,size:"lg"})})]}):e.status.type==="uploaded"?a(we,{disabled:t,children:oe(e.size,R.Byte)}):null,nt=({fileInfo:e,onDelete:t,disabled:n})=>x(he,{className:"stFileUploaderFile","data-testid":"stFileUploaderFile",children:[a(Ye,{disabled:n,children:a(I,{content:Pe,size:"twoXL"})}),x(ge,{className:"stFileUploaderFileData",children:[a(fe,{className:"stFileUploaderFileName","data-testid":"stFileUploaderFileName",title:e.name,disabled:n,children:e.name}),a(ot,{fileInfo:e,disabled:n})]}),a("div",{"data-testid":"stFileUploaderDeleteBtn",children:a(V,{onClick:()=>t(e.id),kind:M.MINIMAL,disabled:n,"aria-label":`Remove ${e.name}`,children:a(I,{content:se,size:"lg"})})})]}),lt=o.memo(nt),st=p("div",{target:"e1o0u1j0"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:e.spacing.twoXS,marginBottom:e.spacing.twoXS})),at=p("div",{target:"e1o0u1j1"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.colors.fadedText40})),it=({currentPage:e,totalPages:t,onNext:n,onPrevious:i})=>x(st,{"data-testid":"stFileUploaderPagination",children:[a(we,{children:`Showing page ${e} of ${t}`}),x(at,{children:[a(V,{onClick:i,kind:M.MINIMAL,children:a(I,{content:ne,size:"xl"})}),a(V,{onClick:n,kind:M.MINIMAL,children:a(I,{content:le,size:"xl"})})]})]}),rt=o.memo(it),te=(e,t)=>Math.ceil(e.length/t),ct=e=>Ue(({pageSize:n,items:i,resetOnAdd:d,...y})=>{const[c,F]=o.useState(0),[w,v]=o.useState(()=>te(i,n)),u=$e(i);o.useEffect(()=>{u&&u.length!==i.length&&v(te(i,n)),u&&u.length<i.length?d&&F(0):c+1>=w&&F(w-1)},[i,c,n,u,d,w]);const E=()=>{F(Math.min(c+1,w-1))},U=()=>{F(Math.max(0,c-1))},A=i.slice(c*n,c*n+n);return x(Ce,{children:[a(e,{items:A,...y}),i.length>n?a(rt,{pageSize:n,totalPages:w,currentPage:c+1,onNext:E,onPrevious:U}):null]})},e),dt=({items:e,onDelete:t,disabled:n})=>a(_e,{children:e.map(i=>a(ue,{children:a(lt,{fileInfo:i,onDelete:t,disabled:n})},i.id))}),pt=ct(dt),ut=e=>a(pe,{children:a(pt,{...e})}),gt=o.memo(ut),ft=(e,t)=>{const n=t.getFileUploaderStateValue(e);if(D(n))return{files:[],nextLocalId:1};const{uploadedFileInfo:i}=n;if(D(i)||i.length===0)return{files:[],nextLocalId:1};let d=1;return{files:i.map(c=>{const F=c.name,w=c.size,v=c.fileId,u=c.fileUrls,E=new j(F,w,d,{type:"uploaded",fileId:v,fileUrls:u});return d+=1,E}),nextLocalId:d}},$=e=>{const t=e.filter(n=>n.status.type==="uploaded").map(n=>{const{name:i,size:d,status:y}=n,{fileId:c,fileUrls:F}=y;return new ke({fileId:c,fileUrls:F,name:i,size:d})});return new Ve({uploadedFileInfo:t})},ht=({disabled:e,element:t,widgetMgr:n,uploadClient:i,fragmentId:d})=>{const{width:y,elementRef:c}=be(),{files:F,nextLocalId:w}=o.useMemo(()=>ft(t,n),[t,n]),v=o.useRef(w),[u,E]=o.useState(()=>F),U=o.useRef(u);o.useEffect(()=>{U.current=u},[u]);const[A,X]=o.useState(!1),B=o.useCallback(()=>{const l=v.current;return v.current+=1,l},[]),P=o.useMemo(()=>{const l=t.maxUploadSizeMb;return Ne(l,R.Megabyte,R.Byte)},[t.maxUploadSizeMb]),S=o.useCallback(l=>{ee.flushSync(()=>{E(s=>{const r=typeof l=="function"?l(s):l;return U.current=r,r})})},[]),N=o.useCallback(l=>{ee.flushSync(()=>{X(l)})},[X]),O=o.useCallback(l=>{S(s=>[...s,l])},[S]),T=o.useCallback(l=>{l.length!==0&&S(s=>[...s,...l])},[S]),q=o.useCallback(l=>{S(s=>s.filter(r=>r.id!==l))},[S]),C=o.useCallback((l,s)=>{S(r=>r.map(g=>g.id===l?s:g))},[S]),b=o.useCallback(l=>U.current.find(s=>s.id===l),[]),_=u.some(l=>l.status.type==="uploading")||A?"updating":"ready";o.useEffect(()=>{n.getFileUploaderStateValue(t)===void 0&&n.setFileUploaderStateValue(t,$(U.current),{fromUi:!1},d)},[n,t,d]),o.useEffect(()=>{if(_!=="ready")return;const l=$(u),s=n.getFileUploaderStateValue(t);Ie(l,s)||n.setFileUploaderStateValue(t,l,{fromUi:!0},d)},[_,u,n,t,d]);const ye=o.useCallback(()=>{S(()=>[]);const l=$([]);n.setFileUploaderStateValue(t,l,{fromUi:!0},d)},[t,d,S,n]);Me({element:t,widgetMgr:n,onFormCleared:ye});const K=o.useCallback(l=>{const s=t.type;if(!s||s.length===0)return!0;const r=l.name.toLowerCase();return s.some(g=>r.endsWith(g.toLowerCase()))},[t.type]),Y=o.useCallback(l=>{const s=[],r=[];return l.forEach(g=>{K(g)?s.push(g):r.push({file:g,errors:[{code:"file-invalid-type",message:`${g.type} files are not allowed.`}]})}),{accepted:s,rejected:r}},[K]),Z=o.useCallback((l,s)=>{const r=b(l);D(r)||r.status.type!=="uploading"||C(r.id,r.setStatus({type:"uploaded",fileId:s.fileId,fileUrls:s}))},[b,C]),G=o.useCallback((l,s)=>{const r=b(s);if(D(r)||r.status.type!=="uploading")return;const g=Math.round(l.loaded*100/l.total);r.status.progress!==g&&C(s,r.setStatus({type:"uploading",abortController:r.status.abortController,progress:g}))},[b,C]),J=o.useCallback((l,s)=>{const r=new AbortController,g=s.webkitRelativePath||s.name,f=new j(g,s.size,B(),{type:"uploading",abortController:r,progress:1});O(f),i.uploadFile(t,l.uploadUrl,s,h=>G(h,f.id),r.signal).then(()=>Z(f.id,l)).catch(h=>{h instanceof DOMException&&h.name==="AbortError"||C(f.id,f.setStatus({type:"error",errorMessage:h?h.toString():"Unknown error"}))})},[O,t,B,Z,G,C,i]),W=o.useCallback(l=>{if(e)return;const s=b(l);D(s)||(s.status.type==="uploading"&&s.status.abortController.abort(),s.status.type==="uploaded"&&s.status.fileUrls.deleteUrl&&i.deleteFile(s.status.fileUrls.deleteUrl),q(l))},[e,b,q,i]),xe=o.useCallback((l,s)=>{const{multipleFiles:r}=t,g=!!t.acceptDirectory;let f=[...l],h=[...s];if(g&&f.length>0){const{accepted:z,rejected:m}=Y(f);f=z,h=[...h,...m]}if(!r&&f.length===0&&h.length>1){const z=h.findIndex(m=>m.errors.length===1&&m.errors[0].code==="too-many-files");z>=0&&(f.push(h[z].file),h.splice(z,1))}if(i.fetchFileURLs(f).then(z=>{if(!r&&f.length>0){const m=U.current.find(H=>H.status.type!=="error");if(m){N(!0);try{W(m.id)}finally{N(!1)}}}Ee(z,f).forEach(([m,H])=>{J(m,H)})}).catch(z=>{T(f.map(m=>new j(m.name,m.size,B(),{type:"error",errorMessage:z})))}),h.length>0){const z=h.map(m=>Te(m,B(),P));T(z)}},[T,W,t,Y,P,B,i,J,N]),Q=o.useMemo(()=>u.slice().reverse(),[u]),ze=t.type;return x(Ge,{className:"stFileUploader","data-testid":"stFileUploader",width:y,ref:c,children:[a(Le,{label:t.label,disabled:e,labelVisibility:Be(t.labelVisibility?.value),children:t.help&&a(De,{content:t.help,label:t.label})}),a(tt,{onDrop:xe,multiple:t.multipleFiles,acceptedExtensions:ze,maxSizeBytes:P,label:t.label,disabled:e,acceptDirectory:!!t.acceptDirectory}),Q.length>0&&a(gt,{items:Q,pageSize:3,onDelete:W,resetOnAdd:!0,disabled:e})]})},zt=o.memo(ht);export{zt as default};
|
|
1
|
+
import{r as o,E as L,_ as k,z as p,ac as Se,o as x,j as a,az as I,b as V,c as Ue,B as M,h as ve,$ as Ce,k as be,al as ee,bC as Ie,e as D,b_ as Ee,p as Be,ad as De,ae as Le,bT as ke,bU as Ve}from"./index.BHyzKS4e.js";import{u as Me}from"./FormClearHelper.DQoXcOWo.js";import{g as oe,F as R,a as Re,D as Ae,I as Pe,s as Ne,b as Te}from"./FileHelper.DQSH0zYW.js";import{S as We,P as He}from"./ProgressBar.DNF_pWKr.js";import{U as j}from"./UploadFileInfo.Dr-zDST7.js";const $e=e=>{const t=o.useRef();return o.useEffect(()=>{t.current=e},[e]),t.current};var ne=o.forwardRef(function(e,t){var n={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(L,k({iconAttrs:n,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),o.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),o.createElement("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12l4.58-4.59z"}))});ne.displayName="ChevronLeft";var le=o.forwardRef(function(e,t){var n={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(L,k({iconAttrs:n,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),o.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),o.createElement("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z"}))});le.displayName="ChevronRight";var se=o.forwardRef(function(e,t){var n={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(L,k({iconAttrs:n,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),o.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),o.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"}))});se.displayName="Clear";var ae=o.forwardRef(function(e,t){var n={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(L,k({iconAttrs:n,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),o.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),o.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"}))});ae.displayName="CloudUpload";var ie=o.forwardRef(function(e,t){var n={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(L,k({iconAttrs:n,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),o.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"}))});ie.displayName="Error";const re=p("section",{target:"ewslnz90"})(({isDisabled:e,theme:t})=>({display:"flex",gap:t.spacing.lg,alignItems:"center",padding:t.spacing.lg,backgroundColor:t.colors.secondaryBg,borderRadius:t.radii.default,border:t.colors.widgetBorderColor?`${t.sizes.borderWidth} solid ${t.colors.widgetBorderColor}`:void 0,height:t.sizes.largestElementHeight,":focus":{outline:"none"},":focus-visible":{boxShadow:t.shadows.focusRingOutline},cursor:e?"not-allowed":"pointer"})),je=p("div",{target:"ewslnz91"})(({theme:e})=>({marginRight:"auto",alignItems:"center",display:"flex",gap:e.spacing.lg,minWidth:0,width:"100%"})),ce=p("span",{target:"ewslnz92"})(({theme:e})=>({color:e.colors.darkenedBgMix100})),de=p("span",{target:"ewslnz93"})(({theme:e,disabled:t})=>({color:t?e.colors.fadedText40:e.colors.bodyText})),Xe=p("span",{target:"ewslnz94"})(({theme:e,disabled:t})=>({fontSize:e.fontSizes.sm,color:t?e.colors.fadedText40:e.colors.fadedText60,display:"block",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",maxWidth:"100%"})),Oe=p("div",{target:"ewslnz95"})({display:"flex",flexDirection:"column",minWidth:0,maxWidth:"100%"}),_e=p("span",{target:"ewslnz96"})({whiteSpace:"nowrap"}),pe=p("div",{target:"ewslnz97"})(({theme:e})=>({left:0,right:0,lineHeight:e.lineHeights.tight,paddingTop:e.spacing.md,paddingLeft:e.spacing.lg,paddingRight:e.spacing.lg})),qe=p("ul",{target:"ewslnz98"})(({theme:e})=>({listStyleType:"none",margin:e.spacing.none,padding:e.spacing.none})),ue=p("li",{target:"ewslnz99"})(({theme:e})=>({margin:e.spacing.none,padding:e.spacing.none})),ge=p("div",{target:"ewslnz910"})(({theme:e})=>({display:"flex",alignItems:"baseline",flex:1,paddingLeft:e.spacing.lg,overflow:"hidden"})),fe=p("div",{target:"ewslnz911"})(({theme:e,disabled:t})=>({marginRight:e.spacing.sm,marginBottom:e.spacing.twoXS,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:t?e.colors.fadedText40:e.colors.bodyText})),he=p("div",{target:"ewslnz912"})(({theme:e})=>({display:"flex",alignItems:"center",marginBottom:e.spacing.twoXS})),Ke=p("span",{target:"ewslnz913"})(({theme:e})=>({marginRight:e.spacing.twoXS})),Ye=p("div",{target:"ewslnz914"})(({theme:e,disabled:t})=>({display:"flex",padding:e.spacing.twoXS,color:t?e.colors.fadedText40:e.colors.darkenedBgMix100})),Fe=p("small",{target:"ewslnz915"})(({theme:e})=>({color:e.colors.redTextColor,fontSize:e.fontSizes.sm,height:e.fontSizes.sm,lineHeight:e.fontSizes.sm,display:"flex",alignItems:"center",whiteSpace:"nowrap"})),me=p("span",{target:"ewslnz916"})({}),Ge=e=>({[re]:{display:"flex",flexDirection:"column",alignItems:"flex-start",height:"auto",gap:e.spacing.sm},[ce]:{display:"none"},[de]:{marginBottom:e.spacing.twoXS},[pe]:{paddingRight:e.spacing.lg},[he]:{maxWidth:"inherit",flex:1,alignItems:"flex-start",marginBottom:e.spacing.sm},[fe]:{width:e.sizes.full},[ge]:{flexDirection:"column"},[Fe]:{height:"auto",whiteSpace:"initial"},[me]:{display:"none"},[ue]:{margin:e.spacing.none,padding:e.spacing.none}}),Je=p("div",{target:"ewslnz917"})(({theme:e,width:t})=>{if(t<Se("23rem"))return Ge(e)}),Qe=({multiple:e,acceptedExtensions:t,maxSizeBytes:n,acceptDirectory:i=!1,disabled:d})=>{const y=()=>i?"directories":e?"files":"file",c=()=>t.length?` • ${t.map(w=>w.replace(/^\./,"").toUpperCase()).join(", ")}`:null,F=()=>`Limit ${oe(n,R.Byte,0)} per file`;return x(je,{"data-testid":"stFileUploaderDropzoneInstructions",children:[a(ce,{children:a(I,{content:ae,size:"threeXL"})}),x(Oe,{children:[x(de,{disabled:d,children:["Drag and drop ",y()," here"]}),x(Xe,{disabled:d,children:[F(),c()]})]})]})},Ze=o.memo(Qe),et=({onDrop:e,multiple:t,acceptedExtensions:n,maxSizeBytes:i,disabled:d,label:y,acceptDirectory:c=!1})=>a(Ae,{onDrop:e,multiple:t,accept:Re(n),maxSize:i,disabled:d,useFsAccessApi:!1,children:({getRootProps:F,getInputProps:w})=>{const U=w({multiple:t||!!c});return x(re,{...F(),"data-testid":"stFileUploaderDropzone",isDisabled:d,"aria-label":y,"aria-disabled":d,children:[a("input",{"data-testid":"stFileUploaderDropzoneInput",...U,...c&&{webkitdirectory:""}}),a(Ze,{multiple:t,acceptedExtensions:n,maxSizeBytes:i,acceptDirectory:c,disabled:d}),a(_e,{children:a(V,{kind:M.SECONDARY,disabled:d,size:Ue.SMALL,children:c?"Browse directories":"Browse files"})})]})}}),tt=o.memo(et),we=p("small",{target:"e1xq3mgd0"})(({kind:e,disabled:t,theme:n})=>{const{redTextColor:i,fadedText60:d,fadedText40:y}=n.colors;let c=d;return t&&(c=y),e==="danger"&&(c=i),{color:c,fontSize:n.fontSizes.sm,lineHeight:n.lineHeights.tight}}),ot=({fileInfo:e,disabled:t})=>e.status.type==="uploading"?a(He,{value:e.status.progress,size:We.SMALL}):e.status.type==="error"?x(Fe,{children:[a(Ke,{"data-testid":"stFileUploaderFileErrorMessage",children:e.status.errorMessage}),a(me,{children:a(I,{content:ie,size:"lg"})})]}):e.status.type==="uploaded"?a(we,{disabled:t,children:oe(e.size,R.Byte)}):null,nt=({fileInfo:e,onDelete:t,disabled:n})=>x(he,{className:"stFileUploaderFile","data-testid":"stFileUploaderFile",children:[a(Ye,{disabled:n,children:a(I,{content:Pe,size:"twoXL"})}),x(ge,{className:"stFileUploaderFileData",children:[a(fe,{className:"stFileUploaderFileName","data-testid":"stFileUploaderFileName",title:e.name,disabled:n,children:e.name}),a(ot,{fileInfo:e,disabled:n})]}),a("div",{"data-testid":"stFileUploaderDeleteBtn",children:a(V,{onClick:()=>t(e.id),kind:M.MINIMAL,disabled:n,"aria-label":`Remove ${e.name}`,children:a(I,{content:se,size:"lg"})})})]}),lt=o.memo(nt),st=p("div",{target:"e1o0u1j0"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:e.spacing.twoXS,marginBottom:e.spacing.twoXS})),at=p("div",{target:"e1o0u1j1"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.colors.fadedText40})),it=({currentPage:e,totalPages:t,onNext:n,onPrevious:i})=>x(st,{"data-testid":"stFileUploaderPagination",children:[a(we,{children:`Showing page ${e} of ${t}`}),x(at,{children:[a(V,{onClick:i,kind:M.MINIMAL,children:a(I,{content:ne,size:"xl"})}),a(V,{onClick:n,kind:M.MINIMAL,children:a(I,{content:le,size:"xl"})})]})]}),rt=o.memo(it),te=(e,t)=>Math.ceil(e.length/t),ct=e=>ve(({pageSize:n,items:i,resetOnAdd:d,...y})=>{const[c,F]=o.useState(0),[w,U]=o.useState(()=>te(i,n)),u=$e(i);o.useEffect(()=>{u&&u.length!==i.length&&U(te(i,n)),u&&u.length<i.length?d&&F(0):c+1>=w&&F(w-1)},[i,c,n,u,d,w]);const E=()=>{F(Math.min(c+1,w-1))},v=()=>{F(Math.max(0,c-1))},A=i.slice(c*n,c*n+n);return x(Ce,{children:[a(e,{items:A,...y}),i.length>n?a(rt,{pageSize:n,totalPages:w,currentPage:c+1,onNext:E,onPrevious:v}):null]})},e),dt=({items:e,onDelete:t,disabled:n})=>a(qe,{children:e.map(i=>a(ue,{children:a(lt,{fileInfo:i,onDelete:t,disabled:n})},i.id))}),pt=ct(dt),ut=e=>a(pe,{children:a(pt,{...e})}),gt=o.memo(ut),ft=(e,t)=>{const n=t.getFileUploaderStateValue(e);if(D(n))return{files:[],nextLocalId:1};const{uploadedFileInfo:i}=n;if(D(i)||i.length===0)return{files:[],nextLocalId:1};let d=1;return{files:i.map(c=>{const F=c.name,w=c.size,U=c.fileId,u=c.fileUrls,E=new j(F,w,d,{type:"uploaded",fileId:U,fileUrls:u});return d+=1,E}),nextLocalId:d}},$=e=>{const t=e.filter(n=>n.status.type==="uploaded").map(n=>{const{name:i,size:d,status:y}=n,{fileId:c,fileUrls:F}=y;return new ke({fileId:c,fileUrls:F,name:i,size:d})});return new Ve({uploadedFileInfo:t})},ht=({disabled:e,element:t,widgetMgr:n,uploadClient:i,fragmentId:d})=>{const{width:y,elementRef:c}=be(),{files:F,nextLocalId:w}=o.useMemo(()=>ft(t,n),[t,n]),U=o.useRef(w),[u,E]=o.useState(()=>F),v=o.useRef(u);o.useEffect(()=>{v.current=u},[u]);const[A,X]=o.useState(!1),B=o.useCallback(()=>{const l=U.current;return U.current+=1,l},[]),P=o.useMemo(()=>{const l=t.maxUploadSizeMb;return Ne(l,R.Megabyte,R.Byte)},[t.maxUploadSizeMb]),S=o.useCallback(l=>{ee.flushSync(()=>{E(s=>{const r=typeof l=="function"?l(s):l;return v.current=r,r})})},[]),N=o.useCallback(l=>{ee.flushSync(()=>{X(l)})},[X]),O=o.useCallback(l=>{S(s=>[...s,l])},[S]),T=o.useCallback(l=>{l.length!==0&&S(s=>[...s,...l])},[S]),_=o.useCallback(l=>{S(s=>s.filter(r=>r.id!==l))},[S]),C=o.useCallback((l,s)=>{S(r=>r.map(g=>g.id===l?s:g))},[S]),b=o.useCallback(l=>v.current.find(s=>s.id===l),[]),q=u.some(l=>l.status.type==="uploading")||A?"updating":"ready";o.useEffect(()=>{n.getFileUploaderStateValue(t)===void 0&&n.setFileUploaderStateValue(t,$(v.current),{fromUi:!1},d)},[n,t,d]),o.useEffect(()=>{if(q!=="ready")return;const l=$(u),s=n.getFileUploaderStateValue(t);Ie(l,s)||n.setFileUploaderStateValue(t,l,{fromUi:!0},d)},[q,u,n,t,d]);const ye=o.useCallback(()=>{S(()=>[]);const l=$([]);n.setFileUploaderStateValue(t,l,{fromUi:!0},d)},[t,d,S,n]);Me({element:t,widgetMgr:n,onFormCleared:ye});const K=o.useCallback(l=>{const s=t.type;if(!s||s.length===0)return!0;const r=l.name.toLowerCase();return s.some(g=>r.endsWith(g.toLowerCase()))},[t.type]),Y=o.useCallback(l=>{const s=[],r=[];return l.forEach(g=>{K(g)?s.push(g):r.push({file:g,errors:[{code:"file-invalid-type",message:`${g.type} files are not allowed.`}]})}),{accepted:s,rejected:r}},[K]),G=o.useCallback((l,s)=>{const r=b(l);D(r)||r.status.type!=="uploading"||C(r.id,r.setStatus({type:"uploaded",fileId:s.fileId,fileUrls:s}))},[b,C]),J=o.useCallback((l,s)=>{const r=b(s);if(D(r)||r.status.type!=="uploading")return;const g=Math.round(l.loaded*100/l.total);r.status.progress!==g&&C(s,r.setStatus({type:"uploading",abortController:r.status.abortController,progress:g}))},[b,C]),Q=o.useCallback((l,s)=>{const r=new AbortController,g=s.webkitRelativePath||s.name,f=new j(g,s.size,B(),{type:"uploading",abortController:r,progress:1});O(f),i.uploadFile(t,l.uploadUrl,s,h=>J(h,f.id),r.signal).then(()=>G(f.id,l)).catch(h=>{h instanceof DOMException&&h.name==="AbortError"||C(f.id,f.setStatus({type:"error",errorMessage:h?h.toString():"Unknown error"}))})},[O,t,B,G,J,C,i]),W=o.useCallback(l=>{if(e)return;const s=b(l);D(s)||(s.status.type==="uploading"&&s.status.abortController.abort(),s.status.type==="uploaded"&&s.status.fileUrls.deleteUrl&&i.deleteFile(s.status.fileUrls.deleteUrl),_(l))},[e,b,_,i]),xe=o.useCallback((l,s)=>{const{multipleFiles:r}=t,g=!!t.acceptDirectory;let f=[...l],h=[...s];if(g&&f.length>0){const{accepted:z,rejected:m}=Y(f);f=z,h=[...h,...m]}if(!r&&f.length===0&&h.length>1){const z=h.findIndex(m=>m.errors.length===1&&m.errors[0].code==="too-many-files");z>=0&&(f.push(h[z].file),h.splice(z,1))}if(i.fetchFileURLs(f).then(z=>{if(!r&&f.length>0){const m=v.current.find(H=>H.status.type!=="error");if(m){N(!0);try{W(m.id)}finally{N(!1)}}}Ee(z,f).forEach(([m,H])=>{Q(m,H)})}).catch(z=>{T(f.map(m=>new j(m.name,m.size,B(),{type:"error",errorMessage:z})))}),h.length>0){const z=h.map(m=>Te(m,B(),P));T(z)}},[T,W,t,Y,P,B,i,Q,N]),Z=o.useMemo(()=>u.slice().reverse(),[u]),ze=t.type;return x(Je,{className:"stFileUploader","data-testid":"stFileUploader",width:y,ref:c,children:[a(Le,{label:t.label,disabled:e,labelVisibility:Be(t.labelVisibility?.value),children:t.help&&a(De,{content:t.help,label:t.label})}),a(tt,{onDrop:xe,multiple:t.multipleFiles,acceptedExtensions:ze,maxSizeBytes:P,label:t.label,disabled:e,acceptDirectory:!!t.acceptDirectory}),Z.length>0&&a(gt,{items:Z,pageSize:3,onDelete:W,resetOnAdd:!0,disabled:e})]})},zt=o.memo(ht);export{zt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as f,r as o,R as g,j as l,V as v}from"./index.
|
|
1
|
+
import{z as f,r as o,R as g,j as l,V as v}from"./index.BHyzKS4e.js";const T=f("div",{target:"e1z085g90"})(()=>({lineHeight:0})),y=f("audio",{target:"e1z085g91"})(({theme:t})=>({width:"100%",height:t.sizes.minElementHeight,margin:0,padding:0})),h=v.getLogger("Audio");function L({element:t,endpoints:a,elementMgr:s}){const i=o.useRef(null),{startTime:n,endTime:d,loop:u,autoplay:p}=t,E=o.useMemo(()=>{if(!t.id)return!0;const e=s.getElementState(t.id,"preventAutoplay");return e||s.setElementState(t.id,"preventAutoplay",!0),e??!1},[t.id,s]);o.useEffect(()=>{i.current&&(i.current.currentTime=n)},[n]),o.useEffect(()=>{const e=i.current,r=()=>{e&&(e.currentTime=t.startTime)};return e&&e.addEventListener("loadedmetadata",r),()=>{e&&e.removeEventListener("loadedmetadata",r)}},[t]),o.useEffect(()=>{const e=i.current;if(!e)return;let r=!1;const c=()=>{d>0&&e.currentTime>=d&&(u?(e.currentTime=n||0,e.play()):r||(r=!0,e.pause()))};return d>0&&e.addEventListener("timeupdate",c),()=>{e&&d>0&&e.removeEventListener("timeupdate",c)}},[d,u,n]),o.useEffect(()=>{const e=i.current;if(!e)return;const r=()=>{u&&(e.currentTime=n||0,e.play())};return e.addEventListener("ended",r),()=>{e&&e.removeEventListener("ended",r)}},[u,n]);const m=g(t.url),A=a.buildMediaURL(t.url);return l(T,{children:l(y,{className:"stAudio","data-testid":"stAudio",ref:i,controls:!0,autoPlay:p&&!E,src:A,onError:e=>{const r=e.currentTarget.src;h.error(`Client Error: Audio source error - ${r}`),a.sendClientErrorToHost("Audio","Audio source failed to load","onerror triggered",r)},crossOrigin:m})})}const z=o.memo(L);export{z as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,L,H as M,B as w,u as T,o as U,j as u,b as A,c as P,D as j,a as N,I as Y}from"./index.
|
|
1
|
+
import{r as o,L,H as M,B as w,u as T,o as U,j as u,b as A,c as P,D as j,a as N,I as Y}from"./index.BHyzKS4e.js";import{m as z}from"./iconPosition.C47DkA-1.js";import{c as R}from"./createDownloadLinkElement.YxVC9Qur.js";function F(S){const{disabled:i,element:r,widgetMgr:B,endpoints:t,fragmentId:g}=S,{help:v,label:x,icon:I,ignoreRerun:h,type:p,url:k,deferredFileId:n}=r,b=r.shortcut?r.shortcut:void 0,[C,f]=o.useState(!1),[l,s]=o.useState(null),{enforceDownloadInNewTab:d=!1}=o.useContext(L),{requestDeferredFile:D}=o.useContext(M);let m=w.SECONDARY;p==="primary"?m=w.PRIMARY:p==="tertiary"&&(m=w.TERTIARY);const c=o.useMemo(()=>t.buildDownloadUrl(k),[t,k]);o.useEffect(()=>{n?.length||t.checkSourceUrlResponse(c,"Download Button")},[c,t,n]);const E=o.useCallback(async()=>{if(!D||!n){s("Deferred download not properly configured");return}f(!0),s(null);try{const e=await D(n);if(e.errorMsg){s(e.errorMsg),f(!1);return}const a=t.buildDownloadUrl(e.url);t.checkSourceUrlResponse(a,"Download Button"),R({filename:"",url:a,enforceDownloadInNewTab:d}).click()}catch(e){const a=e instanceof Error?e.message:"Download failed";s(a)}finally{f(!1)}},[D,n,t,d]),y=o.useCallback(()=>{if(i)return;h||B.setTriggerValue(r,{fromUi:!0},g),!!n?.length?E():R({filename:"",url:c,enforceDownloadInNewTab:d}).click()},[i,h,B,r,g,n,E,c,d]);return T({shortcut:b,disabled:i,onActivate:y}),o.useEffect(()=>{if(l){const e=setTimeout(()=>s(null),5e3);return()=>clearTimeout(e)}},[l]),U("div",{className:"stDownloadButton","data-testid":"stDownloadButton",children:[u(N,{help:v,containerWidth:!0,children:u(A,{kind:m,size:P.SMALL,disabled:i||C,onClick:y,containerWidth:!0,children:u(j,{icon:C?"spinner":I,iconPosition:z(r.iconPosition),label:x,shortcut:b})})}),l&&u(Y,{"data-testid":"stDownloadButtonError",children:l})]})}const O=o.memo(F);export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,E as Q,_ as K,
|
|
1
|
+
import{r as i,E as Q,_ as K,bw as z,bx as k,l as Y,e as j,Q as Z,O as q,by as M,bz as _,bA as ee,bB as te,n as H,bC as J,V as G,W as ne,k as re,a6 as se,bD as oe,j as x,o as ae,ba as ie}from"./index.BHyzKS4e.js";import{w as ce,E as le}from"./withFullScreenWrapper.DBm7N75M.js";import{a as P,S as U,T as ue}from"./Toolbar.BXfC9Z-W.js";import{R as fe}from"./index.Bnwh8oZr.js";import{a as W,c as de,b as me,e as pe,t as he,S as ge,d as ye}from"./embed.CDzakah3.js";import{u as Se}from"./FormClearHelper.DQoXcOWo.js";import{T as be}from"./TableChart.esm.B9SMgSK4.js";import"./moment.C7qA8nIE.js";import"./pandasStylerUtils.DlZ2GBs_.js";import"./numbro.B9_PXfzp.js";import"./_baseIndexOf.BTknn6Gb.js";import"./index.8HslT92O.js";import"./main.23ZP6f1E.js";import"./throttle.DR7d9vp_.js";import"./toConsumableArray.BDTTq1c5.js";import"./formatNumber.L8T7D36k.js";import"./sprintfjs.CtrdaGLQ.js";import"./formatMoment.C6Hwn6X5.js";import"./checkbox.Bqz68SYq.js";import"./createDownloadLinkElement.YxVC9Qur.js";import"./FileDownload.esm.D-YPxF3t.js";import"./_arrayIncludes.B19Iyn2B.js";import"./threshold.CUNQbqMA.js";import"./value.DaKxGC7O.js";import"./timer.BZio6gjG.js";var $=i.forwardRef(function(t,e){var s={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return i.createElement(Q,K({iconAttrs:s,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),i.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),i.createElement("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM7 10h2v7H7zm4-3h2v10h-2zm4 6h2v4h-2z"}))});$.displayName="InsertChart";function F(t,e){if(we(t,e),Array.isArray(t.layer))for(const s of t.layer)s&&typeof s=="object"&&F(s,e);for(const s of["vconcat","hconcat","concat"])if(Array.isArray(t[s]))for(const r of t[s])r&&typeof r=="object"&&F(r,e);("facet"in t||"repeat"in t)&&t.spec&&typeof t.spec=="object"&&F(t.spec,e)}function we(t,e){const s=t.encoding;if(!s)return;const r=s.color;if(!r)return;"value"in r&&z(r.value)&&(r.value=k(r.value,e));const c=r.scale;c&&Array.isArray(c.range)&&(c.range=c.range.map(o=>z(o)?k(o,e):o))}const Ce=20;function Ee(t){"params"in t&&"encoding"in t&&t.params.forEach(e=>{"select"in e&&(["interval","point"].includes(e.select)&&(e.select={type:e.select}),"type"in e.select&&e.select.type==="point"&&!("encodings"in e.select)&&j(e.select.encodings)&&(e.select.encodings=Object.keys(t.encoding)))})}const ve=(t,e,s,r,c,o,f,m)=>{const n=JSON.parse(t);if(typeof n.height=="number"&&n.height<=0&&delete n.height,typeof n.width=="number"&&n.width<=0&&delete n.width,r==="streamlit"?n.config=W(n.config,o):n.usermeta?.embedOptions?.theme==="streamlit"?(n.config=W(n.config,o),n.usermeta.embedOptions.theme=void 0):n.config=de(n.config,o),n.title&&(typeof n.title=="string"&&(n.title={text:n.title}),n.title.limit=n.title.limit??Math.max(f-40,0)),s&&m&&m>0&&(n.height=m),e&&f&&f>0&&(n.width=f,"vconcat"in n&&n.vconcat.forEach(a=>{a===null||typeof a!="object"||"hconcat"in a||"vconcat"in a||"concat"in a||"layer"in a||(a.width=f)})),n.padding||(n.padding={}),j(n.padding.bottom)&&(n.padding.bottom=Ce),n.datasets)throw new Error("Datasets should not be passed as part of the spec");return c.length>0&&Ee(n),F(n,o),n},Ne=(t,e,s,r,c)=>{const o=Y(),{id:f,formId:m,spec:n,data:a,datasets:l,vegaLiteTheme:d,selectionMode:u}=t,h=i.useMemo(()=>u,[JSON.stringify(u)]),y=i.useMemo(()=>ve(n,r,c,d,h,o,e,s),[n,r,c,d,h,o,e,s]);return{id:f,formId:m,vegaLiteTheme:d,spec:y,selectionMode:h,data:a,datasets:l,useContainerWidth:r}},Ae={DATAFRAME_INDEX:"(index)"};function De(t){return!t||t.dimensions.numDataRows===0?null:I(t)}function Ve(t){const e=L(t);if(j(e))return null;const s={};for(const[r,c]of Object.entries(e))s[r]=I(c);return s}function L(t){if(t?.length===0)return null;const e={};return t.forEach(s=>{if(!s)return;const r=s.hasName?s.name:null;e[r]=s.data}),e}function I(t,e=0){if(t.dimensions.numDataRows===0)return[];const s=[],{numDataRows:r,numDataColumns:c,numIndexColumns:o}=t.dimensions,f=t.columnTypes[0]??void 0,m=f?.type===Z.INDEX&&(q(f)||M(f)||_(f));for(let n=e;n<r;n++){const a={};if(m){const{content:l}=t.getCell(n,0);a[Ae.DATAFRAME_INDEX]=typeof l=="bigint"?Number(l):l}for(let l=0;l<c;l++){const d=l+o,{content:u,contentType:h}=t.getCell(n,d);if((u instanceof Date||typeof u=="number"&&Number.isFinite(u))&&(M(h)||_(h))&&!ee(h)){const y=new Date(u).getTimezoneOffset()*60*1e3;a[t.columnNames[0][d]]=u.valueOf()+y}else a[t.columnNames[0][d]]=typeof u=="bigint"?Number(u):u}s.push(a)}return s}const Oe=150,Te=G.getLogger("useVegaLiteSelections"),Re=(t,e,s)=>{const{id:r,formId:c,selectionMode:o}=t,f=i.useCallback(n=>{o.forEach(l=>{n.addSignalListener(l,te(Oe,(d,u)=>{const h=n.getState({data:(v,T)=>o.some(g=>`${g}_store`===v),recurse:!1});H(h)&&e.setElementState(r,"viewState",h);let y=u;"vlPoint"in u&&"or"in u.vlPoint&&(y=u.vlPoint.or);const A={id:r,formId:c},E=JSON.parse(e.getStringValue(A)||"{}"),N={selection:{...E?.selection||{},[d]:y||{}}};J(E,N)||e.setStringValue(A,JSON.stringify(N),{fromUi:!0},s)}))});const a=e.getElementState(r,"viewState");if(H(a))try{return n.setState(a)}catch(l){Te.warn("Failed to restore view state",l)}return n},[r,o,e,c,s]),m=i.useCallback(()=>{const n={selection:{}};o.forEach(u=>{n.selection[u]={}});const a={id:r,formId:c},l=e.getStringValue(a),d=l?JSON.parse(l):n;J(d,n)||e.setStringValue(a,JSON.stringify(n),{fromUi:!0},s)},[r,c,s,o,e]);return{maybeConfigureSelections:f,onFormCleared:m}},B="source",xe=G.getLogger("useVegaEmbed");function Fe(t,e,s){const r=i.useRef(null),c=i.useRef(null),o=i.useRef(B),f=i.useRef(null),m=i.useRef([]),n=i.useRef(null),a=i.useRef([]),[l,d]=i.useState(!1),{maybeConfigureSelections:u,onFormCleared:h}=Re(t,e,s);Se({widgetMgr:e,element:t,onFormCleared:h});const{data:y,datasets:A}=t;i.useEffect(()=>{n.current=y,a.current=A,r.current===null&&(f.current=y,m.current=A)},[y,A]);const E=i.useCallback(()=>{c.current&&c.current(),c.current=null,r.current=null},[]),N=i.useCallback(async(g,b)=>{if(g.current===null)throw new Error("Element missing.");d(!0);try{E();const w={ast:!0,expr:me,tooltip:{disableDefaultStyle:!0},defaultStyle:!1,forceActionsMenu:!0},{vgSpec:S,view:R,finalize:V}=await pe(g.current,b,w);r.current=u(R),c.current=V;const p=Ve(a.current),C=p?Object.keys(p):[];if(C.length===1){const[O]=C;o.current=O}else C.length===0&&S.data&&(o.current=B);const D=De(n.current);if(D&&r.current.insert(o.current,D),p)for(const[O,X]of Object.entries(p))r.current.insert(O,X);return await r.current.runAsync(),await r.current.resize().runAsync(),f.current=n.current,m.current=a.current,r.current}finally{d(!1)}},[E,u]),v=i.useCallback((g,b,w,S)=>{if(!S||S.dimensions.numDataRows===0){try{g.remove(b,he)}catch{}return}if(!w||w.dimensions.numDataRows===0){g.insert(b,I(S));return}S.hash!==w.hash&&(g.data(b,I(S)),xe.info(`Had to clear the ${b} dataset before inserting data through Vega view.`))},[]),T=i.useCallback(async(g,b)=>{if(r.current===null||l)return null;const w=f.current,S=m.current;(w||g)&&v(r.current,o.current,w,g);const R=L(S)??{},V=L(b)??{};for(const[p,C]of Object.entries(V)){const D=p||o.current,O=R[D];v(r.current,D,O,C)}for(const p of Object.keys(R))!Object.hasOwn(V,p)&&p!==o.current&&v(r.current,p,null,null);return await r.current?.resize().runAsync(),f.current=g,m.current=b,r.current},[v,l]);return{createView:N,updateView:T,finalizeView:E}}function Ie(t){try{const e=typeof t=="string"?JSON.parse(t):t;return!!(e.facet||e.encoding?.row||e.encoding?.column||e.encoding?.facet)}catch{return!1}}function Le(t){try{const e=typeof t=="string"?JSON.parse(t):t;return!("vconcat"in e)||!Array.isArray(e.vconcat)?!1:e.vconcat.some(s=>s!==null&&typeof s=="object"&&("hconcat"in s||"vconcat"in s||"concat"in s||"layer"in s))}catch{return!1}}const je=({disableFullscreenMode:t,element:e,fragmentId:s,widgetMgr:r,widthConfig:c,heightConfig:o})=>{const[f,m]=i.useState(!1),[n,a]=i.useState(!1),{expanded:l,height:d,width:u,expand:h,collapse:y}=ne(le),{width:A,height:E,elementRef:N}=re([f]),v=se(c)||e.useContainerWidth,T=oe(o),g=Ie(e.spec),b=Le(e.spec),w=Ne(e,g?u??0:A,(l?d:E)??0,l&&!b?!0:v,l?!0:T),{createView:S,updateView:R,finalizeView:V}=Fe(w,r,s),{data:p,datasets:C,spec:D}=w;if(i.useLayoutEffect(()=>(N.current!==null&&S(N,D),V),[S,V,D,u,d,f,N]),i.useEffect(()=>{R(p,C)},[p,C]),i.useEffect(()=>{p||C?.[0]?.data?a(!0):a(!1)},[p,C]),f){const O=d??(E>0?E:void 0);return x(fe,{data:p??C[0]?.data,height:O,width:c??void 0,customToolbarActions:[x(P,{label:"Show chart",icon:$,onClick:()=>{m(!1)}},"show-chart")]})}return ae(U,{height:T?l?d:"100%":d,useContainerWidth:l?!0:v,children:[x(ue,{target:U,isFullScreen:l,onExpand:h,onCollapse:y,disableFullscreenMode:t,children:n&&x(P,{label:"Show data",icon:be,onClick:()=>{m(!0)}})}),x(ie,{styles:[ge]}),x(ye,{"data-testid":"stVegaLiteChart",className:"stVegaLiteChart",useContainerWidth:v,useContainerHeight:T,ref:N})]})},ze=ce(je),ct=i.memo(ze);export{ge as StyledVegaLiteChartTooltips,W as applyStreamlitTheme,ct as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{z as c,a3 as l,r as i,j as a,
|
|
1
|
+
import{z as c,a3 as l,r as i,j as a,bb as p}from"./index.BHyzKS4e.js";import{P as d,R as f}from"./Particles.BdQSRZde.js";const g=""+new URL("../media/flake-0.DgWaVvm5.png",import.meta.url).href,u=""+new URL("../media/flake-1.B2r5AHMK.png",import.meta.url).href,E=""+new URL("../media/flake-2.BnWSExPC.png",import.meta.url).href,o=150,s=150,S=10,w=90,x=4e3,e=(t,n=0)=>Math.random()*(t-n)+n,_=()=>l(`from{transform:translateY(0)
|
|
2
2
|
rotateX(`,e(360),`deg)
|
|
3
3
|
rotateY(`,e(360),`deg)
|
|
4
4
|
rotateZ(`,e(360),"deg);}to{transform:translateY(calc(100vh + ",o,`px))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ax as j,j as m,ay as U,ag as z,P as $,az as _,q as X,aA as q,m as G,e as Z,r as s,l as J,aB as K,L as Q,o as oo,p as to,ad as ro,ae as eo}from"./index.
|
|
1
|
+
import{ax as j,j as m,ay as U,ag as z,P as $,az as _,q as X,aA as q,m as G,e as Z,r as s,l as J,aB as K,L as Q,o as oo,p as to,ad as ro,ae as eo}from"./index.BHyzKS4e.js";import{h as x}from"./moment.C7qA8nIE.js";import{u as no,D as ao,a as so}from"./useIntlLocale.CysOvegI.js";import{u as io}from"./useBasicWidgetState.BXKaD8DQ.js";import{S as lo}from"./styled-components.iD1HRMLc.js";import{E as co}from"./ErrorOutline.esm.C9uHPmIj.js";import"./timepicker.Bd34xjcG.js";import"./input.BCHJn1Cw.js";import"./base-input.iB32RS3w.js";import"./FormClearHelper.DQoXcOWo.js";const po=({theme:o,isInSidebar:t,step:r,minTime:c,maxTime:u,disabled:p,clearable:g,error:e})=>({Popover:{props:{ignoreBoundary:t,placement:U.bottomLeft,overrides:{Body:{style:{marginTop:o.spacing.px}}}}},CalendarContainer:{style:{fontSize:o.fontSizes.sm,paddingRight:o.spacing.sm,paddingLeft:o.spacing.sm,paddingBottom:o.spacing.none,paddingTop:o.spacing.sm}},Week:{style:{fontSize:o.fontSizes.sm}},Day:{style:({$pseudoHighlighted:i,$pseudoSelected:a,$selected:T,$isHovered:y})=>({fontSize:o.fontSizes.sm,lineHeight:o.lineHeights.base,"::before":{backgroundColor:T||a||i||y?`${o.colors.darkenedBgMix15} !important`:o.colors.transparent},"::after":{borderColor:o.colors.transparent},...G(o)&&y&&a&&!T?{color:o.colors.secondaryBg}:{}})},PrevButton:{style:()=>({display:"flex",alignItems:"center",justifyContent:"center",":active":{backgroundColor:o.colors.transparent},":focus":{backgroundColor:o.colors.transparent,outline:0}})},NextButton:{style:()=>({display:"flex",alignItems:"center",justifyContent:"center",":active":{backgroundColor:o.colors.transparent},":focus":{backgroundColor:o.colors.transparent,outline:0}})},Input:{props:{maskChar:null,endEnhancer:e&&m(q,{content:m(X,{source:e,allowHTML:!1}),placement:$.TOP_RIGHT,error:!0,children:m(_,{content:co,size:"lg"})}),overrides:{EndEnhancer:{style:{color:e?o.colors.redTextColor:o.colors.grayTextColor,backgroundColor:o.colors.transparent}},Root:{style:({$isFocused:i})=>{const a=z(o.colors,i);return{borderLeftWidth:o.sizes.borderWidth,borderRightWidth:o.sizes.borderWidth,borderTopWidth:o.sizes.borderWidth,borderBottomWidth:o.sizes.borderWidth,paddingRight:o.spacing.twoXS,borderTopColor:a,borderRightColor:a,borderBottomColor:a,borderLeftColor:a,...e&&{backgroundColor:o.colors.redBackgroundColor}}}},ClearIcon:{props:{overrides:{Svg:{style:{color:o.colors.grayTextColor,padding:o.spacing.threeXS,height:o.sizes.clearIconSize,width:o.sizes.clearIconSize,":hover":{fill:o.colors.bodyText}}}}}},InputContainer:{style:{backgroundColor:"transparent"}},Input:{style:{fontWeight:o.fontWeights.normal,paddingRight:o.spacing.sm,paddingLeft:o.spacing.md,paddingBottom:o.spacing.sm,paddingTop:o.spacing.sm,lineHeight:o.lineHeights.inputWidget,"::placeholder":{color:o.colors.fadedText60},...e&&{color:o.colors.redTextColor}},props:{"data-testid":"stDateTimeInputField"}}}}},TimeSelectContainer:{style:{paddingTop:o.spacing.none,paddingBottom:o.spacing.none}},TimeSelectFormControl:{style:{marginBottom:o.spacing.none},props:{overrides:{Label:{component:()=>null}}}},TimeSelect:{props:{step:r,format:"24",disabled:p,nullable:g,minTime:c,maxTime:u,overrides:{Select:{props:{disabled:p,overrides:{ControlContainer:{style:({$isFocused:i})=>{const a=z(o.colors,i);return{height:o.sizes.minElementHeight,borderLeftWidth:o.sizes.borderWidth,borderRightWidth:o.sizes.borderWidth,borderTopWidth:o.sizes.borderWidth,borderBottomWidth:o.sizes.borderWidth,borderTopColor:a,borderRightColor:a,borderBottomColor:a,borderLeftColor:a}}},IconsContainer:{style:()=>({paddingRight:o.spacing.sm})},ValueContainer:{style:()=>({lineHeight:o.lineHeights.inputWidget,paddingRight:o.spacing.sm,paddingLeft:o.spacing.md,paddingBottom:o.spacing.sm,paddingTop:o.spacing.sm})},SingleValue:{style:{fontWeight:o.fontWeights.normal},props:{"data-testid":"stDateTimeInputTimeDisplay"}},Dropdown:{style:()=>({paddingTop:o.spacing.none,paddingBottom:o.spacing.none,boxShadow:"none",maxHeight:o.sizes.maxDropdownHeight})},DropdownListItem:{component:lo},Popover:{props:{ignoreBoundary:t,overrides:{Body:{style:()=>({marginTop:o.spacing.px})}}}},Placeholder:{style:()=>({color:o.colors.fadedText60})},SelectArrow:{component:j,props:{overrides:{Svg:{style:()=>({width:o.iconSizes.xl,height:o.iconSizes.xl})}}}}}}}}}}}),h="YYYY/MM/DD, HH:mm",go=(o,t)=>{const r=o.getStringArrayValue(t);return r&&r.length>0?r[0]:null},uo=o=>o.default?.length?o.default[0]:null,fo=o=>o.value?.length?o.value[0]:null,k=o=>{let t;if(Array.isArray(o)?t=o.find(c=>c instanceof Date):t=o,!t||Number.isNaN(t.getTime()))return null;const r=new Date(t.getTime());return r.setSeconds(0,0),r},b=o=>{if(Z(o)||o==="")return null;const t=x(o,h,!0);return t.isValid()?k(t.toDate()):null},B=(o,t)=>o.getFullYear()===t.getFullYear()&&o.getMonth()===t.getMonth()&&o.getDate()===t.getDate(),I=(o,t)=>{const r=new Date(o.getTime());return r.setHours(t.getHours(),t.getMinutes(),0,0),r},mo=(o,t,r,c)=>{const u=b(o.min),p=b(o.max),g=e=>{t.setStringArrayValue(o,e?[e]:[],{fromUi:r.fromUi},c)};if(r.value){const e=b(r.value);if(e){u&&e<u||p&&e>p||g(r.value);return}}g(r.value)};function bo({disabled:o,element:t,widgetMgr:r,fragmentId:c}){const u=J(),p=s.useContext(K),g=s.useRef(null),[e,i]=io({getStateFromWidgetMgr:go,getDefaultStateFromProto:uo,getCurrStateFromProto:fo,updateWidgetMgrState:mo,element:t,widgetMgr:r,fragmentId:c}),{locale:a}=s.useContext(Q),T=no(a),y=t.step?Number(t.step):900,l=s.useMemo(()=>b(t.min),[t.min]),d=s.useMemo(()=>b(t.max),[t.max]),C=s.useMemo(()=>b(e),[e]),[n,v]=s.useState(C),[M,L]=s.useState(C);C!==M&&(v(C),L(C));const H=l??void 0,V=d??void 0,A=s.useMemo(()=>{if(!(!n||!l))return B(n,l)?I(n,l):void 0},[n,l]),E=s.useMemo(()=>{if(!(!n||!d))return B(n,d)?I(n,d):void 0},[n,d]),P=t.format.replaceAll(/[a-zA-Z]/g,"9"),D=`${t.format.replaceAll("Y","y").replaceAll("D","d")}, HH:mm`,R=`${P}, 99:99`,w=`${t.format}, HH:MM`,W=(t.default&&t.default.length>0?t.default[0]:"").length===0&&!o,F=s.useMemo(()=>{if(!n)return null;if(l&&n<l||d&&n>d){const f=x(l).format(D),S=x(d).format(D);return`**Error**: Date and time set outside allowed range. Please select a date and time between ${f} and ${S}.`}return null},[n,l,d,D]),O=s.useCallback(({date:f})=>{const S=k(f);v(S),g.current?.open?.()},[]),N=s.useCallback(()=>{const f=n?x(n).format(h):null;f!==e&&i({value:f,fromUi:!0})},[n,e,i]),Y=po({theme:u,isInSidebar:p,step:y,minTime:A,maxTime:E,disabled:o,clearable:W,error:F});return oo("div",{className:"stDateTimeInput","data-testid":"stDateTimeInput",children:[m(eo,{label:t.label,disabled:o,labelVisibility:to(t.labelVisibility?.value),children:t.help&&m(ro,{content:t.help,label:t.label})}),m(so,{ref:g,locale:T,density:ao.high,value:n,onChange:O,onClose:N,minDate:H,maxDate:V,disabled:o,timeSelectStart:!0,formatString:D,mask:R,placeholder:w,clearable:W,overrides:Y,"aria-label":t.label})]})}const ko=s.memo(bo);export{ko as default};
|