streamlit-nightly 1.42.3.dev20250220__py2.py3-none-any.whl → 1.42.3.dev20250222__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/widgets/button.py +14 -4
- streamlit/proto/DownloadButton_pb2.py +2 -2
- streamlit/proto/DownloadButton_pb2.pyi +4 -1
- streamlit/runtime/credentials.py +15 -16
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{FileDownload.esm.CSCu_FQk.js → FileDownload.esm.B1kyp21I.js} +1 -1
- streamlit/static/static/js/{FileDropzone.xME_qwl7.js → FileDropzone.uWzTac7M.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.D7FpzEHQ.js → FormClearHelper.CEl0YyS3.js} +1 -1
- streamlit/static/static/js/{Hooks.Ofd2jLSe.js → Hooks.B_-0sclb.js} +1 -1
- streamlit/static/static/js/{InputInstructions.C5AiI5fd.js → InputInstructions.M8GsfWtP.js} +1 -1
- streamlit/static/static/js/{ProgressBar.St3jxlFz.js → ProgressBar.DDliFXvs.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.JQTUbdhz.js → RenderInPortalIfExists.DON5no2j.js} +1 -1
- streamlit/static/static/js/{Toolbar.mIL79bYR.js → Toolbar.DGwjBtCI.js} +1 -1
- streamlit/static/static/js/{base-input.CoahMH6I.js → base-input.Dz6cKnV_.js} +1 -1
- streamlit/static/static/js/{createSuper.DJC0972y.js → createSuper.bXxYJzro.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.C9j6qKVt.js → data-grid-overlay-editor.BrHDbHOn.js} +1 -1
- streamlit/static/static/js/{downloader.BmN5QG23.js → downloader.BUh1naKp.js} +1 -1
- streamlit/static/static/js/{es6.CkTV0_PT.js → es6.C8XVTTHj.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.GG3aQxlr.js → iframeResizer.contentWindow.DGWt48-l.js} +1 -1
- streamlit/static/static/js/{index.od8XlC_e.js → index.6zGrdP7S.js} +118 -118
- streamlit/static/static/js/{index.C6YhHXiT.js → index.94WymsOx.js} +1 -1
- streamlit/static/static/js/{index.Bhh-YA7-.js → index.B1Y_k9Fh.js} +1 -1
- streamlit/static/static/js/{index.C2RhGRpZ.js → index.B66JaJi3.js} +1 -1
- streamlit/static/static/js/{index.D6v0tURe.js → index.BBotNZr-.js} +1 -1
- streamlit/static/static/js/{index.DX8V4iLG.js → index.BUnE-2Mi.js} +1 -1
- streamlit/static/static/js/{index.DMRnVKOx.js → index.BXFE-6NA.js} +1 -1
- streamlit/static/static/js/{index.BFMT7m5S.js → index.BhKdTR4z.js} +1 -1
- streamlit/static/static/js/{index.BtEGgjQs.js → index.BiCX2JZK.js} +1 -1
- streamlit/static/static/js/{index.40cNUDYj.js → index.BrXMfzqp.js} +1 -1
- streamlit/static/static/js/{index.GL3uWznV.js → index.BxBwZJQr.js} +1 -1
- streamlit/static/static/js/{index.LvS7giIF.js → index.C2VChsA1.js} +1 -1
- streamlit/static/static/js/{index.BgviuYiK.js → index.C2skmlN3.js} +1 -1
- streamlit/static/static/js/{index.BWRgNHzG.js → index.C5zcxetk.js} +1 -1
- streamlit/static/static/js/{index.DtOoKZuY.js → index.C9nK-VoQ.js} +1 -1
- streamlit/static/static/js/{index.DgheNneH.js → index.CNDCHhth.js} +1 -1
- streamlit/static/static/js/{index.GumFavEm.js → index.CNYNhiEk.js} +1 -1
- streamlit/static/static/js/{index.Cu1SST0o.js → index.CUKOkOB2.js} +36 -36
- streamlit/static/static/js/{index.DGCNoFUa.js → index.Ceuq3IzZ.js} +1 -1
- streamlit/static/static/js/{index.DLmg74_p.js → index.ChSsIvr7.js} +2 -2
- streamlit/static/static/js/{index.B0fq3djO.js → index.D-4pSvTG.js} +1 -1
- streamlit/static/static/js/{index.D8VHOaj4.js → index.DB9G9YYY.js} +1 -1
- streamlit/static/static/js/{index.DpMH9Ich.js → index.DKFH0WYB.js} +1 -1
- streamlit/static/static/js/{index.C_y3GDl0.js → index.DO1Rv491.js} +1 -1
- streamlit/static/static/js/{index.DlpiXPka.js → index.DQT0NMTW.js} +1 -1
- streamlit/static/static/js/{index.BIb_Q_t2.js → index.DU4gaNU_.js} +1 -1
- streamlit/static/static/js/{index.CmKQs94B.js → index.D_tVZ0u0.js} +1 -1
- streamlit/static/static/js/{index.euIqXpX7.js → index.Da7VTJGp.js} +1 -1
- streamlit/static/static/js/{index.DvpzuDf3.js → index.DcA_kXA1.js} +1 -1
- streamlit/static/static/js/index.DgCaLwAb.js +1 -0
- streamlit/static/static/js/{index.CcxxDrWU.js → index.DiXeiIyQ.js} +1 -1
- streamlit/static/static/js/{index.DxseZbLQ.js → index.Dl_RyApM.js} +1 -1
- streamlit/static/static/js/{index.F-Swvxpp.js → index.DvUg88R_.js} +1 -1
- streamlit/static/static/js/{index.c4SbAEld.js → index.NifETEVc.js} +2 -2
- streamlit/static/static/js/{index.BIMiZM1d.js → index.iYzAfcLx.js} +1 -1
- streamlit/static/static/js/{index.B6DhU6bS.js → index.jSEMrPEJ.js} +1 -1
- streamlit/static/static/js/{index.DGtuJLSc.js → index.lCzpOFcS.js} +2 -2
- streamlit/static/static/js/{input.DQUrmNKe.js → input.DqK048_c.js} +1 -1
- streamlit/static/static/js/{memory.Bc-1m0Hw.js → memory.BYwXutbg.js} +1 -1
- streamlit/static/static/js/{mergeWith.DrVjJq9_.js → mergeWith.CwfhUp-s.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.sGSz7Cjz.js → number-overlay-editor.B-1TJraW.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.DB_ioxa8.js → possibleConstructorReturn.CCjgmGB4.js} +1 -1
- streamlit/static/static/js/{sandbox.Df3tB-gk.js → sandbox.CzVH3fBX.js} +1 -1
- streamlit/static/static/js/{textarea.COkOU68B.js → textarea.D47OO5VD.js} +1 -1
- streamlit/static/static/js/{timepicker.DHf9u4bk.js → timepicker.Dq2FqiYO.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.B-S6rpdU.js → toConsumableArray.7OyX1dIj.js} +1 -1
- streamlit/static/static/js/{uniqueId.BfMGEPML.js → uniqueId.naIyoATl.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.B8dRKvrk.js → useBasicWidgetState.DH0ClB0l.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.Bntao_G6.js → useOnInputChange.3GZT2mEx.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.CS8vg4vY.js → withFullScreenWrapper.HzikaPlG.js} +1 -1
- {streamlit_nightly-1.42.3.dev20250220.dist-info → streamlit_nightly-1.42.3.dev20250222.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.42.3.dev20250220.dist-info → streamlit_nightly-1.42.3.dev20250222.dist-info}/RECORD +75 -75
- streamlit/static/static/js/index.zss4f62G.js +0 -1
- {streamlit_nightly-1.42.3.dev20250220.data → streamlit_nightly-1.42.3.dev20250222.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.42.3.dev20250220.dist-info → streamlit_nightly-1.42.3.dev20250222.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.42.3.dev20250220.dist-info → streamlit_nightly-1.42.3.dev20250222.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.42.3.dev20250220.dist-info → streamlit_nightly-1.42.3.dev20250222.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
|
|
1
|
-
import{r as M,E as T,_ as j,n as E,aw as J,C as R,j as f,bu as K,b9 as z,bp as Y,b4 as Z,bo as O,bB as $,d as ee,g as te,aK as re,y as ie,bC as ae,bD as oe,bh as ne,R as se,aq as le,az as de,K as P,bl as ce,bk as ue,br as he,bE as pe,bs as fe,bt as ge,F as me}from"./index.od8XlC_e.js";import{a as V}from"./index.DW_MHI2K.js";import{F as ve}from"./FormClearHelper.D7FpzEHQ.js";import{U as L}from"./UploadFileInfo.C-jY39rj.js";import{P as Se,S as ye}from"./ProgressBar.St3jxlFz.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 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 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,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"}))});H.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&&f(Ie,{children:f(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})=>f(Ee,{"data-testid":"stCameraInputSwitchButton",children:f(K,{content:"Switch camera",placement:z.TOP_RIGHT,children:f(Y,{kind:Z.MINIMAL,onClick:t,children:f(O,{content:H,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 h=a[s]={i:s,l:!1,exports:{}};return o[s].call(h.exports,h,h.exports,n),h.l=!0,h.exports}return n.m=o,n.c=a,n.d=function(s,h,g){n.o(s,h)||Object.defineProperty(s,h,{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,h){if(h&1&&(s=n(s)),h&8||h&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}),h&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 h=s&&s.__esModule?function(){return s.default}:function(){return s};return n.d(h,"a",h),h},n.o=function(s,h){return Object.prototype.hasOwnProperty.call(s,h)},n.p="",n(n.s="./src/react-webcam.tsx")}({"./src/react-webcam.tsx":function(o,a,n){n.r(a);var s=n("react"),h=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){h(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 p=y/S;y=c.minScreenshotWidth||this.video.clientWidth,S=y/p,c.minScreenshotHeight&&S<c.minScreenshotHeight&&(S=c.minScreenshotHeight,y=S*p)}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,p){var w={video:typeof p<"u"?p:!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 p=S.deviceId;return typeof p=="string"?p:Array.isArray(p)&&p.length>0?p[0]:typeof p=="object"&&p.ideal?p.ideal:null};MediaStreamTrack.getSources(function(S){var p=null,w=null;S.forEach(function(x){x.kind==="audio"?p=x.id:x.kind==="video"&&(w=x.id)});var b=y(i.audioConstraints);b&&(p=b);var v=y(i.videoConstraints);v&&(w=v),d(c(p),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,p=c.style,w=p===void 0?{}:p,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:[f(O,{size:"threeXL",color:$.gray60,content:N}),R(Me,{children:["This app would like to use your camera.",f(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:h})=>{const[g,U]=M.useState(h||"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?f(je,{width:I}):ae.isMobile&&f(Re,{switchFacingMode:s}),f(W,{"data-testid":"stCameraInputWebcamStyledBox",hidden:g!=="success"&&!r&&!o,width:I,children:!r&&f(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}})}),f(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 h=s.name,g=s.size,U=s.fileId,C=s.fileUrls;return new L(h,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:[f(ge,{label:l.label,disabled:o,labelVisibility:he((n=l.labelVisibility)==null?void 0:n.value),children:l.help&&f(pe,{children:f(fe,{content:l.help,placement:z.TOP_RIGHT})})}),this.state.imgSrc?R(me,{children:[f(W,{width:a,children:this.state.imgSrc!==this.RESTORED_FROM_WIDGET_STRING&&f(we,{src:this.state.imgSrc,alt:"Snapshot",opacity:this.state.shutter||!this.state.minShutterEffectPassed?"50%":"100%",width:a,height:a*9/16})}),f(q,{onClick:this.removeCapture,progress:this.getProgress(),disabled:!!this.getProgress()||o,children:this.getProgress()?"Uploading...":R(Ue,{children:[f(O,{content:D,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):f(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 De=ne(Le);export{De as default};
|
1
|
+
import{r as M,E as T,_ as j,n as E,aw as J,C as R,j as f,bu as K,b9 as z,bp as Y,b4 as Z,bo as O,bB as $,d as ee,g as te,aK as re,y as ie,bC as ae,bD as oe,bh as ne,R as se,aq as le,az as de,K as P,bl as ce,bk as ue,br as he,bE as pe,bs as fe,bt as ge,F as me}from"./index.6zGrdP7S.js";import{a as V}from"./index.DW_MHI2K.js";import{F as ve}from"./FormClearHelper.CEl0YyS3.js";import{U as L}from"./UploadFileInfo.C-jY39rj.js";import{P as Se,S as ye}from"./ProgressBar.DDliFXvs.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 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 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,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"}))});H.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&&f(Ie,{children:f(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})=>f(Ee,{"data-testid":"stCameraInputSwitchButton",children:f(K,{content:"Switch camera",placement:z.TOP_RIGHT,children:f(Y,{kind:Z.MINIMAL,onClick:t,children:f(O,{content:H,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 h=a[s]={i:s,l:!1,exports:{}};return o[s].call(h.exports,h,h.exports,n),h.l=!0,h.exports}return n.m=o,n.c=a,n.d=function(s,h,g){n.o(s,h)||Object.defineProperty(s,h,{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,h){if(h&1&&(s=n(s)),h&8||h&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}),h&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 h=s&&s.__esModule?function(){return s.default}:function(){return s};return n.d(h,"a",h),h},n.o=function(s,h){return Object.prototype.hasOwnProperty.call(s,h)},n.p="",n(n.s="./src/react-webcam.tsx")}({"./src/react-webcam.tsx":function(o,a,n){n.r(a);var s=n("react"),h=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){h(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 p=y/S;y=c.minScreenshotWidth||this.video.clientWidth,S=y/p,c.minScreenshotHeight&&S<c.minScreenshotHeight&&(S=c.minScreenshotHeight,y=S*p)}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,p){var w={video:typeof p<"u"?p:!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 p=S.deviceId;return typeof p=="string"?p:Array.isArray(p)&&p.length>0?p[0]:typeof p=="object"&&p.ideal?p.ideal:null};MediaStreamTrack.getSources(function(S){var p=null,w=null;S.forEach(function(x){x.kind==="audio"?p=x.id:x.kind==="video"&&(w=x.id)});var b=y(i.audioConstraints);b&&(p=b);var v=y(i.videoConstraints);v&&(w=v),d(c(p),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,p=c.style,w=p===void 0?{}:p,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:[f(O,{size:"threeXL",color:$.gray60,content:N}),R(Me,{children:["This app would like to use your camera.",f(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:h})=>{const[g,U]=M.useState(h||"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?f(je,{width:I}):ae.isMobile&&f(Re,{switchFacingMode:s}),f(W,{"data-testid":"stCameraInputWebcamStyledBox",hidden:g!=="success"&&!r&&!o,width:I,children:!r&&f(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}})}),f(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 h=s.name,g=s.size,U=s.fileId,C=s.fileUrls;return new L(h,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:[f(ge,{label:l.label,disabled:o,labelVisibility:he((n=l.labelVisibility)==null?void 0:n.value),children:l.help&&f(pe,{children:f(fe,{content:l.help,placement:z.TOP_RIGHT})})}),this.state.imgSrc?R(me,{children:[f(W,{width:a,children:this.state.imgSrc!==this.RESTORED_FROM_WIDGET_STRING&&f(we,{src:this.state.imgSrc,alt:"Snapshot",opacity:this.state.shutter||!this.state.minShutterEffectPassed?"50%":"100%",width:a,height:a*9/16})}),f(q,{onClick:this.removeCapture,progress:this.getProgress(),disabled:!!this.getProgress()||o,children:this.getProgress()?"Uploading...":R(Ue,{children:[f(O,{content:D,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):f(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 De=ne(Le);export{De as default};
|