streamlit-nightly 1.42.3.dev20250224__py2.py3-none-any.whl → 1.42.3.dev20250226__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/config.py +11 -4
- streamlit/elements/arrow.py +16 -8
- streamlit/elements/widgets/chat.py +99 -17
- streamlit/elements/widgets/data_editor.py +12 -7
- streamlit/elements/widgets/file_uploader.py +20 -10
- streamlit/proto/ClientState_pb2.py +5 -3
- streamlit/proto/ClientState_pb2.pyi +29 -2
- streamlit/proto/NewSession_pb2.py +16 -16
- streamlit/proto/NewSession_pb2.pyi +9 -9
- streamlit/runtime/app_session.py +5 -0
- streamlit/runtime/caching/hashing.py +67 -5
- streamlit/runtime/context.py +19 -0
- streamlit/runtime/scriptrunner/script_runner.py +2 -0
- streamlit/runtime/scriptrunner_utils/script_requests.py +7 -1
- streamlit/runtime/scriptrunner_utils/script_run_context.py +4 -0
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{FileDownload.esm.Db6P60XC.js → FileDownload.esm.CWn5B5ZN.js} +1 -1
- streamlit/static/static/js/{FileHelper.LHDgAkEu.js → FileHelper.Bii_mi1A.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.BkPbs0OF.js → FormClearHelper.BlCIuWCo.js} +1 -1
- streamlit/static/static/js/{Hooks.CW1Ujj-E.js → Hooks.DURid8_V.js} +1 -1
- streamlit/static/static/js/{InputInstructions.CHpHVupe.js → InputInstructions.gFFpIc6i.js} +1 -1
- streamlit/static/static/js/{ProgressBar.CSZV-k_M.js → ProgressBar.CtXtbXhv.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.CrI9B0Qh.js → RenderInPortalIfExists.DKWNQmbm.js} +1 -1
- streamlit/static/static/js/{Toolbar.CfNF-56q.js → Toolbar.CKKwksQV.js} +1 -1
- streamlit/static/static/js/{base-input.BBFJwxWO.js → base-input.BUY9TLqO.js} +3 -3
- streamlit/static/static/js/checkbox.C4L_5Z9H.js +9 -0
- streamlit/static/static/js/{createSuper.rz8EjYR0.js → createSuper.DprEKsA6.js} +1 -1
- streamlit/static/static/js/data-grid-overlay-editor.BArvtwSg.js +1 -0
- streamlit/static/static/js/{downloader.DEY2_Oao.js → downloader.C5pxkE2v.js} +1 -1
- streamlit/static/static/js/{es6.Cbt8Qb0v.js → es6.DmKjMqyQ.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.DlY1zPt7.js → iframeResizer.contentWindow.DhqbXIl1.js} +1 -1
- streamlit/static/static/js/{index.LmMDdxLh.js → index.B-S4HX7x.js} +1 -1
- streamlit/static/static/js/{index.InwDjRN5.js → index.B-vrwvgD.js} +1 -1
- streamlit/static/static/js/index.BAfr2RC0.js +3865 -0
- streamlit/static/static/js/index.BCErGZwr.js +1 -0
- streamlit/static/static/js/{index.Bv1JbhEf.js → index.BEnZZwfW.js} +1 -1
- streamlit/static/static/js/{index.CUepHEom.js → index.BSczaRDm.js} +1 -1
- streamlit/static/static/js/{index.BtBNIxWC.js → index.BUnWa5Cg.js} +1 -1
- streamlit/static/static/js/{index.BFFhpOhV.js → index.BVHfAEko.js} +1 -1
- streamlit/static/static/js/{index.CIDueoC2.js → index.Bds7Anva.js} +1 -1
- streamlit/static/static/js/index.Bk3A478D.js +197 -0
- streamlit/static/static/js/{index.D2PC_wwi.js → index.BmnSGdtS.js} +1 -1
- streamlit/static/static/js/{index.DPZJrrNj.js → index.BoBCblDb.js} +1 -1
- streamlit/static/static/js/{index.Bhf5i-o4.js → index.C3l2zbST.js} +1 -1
- streamlit/static/static/js/{index.C9kvqGu0.js → index.CTqvpoOz.js} +1 -1
- streamlit/static/static/js/{index.DEz7mrAp.js → index.CXpOPWFV.js} +1 -1
- streamlit/static/static/js/{index.CjN5S59O.js → index.Cd03IYkG.js} +1 -1
- streamlit/static/static/js/{index.C41AtD-D.js → index.ChEJa75P.js} +1 -1
- streamlit/static/static/js/{index.DxvQWdtj.js → index.CoQjULdH.js} +18 -18
- streamlit/static/static/js/{index.I2Ij_yHL.js → index.CvNhwseQ.js} +1 -1
- streamlit/static/static/js/{index.D1sfL1bE.js → index.D2-IYCcZ.js} +1 -1
- streamlit/static/static/js/{index.DuUcgXrv.js → index.D2G24Udm.js} +1 -1
- streamlit/static/static/js/index.DNr2W0gq.js +1 -0
- streamlit/static/static/js/{index.jj20zRA4.js → index.DhcYAj3f.js} +1 -1
- streamlit/static/static/js/{index.BcIDRdbw.js → index.DtIKjlNZ.js} +1 -1
- streamlit/static/static/js/{index.C3FZ8TOb.js → index.EIkP6R_d.js} +2 -2
- streamlit/static/static/js/{index.7HEH_7fJ.js → index.KPwXWqBk.js} +7 -7
- streamlit/static/static/js/index.NKOzzX__.js +1 -0
- streamlit/static/static/js/{index.B5Q1lb1E.js → index.O5-Wn4Yr.js} +1 -1
- streamlit/static/static/js/index.RFfgDsnM.js +2 -0
- streamlit/static/static/js/{index.8pg9ijwI.js → index.RrEbViHi.js} +1 -1
- streamlit/static/static/js/{index.CUFUpykP.js → index.UE_L1IEZ.js} +2 -2
- streamlit/static/static/js/index.WAlW9lgW.js +1 -0
- streamlit/static/static/js/{index.CgZ_3VRU.js → index.c_V1HXTs.js} +1 -1
- streamlit/static/static/js/{index.Df3vkO_v.js → index.doRPQ8od.js} +1 -1
- streamlit/static/static/js/index.oPGa5nFU.js +1 -0
- streamlit/static/static/js/{index.D8mp5ppE.js → index.u1gL_Cm_.js} +1 -1
- streamlit/static/static/js/{index.LypQPPkP.js → index.xTncca7J.js} +1 -1
- streamlit/static/static/js/{input.QeLiGsyn.js → input.EkJ_AsTP.js} +1 -1
- streamlit/static/static/js/{memory.0fYVo8Wx.js → memory.BFs17dZE.js} +1 -1
- streamlit/static/static/js/{mergeWith.AOqADio_.js → mergeWith.B4u0whL-.js} +1 -1
- streamlit/static/static/js/number-overlay-editor.DwazN43x.js +9 -0
- streamlit/static/static/js/{possibleConstructorReturn.C4RsC1R8.js → possibleConstructorReturn.CZfYLVBb.js} +1 -1
- streamlit/static/static/js/{sandbox.DT2p3KTe.js → sandbox.PjijA1v1.js} +1 -1
- streamlit/static/static/js/{textarea.DQh9RYKV.js → textarea.BGGnQXtw.js} +1 -1
- streamlit/static/static/js/{timepicker.Br_cR0hi.js → timepicker.eLEnk1tw.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.CzYSWELu.js → toConsumableArray.CgKj9NUY.js} +1 -1
- streamlit/static/static/js/uniqueId.CPmOGhdZ.js +1 -0
- streamlit/static/static/js/{useBasicWidgetState.6R32QW2v.js → useBasicWidgetState.Bw_fxTtX.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.C4OiWI1_.js → useOnInputChange.D8qi7pm4.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.BLeP_b5i.js → withFullScreenWrapper.BjVufR9b.js} +1 -1
- streamlit/user_info.py +4 -12
- {streamlit_nightly-1.42.3.dev20250224.dist-info → streamlit_nightly-1.42.3.dev20250226.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.42.3.dev20250224.dist-info → streamlit_nightly-1.42.3.dev20250226.dist-info}/RECORD +88 -87
- {streamlit_nightly-1.42.3.dev20250224.dist-info → streamlit_nightly-1.42.3.dev20250226.dist-info}/WHEEL +1 -1
- streamlit/static/static/js/data-grid-overlay-editor.DUagmDpG.js +0 -1
- streamlit/static/static/js/index.C29vTftb.js +0 -3865
- streamlit/static/static/js/index.CUWXxL_C.js +0 -1
- streamlit/static/static/js/index.C_SUbLL7.js +0 -1
- streamlit/static/static/js/index.CdiPATR3.js +0 -197
- streamlit/static/static/js/index.Con6tiNg.js +0 -1
- streamlit/static/static/js/index.DymllY6d.js +0 -2
- streamlit/static/static/js/index.G1PSqufB.js +0 -9
- streamlit/static/static/js/index.RDHMaPCV.js +0 -1
- streamlit/static/static/js/number-overlay-editor.DAvAckzz.js +0 -9
- streamlit/static/static/js/uniqueId.BdUnRe3-.js +0 -1
- {streamlit_nightly-1.42.3.dev20250224.data → streamlit_nightly-1.42.3.dev20250226.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.42.3.dev20250224.dist-info → streamlit_nightly-1.42.3.dev20250226.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.42.3.dev20250224.dist-info → streamlit_nightly-1.42.3.dev20250226.dist-info}/top_level.txt +0 -0
@@ -1 +0,0 @@
|
|
1
|
-
import{r,E as X,_ as q,n as x,y as ut,bh as ct,cr as dt,M as J,cB as I,K as b,B as N,j as u,bs as pt,bF as ft,bt,ba as mt,bu as gt,bp as M,ar as ht}from"./index.7HEH_7fJ.js";import{s as yt}from"./sprintf.D7DtBTRn.js";import{u as It}from"./uniqueId.BdUnRe3-.js";import{u as Tt}from"./FormClearHelper.BkPbs0OF.js";import{I as wt}from"./InputInstructions.CHpHVupe.js";import{I as Ct}from"./input.QeLiGsyn.js";import"./base-input.BBFJwxWO.js";var Q=r.forwardRef(function(t,e){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(X,q({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),r.createElement("path",{d:"M0 3v2h8V3H0z"}))});Q.displayName="Minus";var Y=r.forwardRef(function(t,e){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(X,q({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),r.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"}),G=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=ht.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,K=({step:t,dataType:e})=>t||(e===I.DataType.INT?1:.01),z=({value:t,format:e,step:o,dataType:f})=>{if(b(t))return null;let n=xt(e);if(b(n)&&J(o)){const d=o.toString();f===I.DataType.FLOAT&&o!==0&&d.includes(".")&&(n=`%0.${d.split(".")[1].length}f`)}if(b(n))return t.toString();try{return yt.sprintf(n,t)}catch(d){return kt.warn(`Error in sprintf(${n}, ${t}): ${d}`),String(t)}},Dt=(t,e,o)=>b(t)?!1:t-e>=o,Et=(t,e,o)=>b(t)?!1:t+e<=o,Ft=({disabled:t,element:e,widgetMgr:o,fragmentId:f})=>{var j;const n=ut(),{dataType:d,id:C,formId:p,default:B,format:W}=e,m=e.hasMin?e.min:-1/0,g=e.hasMax?e.max:1/0,{values:[A],elementRef:Z}=ct(r.useMemo(()=>["width"],[])),[s,tt]=r.useState(K(e)),H=Rt({element:e,widgetMgr:o}),[h,T]=r.useState(!1),[i,w]=r.useState(H),[L,v]=r.useState(z({value:H,...e,step:s})),[P,U]=r.useState(!1),R=r.useRef(null),$=r.useRef(It("number_input_")),S=Dt(i,s,m),V=Et(i,s,g),O=dt({formId:p}),et=O?o.allowFormEnterToSubmit(p):h,rt=P&&A>n.breakpoints.hideWidgetDetails;r.useEffect(()=>{tt(K({step:e.step,dataType:e.dataType}))},[e.dataType,e.step]);const l=r.useCallback(({value:a,source:c})=>{var y;if(J(a)&&(m>a||a>g))(y=R.current)==null||y.reportValidity();else{const k=a??B??null;switch(d){case I.DataType.INT:o.setIntValue({id:C,formId:p},k,c,f);break;case I.DataType.FLOAT:o.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:W,step:s}))}},[m,g,R,o,f,s,d,C,p,B,W]),ot=r.useCallback(()=>{h&&l({value:i,source:{fromUi:!0}}),U(!1)},[h,i,l]),nt=r.useCallback(()=>{U(!0)},[]),_=r.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]);r.useEffect(()=>{e.setValue?_():l({value:i,source:{fromUi:!1}})},[]),e.setValue&&_();const D=b(e.default)&&!t,at=r.useCallback(()=>{const a=e.default??null;w(a),l({value:a,source:{fromUi:!0}})},[e]);Tt({element:e,widgetMgr:o,onFormCleared:at});const st=a=>{const{value:c}=a.target;if(c==="")T(!0),w(null),v(null);else{let y;e.dataType===I.DataType.INT?y=parseInt(c,10):y=parseFloat(c),T(!0),w(y),v(c)}},E=r.useCallback(()=>{V&&(T(!0),l({value:(i??m)+s,source:{fromUi:!0}}))},[i,m,s,V]),F=r.useCallback(()=>{S&&(T(!0),l({value:(i??g)-s,source:{fromUi:!0}}))},[i,g,s,S]),it=r.useCallback(a=>{const{key:c}=a;switch(c){case"ArrowUp":a.preventDefault(),E();break;case"ArrowDown":a.preventDefault(),F();break}},[E,F]),lt=r.useCallback(a=>{a.key==="Enter"&&(h&&l({value:i,source:{fromUi:!0}}),o.allowFormEnterToSubmit(p)&&o.submitForm(p,f))},[h,i,l,o,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:P?"focused":"","data-testid":"stNumberInputContainer",children:[u(Ct,{type:"number",inputRef:R,value:L??"",placeholder:e.placeholder,onBlur:ot,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(G,{"data-testid":"stNumberInputStepDown",onClick:F,disabled:!S||t,tabIndex:-1,children:u(M,{content:Q,size:"xs",color:S?"inherit":n.colors.disabled})}),u(G,{"data-testid":"stNumberInputStepUp",onClick:E,disabled:!V||t,tabIndex:-1,children:u(M,{content:Y,size:"xs",color:V?"inherit":n.colors.disabled})})]})]}),rt&&u(Vt,{clearable:D,children:u(wt,{dirty:h,value:L??"",inForm:O,allowEnterToSubmit:et})})]})},Pt=r.memo(Ft);export{Pt as default};
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as M,E as T,_ as O,n as I,ax as K,B as P,j as h,bv as Y,ba as $,bq as Z,b5 as ee,bp as j,bC as z,d as te,g as re,aL as ie,y as ae,bD as ne,bE as oe,bi as se,R as le,ar as de,aA as ce,K as x,bm as ue,bl as pe,bs as fe,bF as he,bt as ge,bu as me,F as ve}from"./index.7HEH_7fJ.js";import{a as V}from"./index.DW_MHI2K.js";import{F as Se}from"./FormClearHelper.BkPbs0OF.js";import{U as L}from"./UploadFileInfo.C-jY39rj.js";import{P as ye,S as be}from"./ProgressBar.CSZV-k_M.js";var N=M.forwardRef(function(t,l){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return M.createElement(T,O({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 D=M.forwardRef(function(t,l){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return M.createElement(T,O({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"}))});D.displayName="X";var H=M.forwardRef(function(t,l){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return M.createElement(T,O({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"}))});H.displayName="SwitchCamera";var k;(function(t){t.XSMALL="xsmall",t.SMALL="small",t.MEDIUM="medium",t.LARGE="large"})(k||(k={}));function Me(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=I("div",{target:"e47j7ja0"})({position:"relative",overflow:"hidden",width:"100%",objectFit:"contain"}),W=I("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"})),we=I("p",{target:"e47j7ja2"})(({theme:t})=>({marginTop:t.spacing.sm,textAlign:"center"})),Ce=I("img",{target:"e47j7ja3"})(({theme:t,opacity:l})=>({borderRadius:`${t.radii.default} ${t.radii.default} 0 0`,objectFit:"contain",opacity:l})),Ue=I("a",{target:"e47j7ja4"})(({theme:t})=>({color:t.colors.primary,display:"block",textDecoration:"none"})),Ie=I("span",{target:"e47j7ja5"})({display:"flex",alignItems:"center"}),Ee=I("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})),Fe=I("div",{target:"e47j7ja8"})({height:"fit-content",width:"100%",position:"absolute",bottom:0}),Pe=I("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 ${K(t.colors.primary,.5)}`},...Me("medium",t)}));function q({disabled:t,onClick:l,children:r,progress:n}){return P(Pe,{disabled:t||!1,onClick:l||(()=>{}),progress:n||null,"data-testid":"stCameraInputButton",children:[r,n&&h(Fe,{children:h(ye,{value:n,size:be.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(Y,{content:"Switch camera",placement:$.TOP_RIGHT,children:h(Z,{kind:ee.MINIMAL,onClick:t,children:h(j,{content:H,size:"twoXL",color:z.white})})})});var _={exports:{}},xe=_.exports,B;function _e(){return B||(B=1,function(t,l){(function(n,a){t.exports=a(te())})(xe,function(r){return function(n){var a={};function o(s){if(a[s])return a[s].exports;var p=a[s]={i:s,l:!1,exports:{}};return n[s].call(p.exports,p,p.exports,o),p.l=!0,p.exports}return o.m=n,o.c=a,o.d=function(s,p,g){o.o(s,p)||Object.defineProperty(s,p,{enumerable:!0,get:g})},o.r=function(s){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},o.t=function(s,p){if(p&1&&(s=o(s)),p&8||p&4&&typeof s=="object"&&s&&s.__esModule)return s;var g=Object.create(null);if(o.r(g),Object.defineProperty(g,"default",{enumerable:!0,value:s}),p&2&&typeof s!="string")for(var U in s)o.d(g,U,(function(C){return s[C]}).bind(null,U));return g},o.n=function(s){var p=s&&s.__esModule?function(){return s.default}:function(){return s};return o.d(p,"a",p),p},o.o=function(s,p){return Object.prototype.hasOwnProperty.call(s,p)},o.p="",o(o.s="./src/react-webcam.tsx")}({"./src/react-webcam.tsx":function(n,a,o){o.r(a);var s=o("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 E=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),b=e.minScreenshotWidth!==i.minScreenshotWidth,S=e.minScreenshotHeight!==i.minScreenshotHeight;(c||b||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 b=this.getCanvas(e);return b&&b.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 b=this.video.videoWidth,S=this.video.videoHeight;if(!this.props.forceScreenshotSourceSize){var v=b/S;b=c.minScreenshotWidth||this.video.clientWidth,S=b/v,c.minScreenshotHeight&&S<c.minScreenshotHeight&&(S=c.minScreenshotHeight,b=S*v)}this.canvas=document.createElement("canvas"),this.canvas.width=(e==null?void 0:e.width)||b,this.canvas.height=(e==null?void 0:e.height)||S,this.ctx=this.canvas.getContext("2d")}var w=this,y=w.ctx,f=w.canvas;return y&&f&&(f.width=(e==null?void 0:e.width)||f.width,f.height=(e==null?void 0:e.height)||f.height,c.mirrored&&(y.translate(f.width,0),y.scale(-1,1)),y.imageSmoothingEnabled=c.imageSmoothing,y.drawImage(this.video,0,0,(e==null?void 0:e.width)||f.width,(e==null?void 0:e.height)||f.height),c.mirrored&&(y.scale(-1,1),y.translate(-f.width,0))),f},u.prototype.requestUserMedia=function(){var e=this,i=this.props,d=function(S,v){var w={video:typeof v<"u"?v:!0};i.audio&&(w.audio=typeof S<"u"?S:!0),e.requestUserMediaId++;var y=e.requestUserMediaId;navigator.mediaDevices.getUserMedia(w).then(function(f){e.unmounted||y!==e.requestUserMediaId?u.stopMediaStream(f):e.handleUserMedia(null,f)}).catch(function(f){e.handleUserMedia(f)})};if("mediaDevices"in navigator)d(i.audioConstraints,i.videoConstraints);else{var c=function(S){return{optional:[{sourceId:S}]}},b=function(S){var v=S.deviceId;return typeof v=="string"?v:Array.isArray(v)&&v.length>0?v[0]:typeof v=="object"&&v.ideal?v.ideal:null};MediaStreamTrack.getSources(function(S){var v=null,w=null;S.forEach(function(R){R.kind==="audio"?v=R.id:R.kind==="video"&&(w=R.id)});var y=b(i.audioConstraints);y&&(v=y);var f=b(i.videoConstraints);f&&(w=f),d(c(v),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,b=c.audio;c.forceScreenshotSourceSize;var S=c.disablePictureInPicture;c.onUserMedia,c.onUserMediaError,c.screenshotFormat,c.screenshotQuality,c.minScreenshotWidth,c.minScreenshotHeight,c.audioConstraints,c.videoConstraints,c.imageSmoothing;var v=c.mirrored,w=c.style,y=w===void 0?{}:w,f=c.children,R=U(c,["audio","forceScreenshotSourceSize","disablePictureInPicture","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored","style","children"]),X=v?g(g({},y),{transform:(y.transform||"")+" scaleX(-1)"}):y,Q={getScreenshot:this.getScreenshot.bind(this)};return s.createElement(s.Fragment,null,s.createElement("video",g({autoPlay:!0,disablePictureInPicture:S,src:d.src,muted:!b,playsInline:!0,ref:function(J){e.video=J},style:X},R)),f&&f(Q))},u.defaultProps={audio:!1,disablePictureInPicture:!1,forceScreenshotSourceSize:!1,imageSmoothing:!0,mirrored:!1,onUserMedia:function(){},onUserMediaError:function(){},screenshotFormat:"image/webp",screenshotQuality:.92},u}(s.Component);a.default=E},react:function(n,a){n.exports=r}}).default})}(_)),_.exports}var Te=_e();const Oe=re(Te);var A;(function(t){t.PENDING="pending",t.SUCCESS="success",t.ERROR="error"})(A||(A={}));const je=({width:t})=>P(W,{width:t,children:[h(j,{size:"threeXL",color:z.gray60,content:N}),P(we,{children:["This app would like to use your camera.",h(Ue,{href:oe,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]})]}),We=({handleCapture:t,width:l,disabled:r,clearPhotoInProgress:n,setClearPhotoInProgress:a,facingMode:o,setFacingMode:s,testOverride:p})=>{const[g,U]=M.useState(p||"pending"),C=M.useRef(null),[E,m]=M.useState(l),u=M.useCallback(ie(1e3,m),[]);M.useEffect(()=>{u(l)},[l,u]);function e(){if(C.current!==null){const d=C.current.getScreenshot();t(d)}}const i=ae();return P(G,{"data-testid":"stCameraInputWebcamComponent",children:[g!=="success"&&!r&&!n?h(je,{width:E}):ne.isMobile&&h(Re,{switchFacingMode:s}),h(W,{"data-testid":"stCameraInputWebcamStyledBox",hidden:g!=="success"&&!r&&!n,width:E,children:!r&&h(Oe,{audio:!1,ref:C,screenshotFormat:"image/jpeg",screenshotQuality:1,width:E,height:E*9/16,style:{borderRadius:`${i.radii.default} ${i.radii.default} 0 0`},onUserMediaError:()=>{U("error")},onUserMedia:()=>{U("success"),a(!1)},videoConstraints:{width:{ideal:E},facingMode:o}})}),h(q,{onClick:e,disabled:g!=="success"||r||n,children:"Take Photo"})]})},Ve=150,Le=de.getLogger("CameraInput");class ke extends le.PureComponent{constructor(l){super(l),this.localFileIdCounter=1,this.RESTORED_FROM_WIDGET_STRING="RESTORED_FROM_WIDGET",this.formClearHelper=new Se,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 n=a=>new Promise(o=>setTimeout(o,a));return Be(r,`camera-input-${new Date().toISOString().replace(/:/g,"_")}.jpg`).then(a=>this.props.uploadClient.fetchFileURLs([a]).then(o=>({file:a,fileUrls:o[0]}))).then(({file:a,fileUrls:o})=>this.uploadFile(o,a)).then(()=>n(Ve)).then(()=>{this.setState((a,o)=>({imgSrc:r,shutter:a.shutter,minShutterEffectPassed:!0}))}).catch(a=>{Le.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:n,widgetMgr:a,fragmentId:o}=this.props,s=a.getFileUploaderStateValue(n);ce(r,s)||a.setFileUploaderStateValue(n,r,{fromUi:!0},o)},this.onFormCleared=()=>{this.setState({files:[]},()=>{const r=this.createWidgetValue();if(x(r))return;this.setState({imgSrc:null});const{widgetMgr:n,element:a,fragmentId:o}=this.props;n.setFileUploaderStateValue(a,r,{fromUi:!0},o)})},this.deleteFile=r=>{const n=this.getFile(r);x(n)||(n.status.type==="uploading"&&n.status.cancelToken.cancel(),n.status.type==="uploaded"&&n.status.fileUrls.deleteUrl&&this.props.uploadClient.deleteFile(n.status.fileUrls.deleteUrl),this.removeFile(r))},this.addFile=r=>{this.setState(n=>({files:[...n.files,r]}))},this.removeFile=r=>{this.setState(n=>({files:n.files.filter(a=>a.id!==r)}))},this.getFile=r=>this.state.files.find(n=>n.id===r),this.updateFile=(r,n)=>{this.setState(a=>({files:a.files.map(o=>o.id===r?n:o)}))},this.onUploadComplete=(r,n)=>{this.setState(()=>({shutter:!1}));const a=this.getFile(r);x(a)||a.status.type!=="uploading"||this.updateFile(a.id,a.setStatus({type:"uploaded",fileId:n.fileId,fileUrls:n}))},this.onUploadProgress=(r,n)=>{const a=this.getFile(n);if(x(a)||a.status.type!=="uploading")return;const o=Math.round(r.loaded*100/r.total);a.status.progress!==o&&this.updateFile(n,a.setStatus({type:"uploading",cancelToken:a.status.cancelToken,progress:o}))},this.reset=()=>{this.setState({files:[],imgSrc:null})},this.uploadFile=(r,n)=>{const a=V.CancelToken.source(),o=new L(n.name,n.size,this.nextLocalFileId(),{type:"uploading",cancelToken:a,progress:1});this.addFile(o),this.props.uploadClient.uploadFile(this.props.element,r.uploadUrl,n,s=>this.onUploadProgress(s,o.id),a.token).then(()=>this.onUploadComplete(o.id,r)).catch(s=>{V.isCancel(s)||this.updateFile(o.id,o.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:n}=this.props,a=r.getFileUploaderStateValue(n);if(x(a))return l;const{uploadedFileInfo:o}=a;return x(o)||o.length===0?l:{files:o.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:o.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:n,fragmentId:a}=this.props;n.getFileUploaderStateValue(r)===void 0&&n.setFileUploaderStateValue(r,l,{fromUi:!1},a)}createWidgetValue(){const l=this.state.files.filter(r=>r.status.type==="uploaded").map(r=>{const{name:n,size:a,status:o}=r;return new ue({fileId:o.fileId,fileUrls:o.fileUrls,name:n,size:a})});return new pe({uploadedFileInfo:l})}render(){var o;const{element:l,widgetMgr:r,disabled:n,width:a}=this.props;return this.formClearHelper.manageFormClearListener(r,l.formId,this.onFormCleared),P(G,{className:"stCameraInput","data-testid":"stCameraInput",children:[h(me,{label:l.label,disabled:n,labelVisibility:fe((o=l.labelVisibility)==null?void 0:o.value),children:l.help&&h(he,{children:h(ge,{content:l.help,placement:$.TOP_RIGHT})})}),this.state.imgSrc?P(ve,{children:[h(W,{width:a,children:this.state.imgSrc!==this.RESTORED_FROM_WIDGET_STRING&&h(Ce,{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()||n,children:this.getProgress()?"Uploading...":P(Ie,{children:[h(j,{content:D,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):h(We,{handleCapture:this.handleCapture,width:a,disabled:n,clearPhotoInProgress:this.state.clearPhotoInProgress,setClearPhotoInProgress:this.setClearPhotoInProgress,facingMode:this.state.facingMode,setFacingMode:this.setFacingMode,testOverride:this.props.testOverride})]})}nextLocalFileId(){return this.localFileIdCounter++}}function Be(t,l){return fetch(t).then(r=>r.arrayBuffer()).then(r=>new File([r],l,{type:"image/jpeg"}))}const He=se(ke);export{He as default};
|