streamlit-nightly 1.42.1.dev20250216__py2.py3-none-any.whl → 1.42.2.dev20250218__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/elements/bokeh_chart.py +5 -4
- streamlit/elements/graphviz_chart.py +2 -3
- streamlit/elements/lib/column_types.py +97 -44
- streamlit/elements/lib/subtitle_utils.py +2 -2
- streamlit/elements/lib/utils.py +1 -2
- streamlit/elements/vega_charts.py +2 -5
- streamlit/runtime/caching/cache_utils.py +2 -3
- streamlit/runtime/caching/hashing.py +1 -2
- streamlit/runtime/forward_msg_cache.py +1 -5
- streamlit/runtime/fragment.py +3 -5
- streamlit/runtime/memory_media_file_storage.py +1 -2
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{FileDownload.esm.K0RIIaSL.js → FileDownload.esm.DU-1rCSB.js} +1 -1
- streamlit/static/static/js/{FileDropzone.DRcTUuNN.js → FileDropzone.BI3MGDdT.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.Dha_cfuU.js → FormClearHelper.DzU-mNjk.js} +1 -1
- streamlit/static/static/js/{Hooks.BrulV197.js → Hooks.qUbVZL-A.js} +1 -1
- streamlit/static/static/js/{InputInstructions.C_m6JNSV.js → InputInstructions.CpNPMMpX.js} +1 -1
- streamlit/static/static/js/{ProgressBar.CXgDz0lS.js → ProgressBar.4yIafGOA.js} +2 -2
- streamlit/static/static/js/{RenderInPortalIfExists.DbjYtj_E.js → RenderInPortalIfExists.31NYBozH.js} +1 -1
- streamlit/static/static/js/{Toolbar.B5RomQbU.js → Toolbar.lnT7wtEH.js} +1 -1
- streamlit/static/static/js/{base-input.B_U9Mij-.js → base-input.DYDwDBVN.js} +4 -4
- streamlit/static/static/js/{createSuper.DiPn7x2M.js → createSuper.CP_bqXkl.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.CxpMznuV.js → data-grid-overlay-editor.Bw6S-08j.js} +1 -1
- streamlit/static/static/js/{downloader.CMxfwi0g.js → downloader.DZpOwdni.js} +1 -1
- streamlit/static/static/js/{es6.CWDfc2yc.js → es6.D670kkuw.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.CyCMpBzy.js → iframeResizer.contentWindow.CBWvp4oS.js} +1 -1
- streamlit/static/static/js/{index.CLXysuIS.js → index.-wGNsvT9.js} +1 -1
- streamlit/static/static/js/{index.CmyE8x29.js → index.0jzSLI-x.js} +2 -2
- streamlit/static/static/js/index.8M0nMTyK.js +1 -0
- streamlit/static/static/js/index.B-Bz2NGO.js +1 -0
- streamlit/static/static/js/index.B6KnC7nW.js +1 -0
- streamlit/static/static/js/index.B9mk7o4G.js +3 -0
- streamlit/static/static/js/index.BCorV1AX.js +1 -0
- streamlit/static/static/js/index.BMlBBPxY.js +9 -0
- streamlit/static/static/js/index.BhTUDBBK.js +1 -0
- streamlit/static/static/js/index.Bif_gpeX.js +1 -0
- streamlit/static/static/js/index.BkURA4Nq.js +3 -0
- streamlit/static/static/js/index.Byj6qntv.js +2 -0
- streamlit/static/static/js/index.C0O8ISw8.js +1 -0
- streamlit/static/static/js/index.C5VAa8DZ.js +1 -0
- streamlit/static/static/js/{index.FVzOj77v.js → index.CA6bEd5D.js} +10 -10
- streamlit/static/static/js/{index.XB-MiuZp.js → index.CD53GuKN.js} +1 -1
- streamlit/static/static/js/index.CKT6gwZG.js +2 -0
- streamlit/static/static/js/{index.DeuQX1T6.js → index.CLsHMaqe.js} +17 -17
- streamlit/static/static/js/index.Ch1c3KR1.js +1 -0
- streamlit/static/static/js/{index.CnzapoES.js → index.ChIZFRw0.js} +1 -1
- streamlit/static/static/js/{index.68LnD3a5.js → index.CrYKK91g.js} +63 -63
- streamlit/static/static/js/index.Cvgj5_qB.js +1 -0
- streamlit/static/static/js/{index.Ctuil2Zq.js → index.D3VdaBwP.js} +1 -1
- streamlit/static/static/js/{index.BW9gD4O1.js → index.D6UL3iMZ.js} +82 -82
- streamlit/static/static/js/index.D8aCPmhr.js +1 -0
- streamlit/static/static/js/{index.B7-ka68B.js → index.DHBu5iL6.js} +2 -2
- streamlit/static/static/js/index.DJF89pFO.js +1 -0
- streamlit/static/static/js/{index.CxT-55oh.js → index.DNEGP5ih.js} +1 -1
- streamlit/static/static/js/index.DRJutLeV.js +1 -0
- streamlit/static/static/js/{index.CZjrVNQ3.js → index.DS38XxzV.js} +1 -1
- streamlit/static/static/js/index.DdeHhk74.js +1 -0
- streamlit/static/static/js/index.De5HitMn.js +1 -0
- streamlit/static/static/js/index.DsvnAu-2.js +1 -0
- streamlit/static/static/js/index.Du4f6P1i.js +1 -0
- streamlit/static/static/js/index.HCbHLWBq.js +1 -0
- streamlit/static/static/js/index.XAUdgEdp.js +1 -0
- streamlit/static/static/js/{index.vyj1usur.js → index.edlGQJ3v.js} +28 -28
- streamlit/static/static/js/{input.D-b9-dhW.js → input.e-37_Dj1.js} +1 -1
- streamlit/static/static/js/{memory.C27_0JRm.js → memory.B5p-2jga.js} +1 -1
- streamlit/static/static/js/{mergeWith.D8F46YVj.js → mergeWith.D8nk5iJa.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.CaHpEyvW.js → number-overlay-editor.DLD5-9zx.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.CnSJ4CFa.js → possibleConstructorReturn.eeV6HB6T.js} +1 -1
- streamlit/static/static/js/{sandbox.Cx5mAMmC.js → sandbox.ChKquq8J.js} +1 -1
- streamlit/static/static/js/{textarea.YeGMY3Ts.js → textarea.ZI_0MUsX.js} +1 -1
- streamlit/static/static/js/{timepicker.BSApuR_7.js → timepicker.C8N66VUc.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.DFJurSxu.js → toConsumableArray.DKg00cRh.js} +1 -1
- streamlit/static/static/js/{uniqueId.B4ugkryR.js → uniqueId.fc9w8X88.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.e9cw5rKa.js → useBasicWidgetState.CySX_BlM.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.CHDPgswc.js → useOnInputChange.BF6Trlh5.js} +1 -1
- streamlit/static/static/js/withFullScreenWrapper.x2WsM7iA.js +1 -0
- streamlit/testing/v1/app_test.py +2 -4
- streamlit/util.py +6 -9
- streamlit/watcher/util.py +2 -7
- streamlit/web/server/app_static_file_handler.py +17 -1
- {streamlit_nightly-1.42.1.dev20250216.dist-info → streamlit_nightly-1.42.2.dev20250218.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.42.1.dev20250216.dist-info → streamlit_nightly-1.42.2.dev20250218.dist-info}/RECORD +86 -86
- streamlit/static/static/js/index.11KmKkMp.js +0 -1
- streamlit/static/static/js/index.B5QCo4O8.js +0 -1
- streamlit/static/static/js/index.B9xlEQvM.js +0 -3
- streamlit/static/static/js/index.Bb_vborY.js +0 -1
- streamlit/static/static/js/index.BoLiyuG0.js +0 -1
- streamlit/static/static/js/index.CBswNuTs.js +0 -1
- streamlit/static/static/js/index.CGHmjGTj.js +0 -1
- streamlit/static/static/js/index.CMM3vxd_.js +0 -1
- streamlit/static/static/js/index.CTrIDSw5.js +0 -1
- streamlit/static/static/js/index.CrDkQv4h.js +0 -1
- streamlit/static/static/js/index.CxX3WJZV.js +0 -9
- streamlit/static/static/js/index.D4y-ZpWF.js +0 -3
- streamlit/static/static/js/index.DUqWz4q7.js +0 -1
- streamlit/static/static/js/index.DaR46enR.js +0 -1
- streamlit/static/static/js/index.DcCioSks.js +0 -2
- streamlit/static/static/js/index.Di8ddb5O.js +0 -1
- streamlit/static/static/js/index.Djk5RccG.js +0 -1
- streamlit/static/static/js/index.DsPUu3xS.js +0 -2
- streamlit/static/static/js/index.FjL8doTL.js +0 -1
- streamlit/static/static/js/index.OiKVkRzb.js +0 -1
- streamlit/static/static/js/index.YBzhCbWe.js +0 -1
- streamlit/static/static/js/index.ZlPieA63.js +0 -1
- streamlit/static/static/js/index.eP8uJaty.js +0 -1
- streamlit/static/static/js/index.fz6QTJde.js +0 -1
- streamlit/static/static/js/withFullScreenWrapper.BKBYrOn-.js +0 -1
- {streamlit_nightly-1.42.1.dev20250216.data → streamlit_nightly-1.42.2.dev20250218.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.42.1.dev20250216.dist-info → streamlit_nightly-1.42.2.dev20250218.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.42.1.dev20250216.dist-info → streamlit_nightly-1.42.2.dev20250218.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.42.1.dev20250216.dist-info → streamlit_nightly-1.42.2.dev20250218.dist-info}/top_level.txt +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
import{n,r as t,M as i,j as c,a_ as d,a$ as e,K as g}from"./index.CLsHMaqe.js";const l=n("iframe",{target:"e3tg43n0"})(({theme:o,disableScrolling:r})=>({width:"100%",colorScheme:"normal",border:"none",padding:o.spacing.none,margin:o.spacing.none,overflow:r?"hidden":void 0}));function a(o){return g(o)||o===""?void 0:o}function m({element:o}){const r=a(o.src),s=i(r)?void 0:a(o.srcdoc);return c(l,{className:"stIFrame","data-testid":"stIFrame",allow:e,disableScrolling:!o.scrolling,src:r,srcDoc:s,height:o.height,scrolling:o.scrolling?"auto":"no",sandbox:d,title:"st.iframe"})}const I=t.memo(m);export{I as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{n as l,k as s,r,j as n}from"./index.
|
1
|
+
import{n as l,k as s,r,j as n}from"./index.CLsHMaqe.js";import{P as i,R as m}from"./RenderInPortalIfExists.31NYBozH.js";const c=""+new URL("../media/balloon-0.Czj7AKwE.png",import.meta.url).href,p=""+new URL("../media/balloon-1.CNvFFrND.png",import.meta.url).href,f=""+new URL("../media/balloon-2.DTvC6B1t.png",import.meta.url).href,d=""+new URL("../media/balloon-3.CgSk4tbL.png",import.meta.url).href,B=""+new URL("../media/balloon-4.mbtFrzxf.png",import.meta.url).href,L=""+new URL("../media/balloon-5.CSwkUfRA.png",import.meta.url).href,a=300,h=121,t=20,g=80,u=1e3,x=s("from{transform:translateY(calc(100vh + ",a,"px));}to{transform:translateY(0);}"),_=l("img",{target:"eosrfo90"})(({theme:o})=>({position:"fixed",top:"-300px",marginLeft:`${-121/2}px`,zIndex:o.zIndices.balloons,left:`${Math.random()*(g-t)+t}vw`,animationDelay:`${Math.random()*u}ms`,height:`${a}px`,width:`${h}px`,pointerEvents:"none",animationDuration:"750ms",animationName:x,animationTimingFunction:"ease-in",animationDirection:"normal",animationIterationCount:1,opacity:1})),w=30,e=[c,p,f,d,B,L],A=e.length,I=({particleType:o})=>n(_,{src:e[o]}),M=({scriptRunId:o})=>n(m,{children:n(i,{className:"stBalloons","data-testid":"stBalloons",scriptRunId:o,numParticleTypes:A,numParticles:w,ParticleComponent:I})}),S=r.memo(M);export{w as NUM_BALLOONS,S as default};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{n as P,r as s,be as U,y as k,co as g,C as H,j as u,bp as L,bC as B,bq as D,b7 as O,br as j,cp as w}from"./index.CLsHMaqe.js";import{u as _}from"./uniqueId.fc9w8X88.js";import{u as q,a as K,b as $}from"./useOnInputChange.BF6Trlh5.js";import{a as A}from"./useBasicWidgetState.CySX_BlM.js";import{I as G}from"./InputInstructions.CpNPMMpX.js";import{I as N}from"./input.e-37_Dj1.js";import"./inputUtils.CQWz5UKz.js";import"./FormClearHelper.DzU-mNjk.js";import"./base-input.DYDwDBVN.js";const J=P("div",{target:"e1o1zy6o0"})("position:relative;");function M({disabled:e,element:t,widgetMgr:a,fragmentId:n}){var f;const[r,l]=s.useState(I(a,t)??null),{values:[S],elementRef:y}=U(s.useMemo(()=>["width"],[])),[i,d]=s.useState(!1),W=s.useCallback(()=>{l(t.default??null),d(!0)},[t.default]),[T,p]=A({getStateFromWidgetMgr:I,getDefaultStateFromProto:Q,getCurrStateFromProto:X,updateWidgetMgrState:Y,element:t,widgetMgr:a,fragmentId:n,onFormCleared:W});q(T,r,l,i);const[x,m]=s.useState(!1),o=k(),[h]=s.useState(()=>_("text_input_")),{placeholder:C,formId:b}=t,c=s.useCallback(()=>{d(!1),p({value:r,fromUi:!0})},[r,p]),V=g({formId:b})?a.allowFormEnterToSubmit(b):i,v=x&&S>o.breakpoints.hideWidgetDetails,F=s.useCallback(()=>{i&&c(),m(!1)},[i,c]),R=s.useCallback(()=>{m(!0)},[]),z=K({formId:t.formId,maxChars:t.maxChars,setDirty:d,setUiValue:l,setValueWithSource:p}),E=$(t.formId,c,i,a,n);return H(J,{className:"stTextInput","data-testid":"stTextInput",ref:y,children:[u(j,{label:t.label,disabled:e,labelVisibility:L((f=t.labelVisibility)==null?void 0:f.value),htmlFor:h,children:t.help&&u(B,{children:u(D,{content:t.help,placement:O.TOP_RIGHT})})}),u(N,{value:r??"",placeholder:C,onBlur:F,onFocus:R,onChange:z,onKeyPress:E,"aria-label":t.label,disabled:e,id:h,type:Z(t),autoComplete:t.autocomplete,overrides:{Input:{style:{minWidth:0,"::placeholder":{opacity:"0.7"},lineHeight:o.lineHeights.inputWidget,paddingRight:o.spacing.sm,paddingLeft:o.spacing.sm,paddingBottom:o.spacing.sm,paddingTop:o.spacing.sm}},Root:{props:{"data-testid":"stTextInputRootElement"},style:{height:o.sizes.minElementHeight,borderLeftWidth:o.sizes.borderWidth,borderRightWidth:o.sizes.borderWidth,borderTopWidth:o.sizes.borderWidth,borderBottomWidth:o.sizes.borderWidth}}}}),v&&u(G,{dirty:i,value:r??"",maxLength:t.maxChars,inForm:g({formId:t.formId}),allowEnterToSubmit:V})]})}function I(e,t){return e.getStringValue(t)??null}function Q(e){return e.default??null}function X(e){return e.value??null}function Y(e,t,a,n){t.setStringValue(e,a.value,{fromUi:a.fromUi},n)}function Z(e){return e.type===w.Type.PASSWORD?"password":"text"}const lt=s.memo(M);export{lt as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{n as f,r,j as c}from"./index.
|
1
|
+
import{n as f,r,j as c}from"./index.CLsHMaqe.js";const E=f("div",{target:"ea9qfvi0"})(()=>({lineHeight:0})),y=f("audio",{target:"ea9qfvi1"})(({theme:t})=>({width:"100%",height:t.sizes.minElementHeight,margin:0,padding:0}));function A({element:t,endpoints:l,elementMgr:o}){const n=r.useRef(null),{startTime:a,endTime:d,loop:u,autoplay:p}=t,m=r.useMemo(()=>{if(!t.id)return!0;const e=o.getElementState(t.id,"preventAutoplay");return e||o.setElementState(t.id,"preventAutoplay",!0),e??!1},[t.id,o]);r.useEffect(()=>{n.current&&(n.current.currentTime=a)},[a]),r.useEffect(()=>{const e=n.current,i=()=>{e&&(e.currentTime=t.startTime)};return e&&e.addEventListener("loadedmetadata",i),()=>{e&&e.removeEventListener("loadedmetadata",i)}},[t]),r.useEffect(()=>{const e=n.current;if(!e)return;let i=!1;const s=()=>{d>0&&e.currentTime>=d&&(u?(e.currentTime=a||0,e.play()):i||(i=!0,e.pause()))};return d>0&&e.addEventListener("timeupdate",s),()=>{e&&d>0&&e.removeEventListener("timeupdate",s)}},[d,u,a]),r.useEffect(()=>{const e=n.current;if(!e)return;const i=()=>{u&&(e.currentTime=a||0,e.play())};return e.addEventListener("ended",i),()=>{e&&e.removeEventListener("ended",i)}},[u,a]);const v=l.buildMediaURL(t.url);return c(E,{children:c(y,{className:"stAudio","data-testid":"stAudio",ref:n,controls:!0,autoPlay:p&&!m,src:v})})}const h=r.memo(A);export{h as default};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{n as R,r,y as M,b_ as T,b$ as W,C,j as l,bp as V,bC as L,bq as O,b7 as P,br as $,bZ as k,c0 as E,bV as N,c1 as A,bA as B}from"./index.CLsHMaqe.js";import{a as F}from"./useBasicWidgetState.CySX_BlM.js";import"./FormClearHelper.DzU-mNjk.js";const H=R("div",{target:"euzcfsp0"})(({theme:s})=>({"span[aria-disabled='true']":{background:s.colors.fadedText05}})),D=(s,t)=>s.getIntArrayValue(t),U=s=>s.default??null,j=s=>s.value??null,G=(s,t,a,p)=>{t.setIntArrayValue(s,a.value,{fromUi:a.fromUi},p)},K=s=>{var S;const{element:t,widgetMgr:a,fragmentId:p}=s,e=M(),[n,g]=F({getStateFromWidgetMgr:D,getDefaultStateFromProto:U,getCurrStateFromProto:j,updateWidgetMgrState:G,element:t,widgetMgr:a,fragmentId:p}),m=t.maxSelections>0&&n.length>=t.maxSelections,y=r.useMemo(()=>{if(t.maxSelections===0)return"No results";if(n.length===t.maxSelections){const o=t.maxSelections!==1?"options":"option";return`You can only select up to ${t.maxSelections} ${o}. Remove an option first.`}return"No results"},[t.maxSelections,n.length]),f=r.useMemo(()=>n.map(o=>{const i=t.options[o];return{value:o.toString(),label:i}}),[t.options,n]),h=r.useCallback(o=>{const i=()=>{var d;const u=(d=o.option)==null?void 0:d.value;return parseInt(u,10)};switch(o.type){case"remove":return T(n,i());case"clear":return[];case"select":return n.concat([i()]);default:throw new Error(`State transition is unknown: ${o.type}`)}},[n]),v=r.useCallback(o=>{t.maxSelections&&o.type==="select"&&n.length>=t.maxSelections||g({value:h(o),fromUi:!0})},[t.maxSelections,h,g,n.length]),x=r.useCallback((o,i)=>{if(m)return[];const u=o.filter(d=>!n.includes(Number(d.value)));return W(u,i)},[m,n]),{options:c}=t,b=c.length===0?!0:s.disabled,z=c.length===0?"No options to select.":t.placeholder,w=c.map((o,i)=>({label:o,value:i.toString()})),I=c.length>10;return C("div",{className:"stMultiSelect","data-testid":"stMultiSelect",children:[l($,{label:t.label,disabled:b,labelVisibility:V((S=t.labelVisibility)==null?void 0:S.value),children:t.help&&l(L,{children:l(O,{content:t.help,placement:P.TOP_RIGHT})})}),l(H,{children:l(k,{options:w,labelKey:"label",valueKey:"value","aria-label":t.label,placeholder:z,type:A.select,multi:!0,onChange:v,value:f,disabled:b,size:"compact",noResultsMsg:y,filterOptions:x,closeOnSelect:!1,overrides:{Popover:{props:{overrides:{Body:{style:()=>({marginTop:e.spacing.px})}}}},SelectArrow:{component:N,props:{overrides:{Svg:{style:()=>({width:e.iconSizes.xl,height:e.iconSizes.xl})}}}},IconsContainer:{style:()=>({paddingRight:e.spacing.sm})},ControlContainer:{style:{minHeight:e.sizes.minElementHeight,borderLeftWidth:e.sizes.borderWidth,borderRightWidth:e.sizes.borderWidth,borderTopWidth:e.sizes.borderWidth,borderBottomWidth:e.sizes.borderWidth}},Placeholder:{style:()=>({flex:"inherit",opacity:"0.7"})},ValueContainer:{style:()=>({paddingLeft:e.spacing.sm,paddingTop:e.spacing.none,paddingBottom:e.spacing.none,paddingRight:e.spacing.none})},ClearIcon:{props:{overrides:{Svg:{style:{color:e.colors.darkGray,padding:e.spacing.threeXS,height:e.sizes.clearIconSize,width:e.sizes.clearIconSize,cursor:"pointer",":hover":{fill:e.colors.bodyText}}}}}},SearchIcon:{style:{color:e.colors.darkGray}},Tag:{props:{overrides:{Root:{style:{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:B.isMobile&&I===!1?"readonly":null}},Dropdown:{component:E}}})})]})},X=r.memo(K);export{X as default};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as o,E as G,_ as X,n as x,y as ut,be as ct,co as dt,M as J,cy as I,K as b,C as N,j as u,bp as pt,bC as ft,bq as bt,b7 as mt,br as gt,bm as M,an as yt}from"./index.CLsHMaqe.js";import{s as ht}from"./sprintf.D7DtBTRn.js";import{u as It}from"./uniqueId.fc9w8X88.js";import{u as Tt}from"./FormClearHelper.DzU-mNjk.js";import{I as wt}from"./InputInstructions.CpNPMMpX.js";import{I as Ct}from"./input.e-37_Dj1.js";import"./base-input.DYDwDBVN.js";var Q=o.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(G,X({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),o.createElement("path",{d:"M0 3v2h8V3H0z"}))});Q.displayName="Minus";var Y=o.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(G,X({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),o.createElement("path",{d:"M3 0v3H0v2h3v3h2V5h3V3H5V0H3z"}))});Y.displayName="Plus";const vt=x("div",{target:"e5tuigk0"})(({theme:t})=>({display:"flex",flexDirection:"row",flexWrap:"nowrap",alignItems:"center",height:t.sizes.minElementHeight,borderWidth:t.sizes.borderWidth,borderStyle:"solid",borderColor:t.colors.widgetBorderColor??t.colors.secondaryBg,transitionDuration:"200ms",transitionProperty:"border",transitionTimingFunction:"cubic-bezier(0.2, 0.8, 0.4, 1)",borderRadius:t.radii.default,overflow:"hidden","&.focused":{borderColor:t.colors.primary},input:{MozAppearance:"textfield","&::-webkit-inner-spin-button, &::-webkit-outer-spin-button":{WebkitAppearance:"none",margin:t.spacing.none}}})),St=x("div",{target:"e5tuigk1"})({display:"flex",flexDirection:"row",alignSelf:"stretch"}),K=x("button",{target:"e5tuigk2"})(({theme:t})=>({margin:t.spacing.none,border:"none",height:t.sizes.full,display:"flex",alignItems:"center",width:t.sizes.numberInputControlsWidth,justifyContent:"center",color:t.colors.bodyText,transition:"color 300ms, backgroundColor 300ms",backgroundColor:t.colors.secondaryBg,"&:hover:enabled, &:focus:enabled":{color:t.colors.white,backgroundColor:t.colors.primary,transition:"none",outline:"none"},"&:active":{outline:"none",border:"none"},"&:last-of-type":{borderTopRightRadius:t.radii.default,borderBottomRightRadius:t.radii.default},"&:disabled":{cursor:"not-allowed",color:t.colors.fadedText40}})),Vt=x("div",{target:"e5tuigk3"})(({theme:t,clearable:e})=>({position:"absolute",marginRight:t.spacing.twoXS,left:0,right:`calc(${t.sizes.numberInputControlsWidth} * 2 + ${e?"1em":"0em"})`})),kt=yt.getLogger("NumberInput");function xt(t){return b(t)||t===""?void 0:t}const Rt=t=>(t.element.dataType===I.DataType.INT?t.widgetMgr.getIntValue(t.element):t.widgetMgr.getDoubleValue(t.element))??t.element.default??null,q=({step:t,dataType:e})=>t||(e===I.DataType.INT?1:.01),z=({value:t,format:e,step:r,dataType:f})=>{if(b(t))return null;let n=xt(e);if(b(n)&&J(r)){const d=r.toString();f===I.DataType.FLOAT&&r!==0&&d.includes(".")&&(n=`%0.${d.split(".")[1].length}f`)}if(b(n))return t.toString();try{return ht.sprintf(n,t)}catch(d){return kt.warn(`Error in sprintf(${n}, ${t}): ${d}`),String(t)}},Dt=(t,e,r)=>b(t)?!1:t-e>=r,Et=(t,e,r)=>b(t)?!1:t+e<=r,Ft=({disabled:t,element:e,widgetMgr:r,fragmentId:f})=>{var j;const n=ut(),{dataType:d,id:C,formId:p,default:W,format:B}=e,m=e.hasMin?e.min:-1/0,g=e.hasMax?e.max:1/0,{values:[A],elementRef:Z}=ct(o.useMemo(()=>["width"],[])),[s,tt]=o.useState(q(e)),H=Rt({element:e,widgetMgr:r}),[y,T]=o.useState(!1),[i,w]=o.useState(H),[P,v]=o.useState(z({value:H,...e,step:s})),[L,U]=o.useState(!1),R=o.useRef(null),$=o.useRef(It("number_input_")),S=Dt(i,s,m),V=Et(i,s,g),O=dt({formId:p}),et=O?r.allowFormEnterToSubmit(p):y,ot=L&&A>n.breakpoints.hideWidgetDetails;o.useEffect(()=>{tt(q({step:e.step,dataType:e.dataType}))},[e.dataType,e.step]);const l=o.useCallback(({value:a,source:c})=>{var h;if(J(a)&&(m>a||a>g))(h=R.current)==null||h.reportValidity();else{const k=a??W??null;switch(d){case I.DataType.INT:r.setIntValue({id:C,formId:p},k,c,f);break;case I.DataType.FLOAT:r.setDoubleValue({id:C,formId:p},k,c,f);break;default:throw new Error("Invalid data type")}T(!1),w(k),v(z({value:k,dataType:d,format:B,step:s}))}},[m,g,R,r,f,s,d,C,p,W,B]),rt=o.useCallback(()=>{y&&l({value:i,source:{fromUi:!0}}),U(!1)},[y,i,l]),nt=o.useCallback(()=>{U(!0)},[]),_=o.useCallback(()=>{const{value:a}=e;e.setValue=!1,w(a??null),v(z({value:a??null,...e,step:s})),l({value:a??null,source:{fromUi:!1}})},[e,s,l]);o.useEffect(()=>{e.setValue?_():l({value:i,source:{fromUi:!1}})},[]),e.setValue&&_();const D=b(e.default)&&!t,at=o.useCallback(()=>{const a=e.default??null;w(a),l({value:a,source:{fromUi:!0}})},[e]);Tt({element:e,widgetMgr:r,onFormCleared:at});const st=a=>{const{value:c}=a.target;if(c==="")T(!0),w(null),v(null);else{let h;e.dataType===I.DataType.INT?h=parseInt(c,10):h=parseFloat(c),T(!0),w(h),v(c)}},E=o.useCallback(()=>{V&&(T(!0),l({value:(i??m)+s,source:{fromUi:!0}}))},[i,m,s,V]),F=o.useCallback(()=>{S&&(T(!0),l({value:(i??g)-s,source:{fromUi:!0}}))},[i,g,s,S]),it=o.useCallback(a=>{const{key:c}=a;switch(c){case"ArrowUp":a.preventDefault(),E();break;case"ArrowDown":a.preventDefault(),F();break}},[E,F]),lt=o.useCallback(a=>{a.key==="Enter"&&(y&&l({value:i,source:{fromUi:!0}}),r.allowFormEnterToSubmit(p)&&r.submitForm(p,f))},[y,i,l,r,p,f]);return N("div",{className:"stNumberInput","data-testid":"stNumberInput",ref:Z,children:[u(gt,{label:e.label,disabled:t,labelVisibility:pt((j=e.labelVisibility)==null?void 0:j.value),htmlFor:$.current,children:e.help&&u(ft,{children:u(bt,{content:e.help,placement:mt.TOP_RIGHT})})}),N(vt,{className:L?"focused":"","data-testid":"stNumberInputContainer",children:[u(Ct,{type:"number",inputRef:R,value:P??"",placeholder:e.placeholder,onBlur:rt,onFocus:nt,onChange:st,onKeyPress:lt,onKeyDown:it,clearable:D,clearOnEscape:D,disabled:t,"aria-label":e.label,id:$.current,overrides:{ClearIconContainer:{style:{padding:0}},ClearIcon:{props:{overrides:{Svg:{style:{color:n.colors.darkGray,padding:n.spacing.threeXS,height:n.sizes.clearIconSize,width:n.sizes.clearIconSize,":hover":{fill:n.colors.bodyText}}}}}},Input:{props:{"data-testid":"stNumberInputField",step:s,min:m,max:g,type:"number",inputMode:""},style:{lineHeight:n.lineHeights.inputWidget,paddingRight:n.spacing.sm,paddingLeft:n.spacing.sm,paddingBottom:n.spacing.sm,paddingTop:n.spacing.sm}},InputContainer:{style:()=>({borderTopRightRadius:0,borderBottomRightRadius:0})},Root:{style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:0,borderRightWidth:0,borderTopWidth:0,borderBottomWidth:0,paddingRight:0}}}}),A>n.breakpoints.hideNumberInputControls&&N(St,{children:[u(K,{"data-testid":"stNumberInputStepDown",onClick:F,disabled:!S||t,tabIndex:-1,children:u(M,{content:Q,size:"xs",color:S?"inherit":n.colors.disabled})}),u(K,{"data-testid":"stNumberInputStepUp",onClick:E,disabled:!V||t,tabIndex:-1,children:u(M,{content:Y,size:"xs",color:V?"inherit":n.colors.disabled})})]})]}),ot&&u(Vt,{clearable:D,children:u(wt,{dirty:y,value:P??"",inForm:O,allowEnterToSubmit:et})})]})},Lt=o.memo(Ft);export{Lt as default};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as s,K as b,j as S,bp as d,c3 as x}from"./index.CLsHMaqe.js";import{a as V}from"./useBasicWidgetState.CySX_BlM.js";import"./FormClearHelper.DzU-mNjk.js";const v=(t,e)=>t.getIntValue(e),U=t=>t.default??null,h=t=>t.value??null,C=(t,e,o,a)=>{e.setIntValue(t,o.value,{fromUi:o.fromUi},a)},F=({disabled:t,element:e,widgetMgr:o,fragmentId:a})=>{const{options:u,help:n,label:c,labelVisibility:r,placeholder:i}=e,[m,l]=V({getStateFromWidgetMgr:v,getDefaultStateFromProto:U,getCurrStateFromProto:h,updateWidgetMgrState:C,element:e,widgetMgr:o,fragmentId:a}),g=s.useCallback(f=>{l({value:f,fromUi:!0})},[l]),p=b(e.default)&&!t;return S(x,{label:c,labelVisibility:d(r==null?void 0:r.value),options:u,disabled:t,onChange:g,value:m,help:n,placeholder:i,clearable:p})},j=s.memo(F);export{j as default};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{n as p,r as s,y as T,C as y,j as i,G as w,ay as h,aL as r,aM as v,aN as m,F as k,D as L}from"./index.CLsHMaqe.js";const z=p("button",{target:"e1rpgzpk0"})(({theme:t})=>({fontSize:t.fontSizes.sm,lineHeight:t.lineHeights.base,color:t.colors.fadedText60,backgroundColor:t.colors.transparent,fontFamily:"inherit",margin:t.spacing.none,border:"none",boxShadow:"none",padding:t.spacing.none,"&:hover, &:active, &:focus":{border:"none",outline:"none",boxShadow:"none"},"&:hover":{color:t.colors.primary}})),R=p("div",{target:"e1rpgzpk1"})(({theme:t})=>({display:"flex",flexDirection:"row",gap:t.spacing.lg,"> span":{marginTop:t.spacing.twoXS}})),C=p("div",{target:"e1rpgzpk3"})(({theme:t})=>({display:"flex",flexDirection:"column",gap:t.spacing.sm,alignItems:"start",justifyContent:"center",overflow:"hidden",minHeight:"100%",fontSize:t.fontSizes.sm,lineHeight:t.lineHeights.base,div:{display:"inline-flex"}}));function B(t){const a=L(t);return{Body:{props:{"data-testid":"stToast",className:"stToast"},style:{display:"flex",flexDirection:"row",gap:t.spacing.md,width:t.sizes.toastWidth,marginTop:t.spacing.sm,borderTopLeftRadius:t.radii.default,borderTopRightRadius:t.radii.default,borderBottomLeftRadius:t.radii.default,borderBottomRightRadius:t.radii.default,paddingTop:t.spacing.lg,paddingBottom:t.spacing.lg,paddingLeft:t.spacing.twoXL,paddingRight:t.spacing.twoXL,backgroundColor:a?t.colors.gray10:t.colors.gray90,color:t.colors.bodyText,boxShadow:a?"0px 4px 16px rgba(0, 0, 0, 0.16)":"0px 4px 16px rgba(0, 0, 0, 0.7)"}},CloseIcon:{style:{color:t.colors.fadedText40,width:t.fontSizes.lg,height:t.fontSizes.lg,marginRight:`calc(-1 * ${t.spacing.lg} / 2)`,":hover":{color:t.colors.bodyText}}}}}function E(t){if(t.length>104){let o=t.replace(/^(.{104}[^\s]*).*/,"$1");return o.length>104&&(o=o.substring(0,104).split(" ").slice(0,-1).join(" ")),o.trim()}return t}function D({body:t,icon:a}){const o=T(),n=E(t),d=t!==n,[e,x]=s.useState(!d),[u,b]=s.useState(0),f=s.useCallback(()=>{x(!e)},[e]),c=s.useMemo(()=>B(o),[o]),l=s.useMemo(()=>y(R,{expanded:e,children:[a&&i(w,{iconValue:a,size:"xl",testid:"stToastDynamicIcon"}),y(C,{children:[i(h,{source:e?t:n,allowHTML:!1,isToast:!0}),d&&i(z,{"data-testid":"stToastViewButton",onClick:f,children:e?"view less":"view more"})]})]}),[d,e,t,a,n,f]);s.useEffect(()=>{if(o.inSidebar)return;const g=r.info(l,{overrides:{...c}});return b(g),()=>{r.update(g,{overrides:{Body:{style:{transitionDuration:0}}}}),r.clear(g)}},[]),s.useEffect(()=>{r.update(u,{children:l,overrides:{...c}})},[u,l,c]);const S=i(m,{kind:v.ERROR,body:"Streamlit API Error: `st.toast` cannot be called directly on the sidebar with `st.sidebar.toast`. See our `st.toast` API [docs](https://docs.streamlit.io/develop/api-reference/status/st.toast) for more information."});return i(k,{children:o.inSidebar&&S})}const H=s.memo(D);export{H as default};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as i,j as c,bp as g,bM as b}from"./index.CLsHMaqe.js";import{a as m}from"./useBasicWidgetState.CySX_BlM.js";import"./FormClearHelper.DzU-mNjk.js";const p=(t,e)=>t.getStringValue(e),f=t=>t.default??null,C=t=>t.value??null,d=(t,e,r,o)=>{e.setStringValue(t,r.value,{fromUi:r.fromUi},o)},S=({element:t,disabled:e,widgetMgr:r,fragmentId:o})=>{var l;const[s,a]=m({getStateFromWidgetMgr:p,getDefaultStateFromProto:f,getCurrStateFromProto:C,updateWidgetMgrState:d,element:t,widgetMgr:r,fragmentId:o}),u=i.useCallback(n=>{a({value:n,fromUi:!0})},[a]);return c(b,{label:t.label,labelVisibility:g((l=t.labelVisibility)==null?void 0:l.value),help:t.help,onChange:u,disabled:e,value:s})},k=i.memo(S);export{k as default};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as M,E as T,_ as j,n as E,at as J,C as R,j as h,bs as K,b7 as z,bn as Y,b2 as Z,bm as O,bz as $,d as ee,g as te,aH as re,y as ie,bA as ae,bB as oe,bf as ne,R as se,an as le,aw as de,K as P,bj as ce,bi as ue,bp as pe,bC as fe,bq as he,br as ge,F as me}from"./index.CLsHMaqe.js";import{a as V}from"./index.DW_MHI2K.js";import{F as ve}from"./FormClearHelper.DzU-mNjk.js";import{U as L}from"./UploadFileInfo.C-jY39rj.js";import{P as Se,S as ye}from"./ProgressBar.4yIafGOA.js";var N=M.forwardRef(function(t,l){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return M.createElement(T,j({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:l}),M.createElement("path",{d:"M.5 1c-.28 0-.5.23-.5.5v4c0 .28.23.5.5.5h5c.28 0 .5-.22.5-.5V4l1 1h1V2H7L6 3V1.5c0-.28-.22-.5-.5-.5h-5z"}))});N.displayName="Video";var H=M.forwardRef(function(t,l){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return M.createElement(T,j({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:l}),M.createElement("path",{d:"M1.41 0L0 1.41l.72.72L2.5 3.94.72 5.72 0 6.41l1.41 1.44.72-.72 1.81-1.81 1.78 1.81.69.72 1.44-1.44-.72-.69-1.81-1.78 1.81-1.81.72-.72L6.41 0l-.69.72L3.94 2.5 2.13.72 1.41 0z"}))});H.displayName="X";var D=M.forwardRef(function(t,l){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return M.createElement(T,j({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:l}),M.createElement("rect",{width:24,height:24,fill:"none"}),M.createElement("path",{d:"M20 5h-3.17l-1.24-1.35A1.99 1.99 0 0014.12 3H9.88c-.56 0-1.1.24-1.48.65L7.17 5H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-1.35 8.35l-2.79 2.79c-.32.32-.86.1-.86-.35v-1.75H9v1.75c0 .45-.54.67-.85.35l-2.79-2.79c-.2-.2-.2-.51 0-.71l2.79-2.79a.5.5 0 01.85.36v1.83h6v-1.83c0-.45.54-.67.85-.35l2.79 2.79c.2.19.2.51.01.7z"}))});D.displayName="SwitchCamera";var k;(function(t){t.XSMALL="xsmall",t.SMALL="small",t.MEDIUM="medium",t.LARGE="large"})(k||(k={}));function be(t,l){switch(t){case"xsmall":return{padding:`${l.spacing.twoXS} ${l.spacing.sm}`,fontSize:l.fontSizes.sm};case"small":return{padding:`${l.spacing.twoXS} ${l.spacing.md}`};case"large":return{padding:`${l.spacing.md} ${l.spacing.md}`};default:return{padding:`${l.spacing.xs} ${l.spacing.md}`}}}const G=E("div",{target:"e47j7ja0"})({position:"relative",overflow:"hidden",width:"100%",objectFit:"contain"}),W=E("div",{target:"e47j7ja1"})(({theme:t,width:l})=>({backgroundColor:t.colors.secondaryBg,borderRadius:`${t.radii.default} ${t.radii.default} 0 0`,width:"100%",height:l*9/16,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"})),Me=E("p",{target:"e47j7ja2"})(({theme:t})=>({marginTop:t.spacing.sm,textAlign:"center"})),we=E("img",{target:"e47j7ja3"})(({theme:t,opacity:l})=>({borderRadius:`${t.radii.default} ${t.radii.default} 0 0`,objectFit:"contain",opacity:l})),Ce=E("a",{target:"e47j7ja4"})(({theme:t})=>({color:t.colors.primary,display:"block",textDecoration:"none"})),Ue=E("span",{target:"e47j7ja5"})({display:"flex",alignItems:"center"}),Ee=E("div",{target:"e47j7ja6"})(({theme:t})=>({position:"absolute",top:t.spacing.lg,right:t.spacing.lg,zIndex:t.zIndices.priority,color:t.colors.fadedText40,mixBlendMode:"difference",opacity:.6})),Ie=E("div",{target:"e47j7ja8"})({height:"fit-content",width:"100%",position:"absolute",bottom:0}),Fe=E("button",{target:"e47j7ja9"})(({theme:t})=>({position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:t.colors.lightenedBg05,border:`${t.sizes.borderWidth} solid ${t.colors.borderColor}`,borderRadius:`0 0 ${t.radii.default} ${t.radii.default}`,"&:hover":{borderColor:t.colors.primary,color:t.colors.primary},"&:active":{color:t.colors.white,borderColor:t.colors.primary,backgroundColor:t.colors.primary},"&:focus:not(:active)":{borderColor:t.colors.primary,color:t.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{color:t.colors.fadedText40},fontWeight:t.fontWeights.normal,padding:`${t.spacing.xs} ${t.spacing.md}`,margin:t.spacing.none,lineHeight:t.lineHeights.base,color:"inherit",width:"100%",userSelect:"none","&:focus":{outline:"none"},"&:focus-visible":{boxShadow:`0 0 0 0.2rem ${J(t.colors.primary,.5)}`},...be("medium",t)}));function q({disabled:t,onClick:l,children:r,progress:o}){return R(Fe,{disabled:t||!1,onClick:l||(()=>{}),progress:o||null,"data-testid":"stCameraInputButton",children:[r,o&&h(Ie,{children:h(Se,{value:o,size:ye.EXTRASMALL,overrides:{Bar:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarProgress:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarContainer:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}}}})})]})}var F;(function(t){t.USER="user",t.ENVIRONMENT="environment"})(F||(F={}));const Re=({switchFacingMode:t})=>h(Ee,{"data-testid":"stCameraInputSwitchButton",children:h(K,{content:"Switch camera",placement:z.TOP_RIGHT,children:h(Y,{kind:Z.MINIMAL,onClick:t,children:h(O,{content:D,size:"twoXL",color:$.white})})})});var _={exports:{}},xe=_.exports,B;function Pe(){return B||(B=1,function(t,l){(function(o,a){t.exports=a(ee())})(xe,function(r){return function(o){var a={};function n(s){if(a[s])return a[s].exports;var p=a[s]={i:s,l:!1,exports:{}};return o[s].call(p.exports,p,p.exports,n),p.l=!0,p.exports}return n.m=o,n.c=a,n.d=function(s,p,g){n.o(s,p)||Object.defineProperty(s,p,{enumerable:!0,get:g})},n.r=function(s){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},n.t=function(s,p){if(p&1&&(s=n(s)),p&8||p&4&&typeof s=="object"&&s&&s.__esModule)return s;var g=Object.create(null);if(n.r(g),Object.defineProperty(g,"default",{enumerable:!0,value:s}),p&2&&typeof s!="string")for(var U in s)n.d(g,U,(function(C){return s[C]}).bind(null,U));return g},n.n=function(s){var p=s&&s.__esModule?function(){return s.default}:function(){return s};return n.d(p,"a",p),p},n.o=function(s,p){return Object.prototype.hasOwnProperty.call(s,p)},n.p="",n(n.s="./src/react-webcam.tsx")}({"./src/react-webcam.tsx":function(o,a,n){n.r(a);var s=n("react"),p=function(){var m=function(u,e){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,d){i.__proto__=d}||function(i,d){for(var c in d)d.hasOwnProperty(c)&&(i[c]=d[c])},m(u,e)};return function(u,e){m(u,e);function i(){this.constructor=u}u.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}}(),g=function(){return g=Object.assign||function(m){for(var u,e=1,i=arguments.length;e<i;e++){u=arguments[e];for(var d in u)Object.prototype.hasOwnProperty.call(u,d)&&(m[d]=u[d])}return m},g.apply(this,arguments)},U=function(m,u){var e={};for(var i in m)Object.prototype.hasOwnProperty.call(m,i)&&u.indexOf(i)<0&&(e[i]=m[i]);if(m!=null&&typeof Object.getOwnPropertySymbols=="function")for(var d=0,i=Object.getOwnPropertySymbols(m);d<i.length;d++)u.indexOf(i[d])<0&&Object.prototype.propertyIsEnumerable.call(m,i[d])&&(e[i[d]]=m[i[d]]);return e};(function(){typeof window>"u"||(navigator.mediaDevices===void 0&&(navigator.mediaDevices={}),navigator.mediaDevices.getUserMedia===void 0&&(navigator.mediaDevices.getUserMedia=function(u){var e=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return e?new Promise(function(i,d){e.call(navigator,u,i,d)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}))})();function C(){return!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)}var I=function(m){p(u,m);function u(e){var i=m.call(this,e)||this;return i.canvas=null,i.ctx=null,i.requestUserMediaId=0,i.unmounted=!1,i.state={hasUserMedia:!1},i}return u.prototype.componentDidMount=function(){var e=this,i=e.state,d=e.props;if(this.unmounted=!1,!C()){d.onUserMediaError("getUserMedia not supported");return}i.hasUserMedia||this.requestUserMedia(),d.children&&typeof d.children!="function"&&console.warn("children must be a function")},u.prototype.componentDidUpdate=function(e){var i=this.props;if(!C()){i.onUserMediaError("getUserMedia not supported");return}var d=JSON.stringify(e.audioConstraints)!==JSON.stringify(i.audioConstraints),c=JSON.stringify(e.videoConstraints)!==JSON.stringify(i.videoConstraints),y=e.minScreenshotWidth!==i.minScreenshotWidth,S=e.minScreenshotHeight!==i.minScreenshotHeight;(c||y||S)&&(this.canvas=null,this.ctx=null),(d||c)&&(this.stopAndCleanup(),this.requestUserMedia())},u.prototype.componentWillUnmount=function(){this.unmounted=!0,this.stopAndCleanup()},u.stopMediaStream=function(e){e&&(e.getVideoTracks&&e.getAudioTracks?(e.getVideoTracks().map(function(i){e.removeTrack(i),i.stop()}),e.getAudioTracks().map(function(i){e.removeTrack(i),i.stop()})):e.stop())},u.prototype.stopAndCleanup=function(){var e=this.state;e.hasUserMedia&&(u.stopMediaStream(this.stream),e.src&&window.URL.revokeObjectURL(e.src))},u.prototype.getScreenshot=function(e){var i=this,d=i.state,c=i.props;if(!d.hasUserMedia)return null;var y=this.getCanvas(e);return y&&y.toDataURL(c.screenshotFormat,c.screenshotQuality)},u.prototype.getCanvas=function(e){var i=this,d=i.state,c=i.props;if(!this.video||!d.hasUserMedia||!this.video.videoHeight)return null;if(!this.ctx){var y=this.video.videoWidth,S=this.video.videoHeight;if(!this.props.forceScreenshotSourceSize){var f=y/S;y=c.minScreenshotWidth||this.video.clientWidth,S=y/f,c.minScreenshotHeight&&S<c.minScreenshotHeight&&(S=c.minScreenshotHeight,y=S*f)}this.canvas=document.createElement("canvas"),this.canvas.width=(e==null?void 0:e.width)||y,this.canvas.height=(e==null?void 0:e.height)||S,this.ctx=this.canvas.getContext("2d")}var w=this,b=w.ctx,v=w.canvas;return b&&v&&(v.width=(e==null?void 0:e.width)||v.width,v.height=(e==null?void 0:e.height)||v.height,c.mirrored&&(b.translate(v.width,0),b.scale(-1,1)),b.imageSmoothingEnabled=c.imageSmoothing,b.drawImage(this.video,0,0,(e==null?void 0:e.width)||v.width,(e==null?void 0:e.height)||v.height),c.mirrored&&(b.scale(-1,1),b.translate(-v.width,0))),v},u.prototype.requestUserMedia=function(){var e=this,i=this.props,d=function(S,f){var w={video:typeof f<"u"?f:!0};i.audio&&(w.audio=typeof S<"u"?S:!0),e.requestUserMediaId++;var b=e.requestUserMediaId;navigator.mediaDevices.getUserMedia(w).then(function(v){e.unmounted||b!==e.requestUserMediaId?u.stopMediaStream(v):e.handleUserMedia(null,v)}).catch(function(v){e.handleUserMedia(v)})};if("mediaDevices"in navigator)d(i.audioConstraints,i.videoConstraints);else{var c=function(S){return{optional:[{sourceId:S}]}},y=function(S){var f=S.deviceId;return typeof f=="string"?f:Array.isArray(f)&&f.length>0?f[0]:typeof f=="object"&&f.ideal?f.ideal:null};MediaStreamTrack.getSources(function(S){var f=null,w=null;S.forEach(function(x){x.kind==="audio"?f=x.id:x.kind==="video"&&(w=x.id)});var b=y(i.audioConstraints);b&&(f=b);var v=y(i.videoConstraints);v&&(w=v),d(c(f),c(w))})}},u.prototype.handleUserMedia=function(e,i){var d=this.props;if(e||!i){this.setState({hasUserMedia:!1}),d.onUserMediaError(e);return}this.stream=i;try{this.video&&(this.video.srcObject=i),this.setState({hasUserMedia:!0})}catch{this.setState({hasUserMedia:!0,src:window.URL.createObjectURL(i)})}d.onUserMedia(i)},u.prototype.render=function(){var e=this,i=this,d=i.state,c=i.props,y=c.audio;c.forceScreenshotSourceSize,c.onUserMedia,c.onUserMediaError,c.screenshotFormat,c.screenshotQuality,c.minScreenshotWidth,c.minScreenshotHeight,c.audioConstraints,c.videoConstraints,c.imageSmoothing;var S=c.mirrored,f=c.style,w=f===void 0?{}:f,b=c.children,v=U(c,["audio","forceScreenshotSourceSize","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored","style","children"]),x=S?g(g({},w),{transform:(w.transform||"")+" scaleX(-1)"}):w,X={getScreenshot:this.getScreenshot.bind(this)};return s.createElement(s.Fragment,null,s.createElement("video",g({autoPlay:!0,src:d.src,muted:!y,playsInline:!0,ref:function(Q){e.video=Q},style:x},v)),b&&b(X))},u.defaultProps={audio:!1,forceScreenshotSourceSize:!1,imageSmoothing:!0,mirrored:!1,onUserMedia:function(){},onUserMediaError:function(){},screenshotFormat:"image/webp",screenshotQuality:.92},u}(s.Component);a.default=I},react:function(o,a){o.exports=r}}).default})}(_)),_.exports}var _e=Pe();const Te=te(_e);var A;(function(t){t.PENDING="pending",t.SUCCESS="success",t.ERROR="error"})(A||(A={}));const je=({width:t})=>R(W,{width:t,children:[h(O,{size:"threeXL",color:$.gray60,content:N}),R(Me,{children:["This app would like to use your camera.",h(Ce,{href:oe,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]})]}),Oe=({handleCapture:t,width:l,disabled:r,clearPhotoInProgress:o,setClearPhotoInProgress:a,facingMode:n,setFacingMode:s,testOverride:p})=>{const[g,U]=M.useState(p||"pending"),C=M.useRef(null),[I,m]=M.useState(l),u=M.useCallback(re(1e3,m),[]);M.useEffect(()=>{u(l)},[l,u]);function e(){if(C.current!==null){const d=C.current.getScreenshot();t(d)}}const i=ie();return R(G,{"data-testid":"stCameraInputWebcamComponent",children:[g!=="success"&&!r&&!o?h(je,{width:I}):ae.isMobile&&h(Re,{switchFacingMode:s}),h(W,{"data-testid":"stCameraInputWebcamStyledBox",hidden:g!=="success"&&!r&&!o,width:I,children:!r&&h(Te,{audio:!1,ref:C,screenshotFormat:"image/jpeg",screenshotQuality:1,width:I,height:I*9/16,style:{borderRadius:`${i.radii.default} ${i.radii.default} 0 0`},onUserMediaError:()=>{U("error")},onUserMedia:()=>{U("success"),a(!1)},videoConstraints:{width:{ideal:I},facingMode:n}})}),h(q,{onClick:e,disabled:g!=="success"||r||o,children:"Take Photo"})]})},We=150,Ve=le.getLogger("CameraInput");class Le extends se.PureComponent{constructor(l){super(l),this.localFileIdCounter=1,this.RESTORED_FROM_WIDGET_STRING="RESTORED_FROM_WIDGET",this.formClearHelper=new ve,this.getProgress=()=>{if(this.state.files.length>0&&this.state.files[this.state.files.length-1].status.type==="uploading")return this.state.files[this.state.files.length-1].status.progress},this.setClearPhotoInProgress=r=>{this.setState({clearPhotoInProgress:r})},this.setFacingMode=()=>{this.setState(r=>({facingMode:r.facingMode===F.USER?F.ENVIRONMENT:F.USER}))},this.handleCapture=r=>{if(r===null)return Promise.resolve();this.setState({imgSrc:r,shutter:!0,minShutterEffectPassed:!1});const o=a=>new Promise(n=>setTimeout(n,a));return ke(r,`camera-input-${new Date().toISOString().replace(/:/g,"_")}.jpg`).then(a=>this.props.uploadClient.fetchFileURLs([a]).then(n=>({file:a,fileUrls:n[0]}))).then(({file:a,fileUrls:n})=>this.uploadFile(n,a)).then(()=>o(We)).then(()=>{this.setState((a,n)=>({imgSrc:r,shutter:a.shutter,minShutterEffectPassed:!0}))}).catch(a=>{Ve.error(a)})},this.removeCapture=()=>{this.state.files.length!==0&&(this.state.files.forEach(r=>this.deleteFile(r.id)),this.setState({imgSrc:null,clearPhotoInProgress:!0}))},this.componentDidUpdate=()=>{if(this.status!=="ready")return;const r=this.createWidgetValue(),{element:o,widgetMgr:a,fragmentId:n}=this.props,s=a.getFileUploaderStateValue(o);de(r,s)||a.setFileUploaderStateValue(o,r,{fromUi:!0},n)},this.onFormCleared=()=>{this.setState({files:[]},()=>{const r=this.createWidgetValue();if(P(r))return;this.setState({imgSrc:null});const{widgetMgr:o,element:a,fragmentId:n}=this.props;o.setFileUploaderStateValue(a,r,{fromUi:!0},n)})},this.deleteFile=r=>{const o=this.getFile(r);P(o)||(o.status.type==="uploading"&&o.status.cancelToken.cancel(),o.status.type==="uploaded"&&o.status.fileUrls.deleteUrl&&this.props.uploadClient.deleteFile(o.status.fileUrls.deleteUrl),this.removeFile(r))},this.addFile=r=>{this.setState(o=>({files:[...o.files,r]}))},this.removeFile=r=>{this.setState(o=>({files:o.files.filter(a=>a.id!==r)}))},this.getFile=r=>this.state.files.find(o=>o.id===r),this.updateFile=(r,o)=>{this.setState(a=>({files:a.files.map(n=>n.id===r?o:n)}))},this.onUploadComplete=(r,o)=>{this.setState(()=>({shutter:!1}));const a=this.getFile(r);P(a)||a.status.type!=="uploading"||this.updateFile(a.id,a.setStatus({type:"uploaded",fileId:o.fileId,fileUrls:o}))},this.onUploadProgress=(r,o)=>{const a=this.getFile(o);if(P(a)||a.status.type!=="uploading")return;const n=Math.round(r.loaded*100/r.total);a.status.progress!==n&&this.updateFile(o,a.setStatus({type:"uploading",cancelToken:a.status.cancelToken,progress:n}))},this.reset=()=>{this.setState({files:[],imgSrc:null})},this.uploadFile=(r,o)=>{const a=V.CancelToken.source(),n=new L(o.name,o.size,this.nextLocalFileId(),{type:"uploading",cancelToken:a,progress:1});this.addFile(n),this.props.uploadClient.uploadFile(this.props.element,r.uploadUrl,o,s=>this.onUploadProgress(s,n.id),a.token).then(()=>this.onUploadComplete(n.id,r)).catch(s=>{V.isCancel(s)||this.updateFile(n.id,n.setStatus({type:"error",errorMessage:s?s.toString():"Unknown error"}))})},this.state=this.initialValue}get initialValue(){const l={files:[],imgSrc:null,shutter:!1,minShutterEffectPassed:!0,clearPhotoInProgress:!1,facingMode:F.USER},{widgetMgr:r,element:o}=this.props,a=r.getFileUploaderStateValue(o);if(P(a))return l;const{uploadedFileInfo:n}=a;return P(n)||n.length===0?l:{files:n.map(s=>{const p=s.name,g=s.size,U=s.fileId,C=s.fileUrls;return new L(p,g,this.nextLocalFileId(),{type:"uploaded",fileId:U,fileUrls:C})}),imgSrc:n.length===0?"":this.RESTORED_FROM_WIDGET_STRING,shutter:!1,minShutterEffectPassed:!1,clearPhotoInProgress:!1,facingMode:F.USER}}componentWillUnmount(){this.formClearHelper.disconnect()}get status(){const l=r=>r.status.type==="uploading";return this.state.files.some(l)?"updating":"ready"}componentDidMount(){const l=this.createWidgetValue(),{element:r,widgetMgr:o,fragmentId:a}=this.props;o.getFileUploaderStateValue(r)===void 0&&o.setFileUploaderStateValue(r,l,{fromUi:!1},a)}createWidgetValue(){const l=this.state.files.filter(r=>r.status.type==="uploaded").map(r=>{const{name:o,size:a,status:n}=r;return new ce({fileId:n.fileId,fileUrls:n.fileUrls,name:o,size:a})});return new ue({uploadedFileInfo:l})}render(){var n;const{element:l,widgetMgr:r,disabled:o,width:a}=this.props;return this.formClearHelper.manageFormClearListener(r,l.formId,this.onFormCleared),R(G,{className:"stCameraInput","data-testid":"stCameraInput",children:[h(ge,{label:l.label,disabled:o,labelVisibility:pe((n=l.labelVisibility)==null?void 0:n.value),children:l.help&&h(fe,{children:h(he,{content:l.help,placement:z.TOP_RIGHT})})}),this.state.imgSrc?R(me,{children:[h(W,{width:a,children:this.state.imgSrc!==this.RESTORED_FROM_WIDGET_STRING&&h(we,{src:this.state.imgSrc,alt:"Snapshot",opacity:this.state.shutter||!this.state.minShutterEffectPassed?"50%":"100%",width:a,height:a*9/16})}),h(q,{onClick:this.removeCapture,progress:this.getProgress(),disabled:!!this.getProgress()||o,children:this.getProgress()?"Uploading...":R(Ue,{children:[h(O,{content:H,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):h(Oe,{handleCapture:this.handleCapture,width:a,disabled:o,clearPhotoInProgress:this.state.clearPhotoInProgress,setClearPhotoInProgress:this.setClearPhotoInProgress,facingMode:this.state.facingMode,setFacingMode:this.setFacingMode,testOverride:this.props.testOverride})]})}nextLocalFileId(){return this.localFileIdCounter++}}function ke(t,l){return fetch(t).then(r=>r.arrayBuffer()).then(r=>new File([r],l,{type:"image/jpeg"}))}const He=ne(Le);export{He as default};
|