streamlit-nightly 1.52.3.dev20260108__py3-none-any.whl → 1.52.3.dev20260110__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/components/v2/__init__.py +3 -3
- streamlit/components/v2/types.py +4 -4
- streamlit/config.py +14 -0
- streamlit/elements/lib/options_selector_utils.py +98 -0
- streamlit/elements/widgets/multiselect.py +19 -9
- streamlit/elements/widgets/selectbox.py +12 -24
- streamlit/proto/MetricsEvent_pb2.py +4 -4
- streamlit/proto/MetricsEvent_pb2.pyi +4 -1
- streamlit/proto/PageProfile_pb2.py +6 -6
- streamlit/proto/PageProfile_pb2.pyi +11 -1
- streamlit/runtime/metrics_util.py +4 -0
- streamlit/runtime/runtime.py +3 -0
- streamlit/starlette.py +34 -0
- streamlit/static/index.html +1 -1
- streamlit/static/manifest.json +300 -300
- streamlit/static/static/js/{ErrorOutline.esm.j3b3OjAK.js → ErrorOutline.esm.BcqUpfNe.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.DCizXv6Q.js → FileDownload.esm.CtJWBuub.js} +1 -1
- streamlit/static/static/js/{FileHelper.EpMV5UVe.js → FileHelper.D0dQPhOs.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.lF7Ran5M.js → FormClearHelper.Cm3GDSk6.js} +1 -1
- streamlit/static/static/js/{InputInstructions.CMvqhPhy.js → InputInstructions.D7Hxdzwv.js} +1 -1
- streamlit/static/static/js/{Particles.DsGe8psi.js → Particles.vAUDtAR8.js} +1 -1
- streamlit/static/static/js/{ProgressBar.DzoKn4D-.js → ProgressBar.Dp2CGRba.js} +2 -2
- streamlit/static/static/js/{StreamlitSyntaxHighlighter.CFab0b_b.js → StreamlitSyntaxHighlighter.DC0000nJ.js} +1 -1
- streamlit/static/static/js/{TableChart.esm.nZsTq1Sb.js → TableChart.esm.DDVoSKOT.js} +1 -1
- streamlit/static/static/js/{Toolbar.CFMvwQYl.js → Toolbar.CuMH-Gqe.js} +1 -1
- streamlit/static/static/js/{WidgetLabelHelpIconInline.D2EEUEQX.js → WidgetLabelHelpIconInline.WAReecol.js} +1 -1
- streamlit/static/static/js/{base-input.DKTA2QNz.js → base-input.BX9Jll5o.js} +4 -4
- streamlit/static/static/js/{checkbox.D9H9J-_W.js → checkbox.BzMHUSz1.js} +1 -1
- streamlit/static/static/js/{createDownloadLinkElement.DCk6EhPM.js → createDownloadLinkElement.CviG5BQx.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.DExrGdqs.js → data-grid-overlay-editor.Dzo9A4l6.js} +1 -1
- streamlit/static/static/js/{downloader.CLJ7BreF.js → downloader.DIDvj0d5.js} +1 -1
- streamlit/static/static/js/{embed.CxOHZWx2.js → embed.C8qeQ38b.js} +6 -6
- streamlit/static/static/js/{es6.C99ebre4.js → es6.Dpcc-U7U.js} +2 -2
- streamlit/static/static/js/{formatNumber.D_w4fBsk.js → formatNumber.CPvuaBa8.js} +1 -1
- streamlit/static/static/js/{iconPosition.Cfhw1RkE.js → iconPosition.y0q-Rqem.js} +1 -1
- streamlit/static/static/js/{iframeResizer.contentWindow.BcWUIYOe.js → iframeResizer.contentWindow.DblExdXF.js} +1 -1
- streamlit/static/static/js/{index.BWK_h3IL.js → index.B-g6lwYa.js} +1 -1
- streamlit/static/static/js/{index.DoLorXMA.js → index.B10MmI2m.js} +1 -1
- streamlit/static/static/js/{index.Dx8TcTHV.js → index.B6vCS66f.js} +6 -6
- streamlit/static/static/js/{index.Bp_LrAiI.js → index.B9TG5Ah8.js} +1 -1
- streamlit/static/static/js/{index.CrJ9KZpt.js → index.BDb0PRvK.js} +1 -1
- streamlit/static/static/js/{index.1AemKTSK.js → index.BGufEmCz.js} +1 -1
- streamlit/static/static/js/{index.7Q3Iaebc.js → index.BItU4jMo.js} +1 -1
- streamlit/static/static/js/{index.D18KqoUa.js → index.BPMqWDef.js} +1 -1
- streamlit/static/static/js/index.BTHi5W25.js +1 -0
- streamlit/static/static/js/{index.BHx4Qw7z.js → index.BVN9cI-k.js} +1 -1
- streamlit/static/static/js/index.BWOP7HFT.js +1 -0
- streamlit/static/static/js/{index.DDx6TP95.js → index.BXYgO5B8.js} +1 -1
- streamlit/static/static/js/{index.DkSjHoXw.js → index.BZBWLU1C.js} +8 -8
- streamlit/static/static/js/{index.f_s01aPm.js → index.BfZdZpv-.js} +2 -2
- streamlit/static/static/js/{index.C7_5JMRC.js → index.Bxe7fKbw.js} +1 -1
- streamlit/static/static/js/{index.BcbR2mbc.js → index.C1ElSZEy.js} +1 -1
- streamlit/static/static/js/index.C26ZOVFL.js +1 -0
- streamlit/static/static/js/{index.aJ3XRx8R.js → index.C7lwRBvF.js} +1 -1
- streamlit/static/static/js/{index.CGX2fllG.js → index.C93QGPyk.js} +1 -1
- streamlit/static/static/js/{index.COjurlZk.js → index.CCDejIvL.js} +2 -2
- streamlit/static/static/js/index.CcMmNHAq.js +1 -0
- streamlit/static/static/js/index.D42y-GeO.js +1 -0
- streamlit/static/static/js/{index.C0VFHmJN.js → index.D69ULFWq.js} +1 -1
- streamlit/static/static/js/{index.V4C1Oi-F.js → index.DB4MbQ40.js} +3 -3
- streamlit/static/static/js/{index.DJ4GBc1k.js → index.DRFJgBf-.js} +1 -1
- streamlit/static/static/js/{index.BXQNt1hj.js → index.DTK-btqV.js} +1 -1
- streamlit/static/static/js/{index.CFE-yHdT.js → index.DZEQ0G7H.js} +1 -1
- streamlit/static/static/js/{index.Bu3Lto_G.js → index.DaU1ayM7.js} +1 -1
- streamlit/static/static/js/{index.DSSQzzPk.js → index.Dla9XiNe.js} +2 -2
- streamlit/static/static/js/{index.DiZfOR0A.js → index.DmQqT9OM.js} +1 -1
- streamlit/static/static/js/{index.DuFqxjbN.js → index.DppScppA.js} +1 -1
- streamlit/static/static/js/{index.Dqphk1ee.js → index.Dr8b3Vn6.js} +1 -1
- streamlit/static/static/js/{index.CPo5dtx7.js → index.DvQ7-afx.js} +1 -1
- streamlit/static/static/js/{index.ATP5607r.js → index.F-NmmwfK.js} +1 -1
- streamlit/static/static/js/{index.gnFSTAhI.js → index.MKI8t7l2.js} +1 -1
- streamlit/static/static/js/{index.BXnQdCa5.js → index.RRAKXgBZ.js} +1 -1
- streamlit/static/static/js/{index.CyVBY8PG.js → index.VSsf6tsu.js} +2 -2
- streamlit/static/static/js/{index.DcudoGfL.js → index.aEeM0ekc.js} +1 -1
- streamlit/static/static/js/{index.Ds-w0zIo.js → index.eweE9HKU.js} +1 -1
- streamlit/static/static/js/{index.CBZQ_6AF.js → index.gr6yGiCL.js} +1 -1
- streamlit/static/static/js/{index.mZ1qbnKs.js → index.kKkHk9Mc.js} +1 -1
- streamlit/static/static/js/index.pMvzHC7z.js +1 -0
- streamlit/static/static/js/{index.DIIdzDwK.js → index.pgifwCIr.js} +1 -1
- streamlit/static/static/js/index.q83b8_8b.js +1 -0
- streamlit/static/static/js/{index.BzQChe4y.js → index.u2AvcQQT.js} +1 -1
- streamlit/static/static/js/{index.CrzXL2V8.js → index.w2_VrtVw.js} +1 -1
- streamlit/static/static/js/{index.DbmtfcDm.js → index.wv1DYVsn.js} +1 -1
- streamlit/static/static/js/{index.COZICZL6.js → index.x4j6nnNb.js} +1 -1
- streamlit/static/static/js/{input.CZPD7mCu.js → input.BoJqOS7a.js} +1 -1
- streamlit/static/static/js/{main.CX1jAiMw.js → main.B5XmUwmQ.js} +1 -1
- streamlit/static/static/js/{memory.m0jC5ULx.js → memory.9izgq54V.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.Dy0iTeCo.js → number-overlay-editor.PqOGQcLn.js} +1 -1
- streamlit/static/static/js/{pandasStylerUtils.D9jj-wHU.js → pandasStylerUtils.DUtF2t3R.js} +1 -1
- streamlit/static/static/js/{sandbox.CbvG1iAz.js → sandbox.DgKTHPLO.js} +1 -1
- streamlit/static/static/js/{styled-components.Cw3ioniY.js → styled-components.D4x8jmOI.js} +1 -1
- streamlit/static/static/js/{throttle.CAwhGpn0.js → throttle.DxEHIIp7.js} +1 -1
- streamlit/static/static/js/{timepicker.Bh3m6Pjp.js → timepicker.CDks5DWI.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.DM0o32JS.js → toConsumableArray.CvTQRsV-.js} +1 -1
- streamlit/static/static/js/uniqueId.RScLN3St.js +1 -0
- streamlit/static/static/js/{useBasicWidgetState.C9zOVP8a.js → useBasicWidgetState.D6_b0IqA.js} +1 -1
- streamlit/static/static/js/{useIntlLocale.Bo42aN1U.js → useIntlLocale.Ctz17A7g.js} +1 -1
- streamlit/static/static/js/{useTextInputAutoExpand.DmyHLDxl.js → useTextInputAutoExpand.PAFB5o1T.js} +1 -1
- streamlit/static/static/js/{useUpdateUiValue.aWXWpqmw.js → useUpdateUiValue.CcTvmGlb.js} +1 -1
- streamlit/static/static/js/{useWaveformController.DlE14M1X.js → useWaveformController.vLi36Ir4.js} +1 -1
- streamlit/static/static/js/{withCalculatedWidth.B5JFJSmG.js → withCalculatedWidth.BtA2jL5-.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.dgVioHk1.js → withFullScreenWrapper.CeeoYBpc.js} +1 -1
- streamlit/web/bootstrap.py +105 -10
- streamlit/web/cli.py +21 -4
- streamlit/web/server/app_discovery.py +421 -0
- streamlit/web/server/server.py +0 -13
- streamlit/web/server/starlette/__init__.py +2 -1
- streamlit/web/server/starlette/starlette_app.py +326 -3
- streamlit/web/server/starlette/starlette_routes.py +27 -8
- {streamlit_nightly-1.52.3.dev20260108.dist-info → streamlit_nightly-1.52.3.dev20260110.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.52.3.dev20260108.dist-info → streamlit_nightly-1.52.3.dev20260110.dist-info}/RECORD +115 -113
- streamlit/static/static/js/index.BOGNGR9a.js +0 -1
- streamlit/static/static/js/index.C-lnh8pI.js +0 -1
- streamlit/static/static/js/index.C98anBCM.js +0 -1
- streamlit/static/static/js/index.CFtGP8pH.js +0 -1
- streamlit/static/static/js/index.Cg59Loqx.js +0 -1
- streamlit/static/static/js/index.CiU2Tdcl.js +0 -1
- streamlit/static/static/js/index.DpnqUQVD.js +0 -1
- streamlit/static/static/js/uniqueId.DtV_RZzG.js +0 -1
- {streamlit_nightly-1.52.3.dev20260108.data → streamlit_nightly-1.52.3.dev20260110.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.52.3.dev20260108.dist-info → streamlit_nightly-1.52.3.dev20260110.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.52.3.dev20260108.dist-info → streamlit_nightly-1.52.3.dev20260110.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.52.3.dev20260108.dist-info → streamlit_nightly-1.52.3.dev20260110.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aT as L,aU as B,aV as E,aW as O,F as A,r as n,l as H,aB as $,aX as k,j as h,aY as F,o as N,p as D,ac as P,ad as U,aZ as Y,a_ as j,ax as _,a$ as K,af as X}from"./index.BZBWLU1C.js";import{u as Z}from"./useBasicWidgetState.D6_b0IqA.js";import{a as q}from"./_arrayIncludes.B19Iyn2B.js";import"./FormClearHelper.Cm3GDSk6.js";import"./_baseIndexOf.BTknn6Gb.js";var G=200;function J(o,t,d,u){var e=-1,m=q,l=!0,p=o.length,s=[],f=t.length;if(!p)return s;t.length>=G&&(m=B,l=!1,t=new L(t));e:for(;++e<p;){var i=o[e],c=i;if(i=i!==0?i:0,l&&c===c){for(var g=f;g--;)if(t[g]===c)continue e;s.push(i)}else m(t,c,u)||s.push(i)}return s}var Q=E(function(o,t){return O(o)?J(o,t):[]});const ee=A("div",{target:"ekqzr6e0"})(({theme:o})=>({"span[aria-disabled='true']":{background:o.colors.fadedText05}})),te=(o,t)=>o.getStringArrayValue(t),oe=o=>o.default.map(t=>o.options[t])??null,re=o=>o.rawValues??null,se=(o,t,d,u)=>{t.setStringArrayValue(o,d.value,{fromUi:d.fromUi},u)},ne=o=>{const{element:t,widgetMgr:d,fragmentId:u}=o,e=H(),m=n.useContext($),l=n.useRef(null),p=n.useRef(0),[s,f]=Z({getStateFromWidgetMgr:te,getDefaultStateFromProto:oe,getCurrStateFromProto:re,updateWidgetMgrState:se,element:t,widgetMgr:d,fragmentId:u}),i=t.maxSelections>0&&s.length>=t.maxSelections,c=n.useMemo(()=>{if(t.maxSelections===0)return"No results";if(s.length===t.maxSelections){const r=t.maxSelections!==1?"options":"option";return`You can only select up to ${t.maxSelections} ${r}. Remove an option first.`}return"No results"},[t.maxSelections,s.length]),g=n.useCallback(r=>{switch(r.type){case"remove":return Q(s,r.option?.value);case"clear":return[];case"select":return s.concat([r.option?.value]);default:throw new Error(`State transition is unknown: ${r.type}`)}},[s]),C=n.useCallback(r=>{t.maxSelections&&r.type==="select"&&s.length>=t.maxSelections||f({value:g(r),fromUi:!0})},[t.maxSelections,g,f,s.length]),{options:v}=t,{placeholder:R,disabled:w,selectOptions:z,inputReadOnly:T,valuesToUiMulti:b,createFilterOptions:x}=k({options:v,isMulti:!0,acceptNewOptions:t.acceptNewOptions??!1,placeholderInput:t.placeholder}),M=n.useCallback((r,a)=>i?[]:x(s)(r,a),[x,i,s]),S=o.disabled||w,W=n.useMemo(()=>b(s),[b,s]),V=n.useMemo(()=>{const r=e.fontSizes.baseFontSize*1.6+14;return`${Math.round(r*4.25)}px`},[e.fontSizes.baseFontSize]);n.useLayoutEffect(()=>{l.current&&(l.current.scrollTop=p.current)});const y=n.useCallback(r=>{p.current=r.currentTarget.scrollTop},[]),I=n.useMemo(()=>(function(a){return h(F,{...a,ref:l,onScroll:y})}),[y]);return N("div",{className:"stMultiSelect","data-testid":"stMultiSelect",children:[h(U,{label:t.label,disabled:S,labelVisibility:D(t.labelVisibility?.value),children:t.help&&h(P,{content:t.help,label:t.label})}),h(ee,{children:h(Y,{creatable:t.acceptNewOptions??!1,options:z,labelKey:"label",valueKey:"value","aria-label":t.label,placeholder:R,type:K.select,multi:!0,onChange:C,value:W,disabled:S,size:"compact",noResultsMsg:c,filterOptions:M,closeOnSelect:!1,ignoreCase:!1,overrides:{Popover:{props:{ignoreBoundary:m,overrides:{Body:{style:()=>({marginTop:e.spacing.px})}}}},SelectArrow:{component:_,props:{style:{cursor:"pointer"},overrides:{Svg:{style:()=>({width:e.iconSizes.xl,height:e.iconSizes.xl})}}}},IconsContainer:{style:()=>({paddingRight:e.spacing.sm})},ControlContainer:{style:({$isFocused:r})=>{const a=X(e.colors,r);return{maxHeight:V,minHeight:e.sizes.minElementHeight,borderLeftWidth:e.sizes.borderWidth,borderRightWidth:e.sizes.borderWidth,borderTopWidth:e.sizes.borderWidth,borderBottomWidth:e.sizes.borderWidth,borderTopColor:a,borderRightColor:a,borderBottomColor:a,borderLeftColor:a}}},Placeholder:{style:()=>({flex:"inherit",color:S?e.colors.fadedText40:e.colors.fadedText60})},ValueContainer:{component:I,style:()=>({overflowY:"auto",paddingLeft:e.spacing.sm,paddingTop:e.spacing.none,paddingBottom:e.spacing.none,paddingRight:e.spacing.none})},ClearIcon:{props:{overrides:{Svg:{style:{color:e.colors.grayTextColor,padding:e.spacing.threeXS,height:e.sizes.clearIconSize,width:e.sizes.clearIconSize,cursor:"pointer",":hover":{fill:e.colors.bodyText}}}}}},SearchIcon:{style:{color:e.colors.grayTextColor}},Tag:{props:{overrides:{Root:{style:{fontWeight:e.fontWeights.normal,borderTopLeftRadius:e.radii.md,borderTopRightRadius:e.radii.md,borderBottomRightRadius:e.radii.md,borderBottomLeftRadius:e.radii.md,fontSize:e.fontSizes.md,paddingLeft:e.spacing.sm,marginLeft:e.spacing.none,marginRight:e.spacing.sm,height:`calc(${e.sizes.minElementHeight} - 2 * ${e.spacing.xs})`,maxWidth:`calc(100% - ${e.spacing.lg})`,cursor:"default !important"}},Action:{style:{paddingLeft:0}},ActionIcon:{props:{overrides:{Svg:{style:{width:"0.625em",height:"0.625em"}}}}}}}},MultiValue:{props:{overrides:{Root:{style:{fontSize:e.fontSizes.sm}}}}},Input:{props:{readOnly:T}},Dropdown:{component:j}}})})]})},ue=n.memo(ne);export{ue as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,E as L,_ as k,F as p,aR as Ue,o as S,j as l,ay as I,b as V,c as ve,B as R,h as ze,a0 as be,k as Ce,ak as ee,bi as Ie,e as D,bW as Ee,p as Be,ab as De,ac as Le,bR as ke,bS as Ve}from"./index.DkSjHoXw.js";import{u as Re}from"./FormClearHelper.lF7Ran5M.js";import{g as oe,F as M,a as Me,D as Ae,I as Pe,s as Ne,b as Te}from"./FileHelper.EpMV5UVe.js";import{S as qe,P as We}from"./ProgressBar.DzoKn4D-.js";import{U as $}from"./UploadFileInfo.Dr-zDST7.js";const He=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 re=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"}))});re.displayName="ChevronRight";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 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"}))});ae.displayName="Clear";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:"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"}))});le.displayName="CloudUpload";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",{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"}))});se.displayName="Error";const ie=p("section",{target:"e7fhruq0"})(({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:`0 0 0 1px ${t.colors.primary}`},cursor:e?"not-allowed":"pointer"})),$e=p("div",{target:"e7fhruq1"})(({theme:e})=>({marginRight:"auto",alignItems:"center",display:"flex",gap:e.spacing.lg,minWidth:0,width:"100%"})),ce=p("span",{target:"e7fhruq2"})(({theme:e})=>({color:e.colors.darkenedBgMix100})),de=p("span",{target:"e7fhruq3"})(({theme:e,disabled:t})=>({color:t?e.colors.fadedText40:e.colors.bodyText})),je=p("span",{target:"e7fhruq4"})(({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%"})),Xe=p("div",{target:"e7fhruq5"})({display:"flex",flexDirection:"column",minWidth:0,maxWidth:"100%"}),Oe=p("span",{target:"e7fhruq6"})({whiteSpace:"nowrap"}),pe=p("div",{target:"e7fhruq7"})(({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:"e7fhruq8"})(({theme:e})=>({listStyleType:"none",margin:e.spacing.none,padding:e.spacing.none})),ue=p("li",{target:"e7fhruq9"})(({theme:e})=>({margin:e.spacing.none,padding:e.spacing.none})),ge=p("div",{target:"e7fhruq10"})(({theme:e})=>({display:"flex",alignItems:"baseline",flex:1,paddingLeft:e.spacing.lg,overflow:"hidden"})),fe=p("div",{target:"e7fhruq11"})(({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:"e7fhruq12"})(({theme:e})=>({display:"flex",alignItems:"center",marginBottom:e.spacing.twoXS})),Ke=p("span",{target:"e7fhruq13"})(({theme:e})=>({marginRight:e.spacing.twoXS})),Ye=p("div",{target:"e7fhruq14"})(({theme:e,disabled:t})=>({display:"flex",padding:e.spacing.twoXS,color:t?e.colors.fadedText40:e.colors.darkenedBgMix100})),Fe=p("small",{target:"e7fhruq15"})(({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:"e7fhruq16"})({}),Ge=e=>({[ie]:{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:"e7fhruq17"})(({theme:e,width:t})=>{if(t<Ue("23rem"))return Ge(e)}),Qe=({multiple:e,acceptedExtensions:t,maxSizeBytes:n,acceptDirectory:s=!1,disabled:d})=>{const x=()=>s?"directories":e?"files":"file",c=()=>t.length?` • ${t.map(y=>y.replace(/^\./,"").toUpperCase()).join(", ")}`:null,F=()=>`Limit ${oe(n,M.Byte,0)} per file`;return S($e,{"data-testid":"stFileUploaderDropzoneInstructions",children:[l(ce,{children:l(I,{content:le,size:"threeXL"})}),S(Xe,{children:[S(de,{disabled:d,children:["Drag and drop ",x()," here"]}),S(je,{disabled:d,children:[F(),c()]})]})]})},Ze=o.memo(Qe),et=({onDrop:e,multiple:t,acceptedExtensions:n,maxSizeBytes:s,disabled:d,label:x,acceptDirectory:c=!1})=>l(Ae,{onDrop:e,multiple:t,accept:Me(n),maxSize:s,disabled:d,useFsAccessApi:!1,children:({getRootProps:F,getInputProps:y})=>{const v=y({multiple:t||!!c});return S(ie,{...F(),"data-testid":"stFileUploaderDropzone",isDisabled:d,"aria-label":x,"aria-disabled":d,children:[l("input",{"data-testid":"stFileUploaderDropzoneInput",...v,...c&&{webkitdirectory:""}}),l(Ze,{multiple:t,acceptedExtensions:n,maxSizeBytes:s,acceptDirectory:c,disabled:d}),l(Oe,{children:l(V,{kind:R.SECONDARY,disabled:d,size:ve.SMALL,children:c?"Browse directories":"Browse files"})})]})}}),tt=o.memo(et),ye=p("small",{target:"e1xq3mgd0"})(({kind:e,disabled:t,theme:n})=>{const{redTextColor:s,fadedText60:d,fadedText40:x}=n.colors;let c=d;return t&&(c=x),e==="danger"&&(c=s),{color:c,fontSize:n.fontSizes.sm,lineHeight:n.lineHeights.tight}}),ot=({fileInfo:e,disabled:t})=>e.status.type==="uploading"?l(We,{value:e.status.progress,size:qe.SMALL}):e.status.type==="error"?S(Fe,{children:[l(Ke,{"data-testid":"stFileUploaderFileErrorMessage",children:e.status.errorMessage}),l(me,{children:l(I,{content:se,size:"lg"})})]}):e.status.type==="uploaded"?l(ye,{disabled:t,children:oe(e.size,M.Byte)}):null,nt=({fileInfo:e,onDelete:t,disabled:n})=>S(he,{className:"stFileUploaderFile","data-testid":"stFileUploaderFile",children:[l(Ye,{disabled:n,children:l(I,{content:Pe,size:"twoXL"})}),S(ge,{className:"stFileUploaderFileData",children:[l(fe,{className:"stFileUploaderFileName","data-testid":"stFileUploaderFileName",title:e.name,disabled:n,children:e.name}),l(ot,{fileInfo:e,disabled:n})]}),l("div",{"data-testid":"stFileUploaderDeleteBtn",children:l(V,{onClick:()=>t(e.id),kind:R.MINIMAL,disabled:n,"aria-label":`Remove ${e.name}`,children:l(I,{content:ae,size:"lg"})})})]}),rt=o.memo(nt),at=p("div",{target:"e1o0u1j0"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:e.spacing.twoXS,marginBottom:e.spacing.twoXS})),lt=p("div",{target:"e1o0u1j1"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.colors.fadedText40})),st=({currentPage:e,totalPages:t,onNext:n,onPrevious:s})=>S(at,{"data-testid":"stFileUploaderPagination",children:[l(ye,{children:`Showing page ${e} of ${t}`}),S(lt,{children:[l(V,{onClick:s,kind:R.MINIMAL,children:l(I,{content:ne,size:"xl"})}),l(V,{onClick:n,kind:R.MINIMAL,children:l(I,{content:re,size:"xl"})})]})]}),it=o.memo(st),te=(e,t)=>Math.ceil(e.length/t),ct=e=>ze(({pageSize:n,items:s,resetOnAdd:d,...x})=>{const[c,F]=o.useState(0),[y,v]=o.useState(()=>te(s,n)),u=He(s);o.useEffect(()=>{u&&u.length!==s.length&&v(te(s,n)),u&&u.length<s.length?d&&F(0):c+1>=y&&F(y-1)},[s,c,n,u,d,y]);const E=()=>{F(Math.min(c+1,y-1))},z=()=>{F(Math.max(0,c-1))},A=s.slice(c*n,c*n+n);return S(be,{children:[l(e,{items:A,...x}),s.length>n?l(it,{pageSize:n,totalPages:y,currentPage:c+1,onNext:E,onPrevious:z}):null]})},e),dt=({items:e,onDelete:t,disabled:n})=>l(_e,{children:e.map(s=>l(ue,{children:l(rt,{fileInfo:s,onDelete:t,disabled:n})},s.id))}),pt=ct(dt),ut=e=>l(pe,{children:l(pt,{...e})}),gt=o.memo(ut),ft=(e,t)=>{const n=t.getFileUploaderStateValue(e);if(D(n))return{files:[],nextLocalId:1};const{uploadedFileInfo:s}=n;if(D(s)||s.length===0)return{files:[],nextLocalId:1};let d=1;return{files:s.map(c=>{const F=c.name,y=c.size,v=c.fileId,u=c.fileUrls,E=new $(F,y,d,{type:"uploaded",fileId:v,fileUrls:u});return d+=1,E}),nextLocalId:d}},H=e=>{const t=e.filter(n=>n.status.type==="uploaded").map(n=>{const{name:s,size:d,status:x}=n,{fileId:c,fileUrls:F}=x;return new ke({fileId:c,fileUrls:F,name:s,size:d})});return new Ve({uploadedFileInfo:t})},ht=({disabled:e,element:t,widgetMgr:n,uploadClient:s,fragmentId:d})=>{const{width:x,elementRef:c}=Ce(),{files:F,nextLocalId:y}=o.useMemo(()=>ft(t,n),[t,n]),v=o.useRef(y),[u,E]=o.useState(()=>F),z=o.useRef(u);o.useEffect(()=>{z.current=u},[u]);const[A,j]=o.useState(!1),B=o.useCallback(()=>{const r=v.current;return v.current+=1,r},[]),P=o.useMemo(()=>{const r=t.maxUploadSizeMb;return Ne(r,M.Megabyte,M.Byte)},[t.maxUploadSizeMb]),U=o.useCallback(r=>{ee.flushSync(()=>{E(a=>{const i=typeof r=="function"?r(a):r;return z.current=i,i})})},[]),N=o.useCallback(r=>{ee.flushSync(()=>{j(r)})},[j]),X=o.useCallback(r=>{U(a=>[...a,r])},[U]),T=o.useCallback(r=>{r.length!==0&&U(a=>[...a,...r])},[U]),O=o.useCallback(r=>{U(a=>a.filter(i=>i.id!==r))},[U]),b=o.useCallback((r,a)=>{U(i=>i.map(g=>g.id===r?a:g))},[U]),C=o.useCallback(r=>z.current.find(a=>a.id===r),[]),_=u.some(r=>r.status.type==="uploading")||A?"updating":"ready";o.useEffect(()=>{n.getFileUploaderStateValue(t)===void 0&&n.setFileUploaderStateValue(t,H(z.current),{fromUi:!1},d)},[n,t,d]),o.useEffect(()=>{if(_!=="ready")return;const r=H(u),a=n.getFileUploaderStateValue(t);Ie(r,a)||n.setFileUploaderStateValue(t,r,{fromUi:!0},d)},[_,u,n,t,d]);const xe=o.useCallback(()=>{U(()=>[]);const r=H([]);n.setFileUploaderStateValue(t,r,{fromUi:!0},d)},[t,d,U,n]);Re({element:t,widgetMgr:n,onFormCleared:xe});const K=o.useCallback(r=>{const a=t.type;if(!a||a.length===0)return!0;const i=r.name.toLowerCase();return a.some(g=>i.endsWith(g.toLowerCase()))},[t.type]),Y=o.useCallback(r=>{const a=[],i=[];return r.forEach(g=>{K(g)?a.push(g):i.push({file:g,errors:[{code:"file-invalid-type",message:`${g.type} files are not allowed.`}]})}),{accepted:a,rejected:i}},[K]),G=o.useCallback((r,a)=>{const i=C(r);D(i)||i.status.type!=="uploading"||b(i.id,i.setStatus({type:"uploaded",fileId:a.fileId,fileUrls:a}))},[C,b]),J=o.useCallback((r,a)=>{const i=C(a);if(D(i)||i.status.type!=="uploading")return;const g=Math.round(r.loaded*100/r.total);i.status.progress!==g&&b(a,i.setStatus({type:"uploading",abortController:i.status.abortController,progress:g}))},[C,b]),Q=o.useCallback((r,a)=>{const i=new AbortController,g=a.webkitRelativePath||a.name,f=new $(g,a.size,B(),{type:"uploading",abortController:i,progress:1});X(f),s.uploadFile(t,r.uploadUrl,a,h=>J(h,f.id),i.signal).then(()=>G(f.id,r)).catch(h=>{h instanceof DOMException&&h.name==="AbortError"||b(f.id,f.setStatus({type:"error",errorMessage:h?h.toString():"Unknown error"}))})},[X,t,B,G,J,b,s]),q=o.useCallback(r=>{if(e)return;const a=C(r);D(a)||(a.status.type==="uploading"&&a.status.abortController.abort(),a.status.type==="uploaded"&&a.status.fileUrls.deleteUrl&&s.deleteFile(a.status.fileUrls.deleteUrl),O(r))},[e,C,O,s]),Se=o.useCallback((r,a)=>{const{multipleFiles:i}=t,g=!!t.acceptDirectory;let f=[...r],h=[...a];if(g&&f.length>0){const{accepted:w,rejected:m}=Y(f);f=w,h=[...h,...m]}if(!i&&f.length===0&&h.length>1){const w=h.findIndex(m=>m.errors.length===1&&m.errors[0].code==="too-many-files");w>=0&&(f.push(h[w].file),h.splice(w,1))}if(s.fetchFileURLs(f).then(w=>{if(!i&&f.length>0){const m=z.current.find(W=>W.status.type!=="error");if(m){N(!0);try{q(m.id)}finally{N(!1)}}}Ee(w,f).forEach(([m,W])=>{Q(m,W)})}).catch(w=>{T(f.map(m=>new $(m.name,m.size,B(),{type:"error",errorMessage:w})))}),h.length>0){const w=h.map(m=>Te(m,B(),P));T(w)}},[T,q,t,Y,P,B,s,Q,N]),Z=o.useMemo(()=>u.slice().reverse(),[u]),we=t.type;return S(Je,{className:"stFileUploader","data-testid":"stFileUploader",width:x,ref:c,children:[l(Le,{label:t.label,disabled:e,labelVisibility:Be(t.labelVisibility?.value),children:t.help&&l(De,{content:t.help,label:t.label})}),l(tt,{onDrop:Se,multiple:t.multipleFiles,acceptedExtensions:we,maxSizeBytes:P,label:t.label,disabled:e,acceptDirectory:!!t.acceptDirectory}),Z.length>0&&l(gt,{items:Z,pageSize:3,onDelete:q,resetOnAdd:!0,disabled:e})]})},wt=o.memo(ht);export{wt as default};
|
|
1
|
+
import{r as o,E as L,_ as k,F as p,ab as Ue,o as S,j as l,az as I,b as V,c as ve,B as M,h as ze,a0 as be,k as Ce,al as ee,bj as Ie,e as D,bX as Ee,p as Be,ac as De,ad as Le,bS as ke,bT as Ve}from"./index.BZBWLU1C.js";import{u as Me}from"./FormClearHelper.Cm3GDSk6.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.D0dQPhOs.js";import{S as qe,P as We}from"./ProgressBar.Dp2CGRba.js";import{U as $}from"./UploadFileInfo.Dr-zDST7.js";const He=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 re=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"}))});re.displayName="ChevronRight";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 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"}))});ae.displayName="Clear";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:"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"}))});le.displayName="CloudUpload";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",{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"}))});se.displayName="Error";const ie=p("section",{target:"e7fhruq0"})(({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:`0 0 0 1px ${t.colors.primary}`},cursor:e?"not-allowed":"pointer"})),$e=p("div",{target:"e7fhruq1"})(({theme:e})=>({marginRight:"auto",alignItems:"center",display:"flex",gap:e.spacing.lg,minWidth:0,width:"100%"})),ce=p("span",{target:"e7fhruq2"})(({theme:e})=>({color:e.colors.darkenedBgMix100})),de=p("span",{target:"e7fhruq3"})(({theme:e,disabled:t})=>({color:t?e.colors.fadedText40:e.colors.bodyText})),je=p("span",{target:"e7fhruq4"})(({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%"})),Xe=p("div",{target:"e7fhruq5"})({display:"flex",flexDirection:"column",minWidth:0,maxWidth:"100%"}),Oe=p("span",{target:"e7fhruq6"})({whiteSpace:"nowrap"}),pe=p("div",{target:"e7fhruq7"})(({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:"e7fhruq8"})(({theme:e})=>({listStyleType:"none",margin:e.spacing.none,padding:e.spacing.none})),ue=p("li",{target:"e7fhruq9"})(({theme:e})=>({margin:e.spacing.none,padding:e.spacing.none})),ge=p("div",{target:"e7fhruq10"})(({theme:e})=>({display:"flex",alignItems:"baseline",flex:1,paddingLeft:e.spacing.lg,overflow:"hidden"})),fe=p("div",{target:"e7fhruq11"})(({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:"e7fhruq12"})(({theme:e})=>({display:"flex",alignItems:"center",marginBottom:e.spacing.twoXS})),Ke=p("span",{target:"e7fhruq13"})(({theme:e})=>({marginRight:e.spacing.twoXS})),Ye=p("div",{target:"e7fhruq14"})(({theme:e,disabled:t})=>({display:"flex",padding:e.spacing.twoXS,color:t?e.colors.fadedText40:e.colors.darkenedBgMix100})),Fe=p("small",{target:"e7fhruq15"})(({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:"e7fhruq16"})({}),Ge=e=>({[ie]:{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:"e7fhruq17"})(({theme:e,width:t})=>{if(t<Ue("23rem"))return Ge(e)}),Qe=({multiple:e,acceptedExtensions:t,maxSizeBytes:n,acceptDirectory:s=!1,disabled:d})=>{const x=()=>s?"directories":e?"files":"file",c=()=>t.length?` • ${t.map(y=>y.replace(/^\./,"").toUpperCase()).join(", ")}`:null,F=()=>`Limit ${oe(n,R.Byte,0)} per file`;return S($e,{"data-testid":"stFileUploaderDropzoneInstructions",children:[l(ce,{children:l(I,{content:le,size:"threeXL"})}),S(Xe,{children:[S(de,{disabled:d,children:["Drag and drop ",x()," here"]}),S(je,{disabled:d,children:[F(),c()]})]})]})},Ze=o.memo(Qe),et=({onDrop:e,multiple:t,acceptedExtensions:n,maxSizeBytes:s,disabled:d,label:x,acceptDirectory:c=!1})=>l(Ae,{onDrop:e,multiple:t,accept:Re(n),maxSize:s,disabled:d,useFsAccessApi:!1,children:({getRootProps:F,getInputProps:y})=>{const v=y({multiple:t||!!c});return S(ie,{...F(),"data-testid":"stFileUploaderDropzone",isDisabled:d,"aria-label":x,"aria-disabled":d,children:[l("input",{"data-testid":"stFileUploaderDropzoneInput",...v,...c&&{webkitdirectory:""}}),l(Ze,{multiple:t,acceptedExtensions:n,maxSizeBytes:s,acceptDirectory:c,disabled:d}),l(Oe,{children:l(V,{kind:M.SECONDARY,disabled:d,size:ve.SMALL,children:c?"Browse directories":"Browse files"})})]})}}),tt=o.memo(et),ye=p("small",{target:"e1xq3mgd0"})(({kind:e,disabled:t,theme:n})=>{const{redTextColor:s,fadedText60:d,fadedText40:x}=n.colors;let c=d;return t&&(c=x),e==="danger"&&(c=s),{color:c,fontSize:n.fontSizes.sm,lineHeight:n.lineHeights.tight}}),ot=({fileInfo:e,disabled:t})=>e.status.type==="uploading"?l(We,{value:e.status.progress,size:qe.SMALL}):e.status.type==="error"?S(Fe,{children:[l(Ke,{"data-testid":"stFileUploaderFileErrorMessage",children:e.status.errorMessage}),l(me,{children:l(I,{content:se,size:"lg"})})]}):e.status.type==="uploaded"?l(ye,{disabled:t,children:oe(e.size,R.Byte)}):null,nt=({fileInfo:e,onDelete:t,disabled:n})=>S(he,{className:"stFileUploaderFile","data-testid":"stFileUploaderFile",children:[l(Ye,{disabled:n,children:l(I,{content:Pe,size:"twoXL"})}),S(ge,{className:"stFileUploaderFileData",children:[l(fe,{className:"stFileUploaderFileName","data-testid":"stFileUploaderFileName",title:e.name,disabled:n,children:e.name}),l(ot,{fileInfo:e,disabled:n})]}),l("div",{"data-testid":"stFileUploaderDeleteBtn",children:l(V,{onClick:()=>t(e.id),kind:M.MINIMAL,disabled:n,"aria-label":`Remove ${e.name}`,children:l(I,{content:ae,size:"lg"})})})]}),rt=o.memo(nt),at=p("div",{target:"e1o0u1j0"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:e.spacing.twoXS,marginBottom:e.spacing.twoXS})),lt=p("div",{target:"e1o0u1j1"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.colors.fadedText40})),st=({currentPage:e,totalPages:t,onNext:n,onPrevious:s})=>S(at,{"data-testid":"stFileUploaderPagination",children:[l(ye,{children:`Showing page ${e} of ${t}`}),S(lt,{children:[l(V,{onClick:s,kind:M.MINIMAL,children:l(I,{content:ne,size:"xl"})}),l(V,{onClick:n,kind:M.MINIMAL,children:l(I,{content:re,size:"xl"})})]})]}),it=o.memo(st),te=(e,t)=>Math.ceil(e.length/t),ct=e=>ze(({pageSize:n,items:s,resetOnAdd:d,...x})=>{const[c,F]=o.useState(0),[y,v]=o.useState(()=>te(s,n)),u=He(s);o.useEffect(()=>{u&&u.length!==s.length&&v(te(s,n)),u&&u.length<s.length?d&&F(0):c+1>=y&&F(y-1)},[s,c,n,u,d,y]);const E=()=>{F(Math.min(c+1,y-1))},z=()=>{F(Math.max(0,c-1))},A=s.slice(c*n,c*n+n);return S(be,{children:[l(e,{items:A,...x}),s.length>n?l(it,{pageSize:n,totalPages:y,currentPage:c+1,onNext:E,onPrevious:z}):null]})},e),dt=({items:e,onDelete:t,disabled:n})=>l(_e,{children:e.map(s=>l(ue,{children:l(rt,{fileInfo:s,onDelete:t,disabled:n})},s.id))}),pt=ct(dt),ut=e=>l(pe,{children:l(pt,{...e})}),gt=o.memo(ut),ft=(e,t)=>{const n=t.getFileUploaderStateValue(e);if(D(n))return{files:[],nextLocalId:1};const{uploadedFileInfo:s}=n;if(D(s)||s.length===0)return{files:[],nextLocalId:1};let d=1;return{files:s.map(c=>{const F=c.name,y=c.size,v=c.fileId,u=c.fileUrls,E=new $(F,y,d,{type:"uploaded",fileId:v,fileUrls:u});return d+=1,E}),nextLocalId:d}},H=e=>{const t=e.filter(n=>n.status.type==="uploaded").map(n=>{const{name:s,size:d,status:x}=n,{fileId:c,fileUrls:F}=x;return new ke({fileId:c,fileUrls:F,name:s,size:d})});return new Ve({uploadedFileInfo:t})},ht=({disabled:e,element:t,widgetMgr:n,uploadClient:s,fragmentId:d})=>{const{width:x,elementRef:c}=Ce(),{files:F,nextLocalId:y}=o.useMemo(()=>ft(t,n),[t,n]),v=o.useRef(y),[u,E]=o.useState(()=>F),z=o.useRef(u);o.useEffect(()=>{z.current=u},[u]);const[A,j]=o.useState(!1),B=o.useCallback(()=>{const r=v.current;return v.current+=1,r},[]),P=o.useMemo(()=>{const r=t.maxUploadSizeMb;return Ne(r,R.Megabyte,R.Byte)},[t.maxUploadSizeMb]),U=o.useCallback(r=>{ee.flushSync(()=>{E(a=>{const i=typeof r=="function"?r(a):r;return z.current=i,i})})},[]),N=o.useCallback(r=>{ee.flushSync(()=>{j(r)})},[j]),X=o.useCallback(r=>{U(a=>[...a,r])},[U]),T=o.useCallback(r=>{r.length!==0&&U(a=>[...a,...r])},[U]),O=o.useCallback(r=>{U(a=>a.filter(i=>i.id!==r))},[U]),b=o.useCallback((r,a)=>{U(i=>i.map(g=>g.id===r?a:g))},[U]),C=o.useCallback(r=>z.current.find(a=>a.id===r),[]),_=u.some(r=>r.status.type==="uploading")||A?"updating":"ready";o.useEffect(()=>{n.getFileUploaderStateValue(t)===void 0&&n.setFileUploaderStateValue(t,H(z.current),{fromUi:!1},d)},[n,t,d]),o.useEffect(()=>{if(_!=="ready")return;const r=H(u),a=n.getFileUploaderStateValue(t);Ie(r,a)||n.setFileUploaderStateValue(t,r,{fromUi:!0},d)},[_,u,n,t,d]);const xe=o.useCallback(()=>{U(()=>[]);const r=H([]);n.setFileUploaderStateValue(t,r,{fromUi:!0},d)},[t,d,U,n]);Me({element:t,widgetMgr:n,onFormCleared:xe});const K=o.useCallback(r=>{const a=t.type;if(!a||a.length===0)return!0;const i=r.name.toLowerCase();return a.some(g=>i.endsWith(g.toLowerCase()))},[t.type]),Y=o.useCallback(r=>{const a=[],i=[];return r.forEach(g=>{K(g)?a.push(g):i.push({file:g,errors:[{code:"file-invalid-type",message:`${g.type} files are not allowed.`}]})}),{accepted:a,rejected:i}},[K]),G=o.useCallback((r,a)=>{const i=C(r);D(i)||i.status.type!=="uploading"||b(i.id,i.setStatus({type:"uploaded",fileId:a.fileId,fileUrls:a}))},[C,b]),J=o.useCallback((r,a)=>{const i=C(a);if(D(i)||i.status.type!=="uploading")return;const g=Math.round(r.loaded*100/r.total);i.status.progress!==g&&b(a,i.setStatus({type:"uploading",abortController:i.status.abortController,progress:g}))},[C,b]),Q=o.useCallback((r,a)=>{const i=new AbortController,g=a.webkitRelativePath||a.name,f=new $(g,a.size,B(),{type:"uploading",abortController:i,progress:1});X(f),s.uploadFile(t,r.uploadUrl,a,h=>J(h,f.id),i.signal).then(()=>G(f.id,r)).catch(h=>{h instanceof DOMException&&h.name==="AbortError"||b(f.id,f.setStatus({type:"error",errorMessage:h?h.toString():"Unknown error"}))})},[X,t,B,G,J,b,s]),q=o.useCallback(r=>{if(e)return;const a=C(r);D(a)||(a.status.type==="uploading"&&a.status.abortController.abort(),a.status.type==="uploaded"&&a.status.fileUrls.deleteUrl&&s.deleteFile(a.status.fileUrls.deleteUrl),O(r))},[e,C,O,s]),Se=o.useCallback((r,a)=>{const{multipleFiles:i}=t,g=!!t.acceptDirectory;let f=[...r],h=[...a];if(g&&f.length>0){const{accepted:w,rejected:m}=Y(f);f=w,h=[...h,...m]}if(!i&&f.length===0&&h.length>1){const w=h.findIndex(m=>m.errors.length===1&&m.errors[0].code==="too-many-files");w>=0&&(f.push(h[w].file),h.splice(w,1))}if(s.fetchFileURLs(f).then(w=>{if(!i&&f.length>0){const m=z.current.find(W=>W.status.type!=="error");if(m){N(!0);try{q(m.id)}finally{N(!1)}}}Ee(w,f).forEach(([m,W])=>{Q(m,W)})}).catch(w=>{T(f.map(m=>new $(m.name,m.size,B(),{type:"error",errorMessage:w})))}),h.length>0){const w=h.map(m=>Te(m,B(),P));T(w)}},[T,q,t,Y,P,B,s,Q,N]),Z=o.useMemo(()=>u.slice().reverse(),[u]),we=t.type;return S(Je,{className:"stFileUploader","data-testid":"stFileUploader",width:x,ref:c,children:[l(Le,{label:t.label,disabled:e,labelVisibility:Be(t.labelVisibility?.value),children:t.help&&l(De,{content:t.help,label:t.label})}),l(tt,{onDrop:Se,multiple:t.multipleFiles,acceptedExtensions:we,maxSizeBytes:P,label:t.label,disabled:e,acceptDirectory:!!t.acceptDirectory}),Z.length>0&&l(gt,{items:Z,pageSize:3,onDelete:q,resetOnAdd:!0,disabled:e})]})},wt=o.memo(ht);export{wt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as T,r as i,V as b,a3 as L,j as p,W as N}from"./index.
|
|
1
|
+
import{F as T,r as i,V as b,a3 as L,j as p,W as N}from"./index.BZBWLU1C.js";const U=T("iframe",{target:"e655cq30"})(({theme:r})=>({colorScheme:"normal",border:"none",padding:r.spacing.none,margin:r.spacing.none,width:"100%",aspectRatio:"16 / 9"})),R=N.getLogger("Video"),A={width:"100%"};function O({element:r,endpoints:s,elementMgr:f}){const n=i.useRef(null),{type:v,url:c,startTime:a,subtitles:l,endTime:o,loop:d,autoplay:m,muted:E}=r;let y=b(c);const S=i.useMemo(()=>{if(!r.id)return!0;const e=f.getElementState(r.id,"preventAutoplay");return e||f.setElementState(r.id,"preventAutoplay",!0),e??!1},[r.id,f]),g=i.useMemo(()=>JSON.stringify(l?l.map(e=>s.buildMediaURL(`${e.url}`)):[]),[l,s]);i.useEffect(()=>{const e=JSON.parse(g);e.length!==0&&e.forEach(t=>{s.checkSourceUrlResponse(t,"Video Subtitle")})},[g,s]),i.useEffect(()=>{n.current&&(n.current.currentTime=a)},[a]),i.useEffect(()=>{const e=n.current,t=()=>{e&&(e.currentTime=r.startTime)};return e&&e.addEventListener("loadedmetadata",t),()=>{e&&e.removeEventListener("loadedmetadata",t)}},[r]),i.useEffect(()=>{const e=n.current;if(!e)return;let t=!1;const u=()=>{o>0&&e.currentTime>=o&&(d?(e.currentTime=a||0,e.play()):t||(t=!0,e.pause()))};return o>0&&e.addEventListener("timeupdate",u),()=>{e&&o>0&&e.removeEventListener("timeupdate",u)}},[o,d,a]),i.useEffect(()=>{const e=n.current;if(!e)return;const t=()=>{d&&(e.currentTime=a||0,e.play())};return e.addEventListener("ended",t),()=>{e&&e.removeEventListener("ended",t)}},[d,a]);const V=e=>{const t=new URL(e);if(a&&!isNaN(a)&&t.searchParams.append("start",a.toString()),o&&!isNaN(o)&&t.searchParams.append("end",o.toString()),d){t.searchParams.append("loop","1");const u=t.pathname.split("/").pop();u&&t.searchParams.append("playlist",u)}return m&&t.searchParams.append("autoplay","1"),E&&t.searchParams.append("mute","1"),t.toString()};if(v===L.Type.YOUTUBE_IFRAME)return p(U,{className:"stVideo","data-testid":"stVideo",title:c,src:V(c),allow:"autoplay; encrypted-media",allowFullScreen:!0});const h=e=>{const t=e.currentTarget.src;R.error(`Client Error: Video source error - ${t}`),s.sendClientErrorToHost("Video","Video source failed to load","onerror triggered",t)};return p("video",{className:"stVideo","data-testid":"stVideo",ref:n,controls:!0,muted:E,autoPlay:m&&!S,src:s.buildMediaURL(c),style:A,crossOrigin:y,onError:h,children:l?.map((e,t)=>p("track",{kind:"captions",src:s.buildMediaURL(`${e.url}`),label:`${e.label}`,default:t===0,"data-testid":"stVideoSubtitle"},t))})}const $=i.memo(O);export{$ as default};
|