streamlit-nightly 1.43.3.dev20250319__py3-none-any.whl → 1.43.3.dev20250320__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/static/index.html +1 -1
- streamlit/static/static/js/{FileDownload.esm.Dz4lqu2t.js → FileDownload.esm.DQm20hQF.js} +1 -1
- streamlit/static/static/js/{FileHelper.B_o0E5mY.js → FileHelper.O0Tw1vHm.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.B5ARMjis.js → FormClearHelper.B96mvJBl.js} +1 -1
- streamlit/static/static/js/{Hooks.gYcZ3nte.js → Hooks.DhfCkO7P.js} +1 -1
- streamlit/static/static/js/{InputInstructions.K_vAW_MG.js → InputInstructions.BUcruzQw.js} +1 -1
- streamlit/static/static/js/{ProgressBar.DOjGuUdH.js → ProgressBar.C5PvfYoT.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.C4HdMGrO.js → RenderInPortalIfExists.CsAqYz6S.js} +1 -1
- streamlit/static/static/js/{Toolbar.BZqFuVCo.js → Toolbar.DPKilS9Z.js} +1 -1
- streamlit/static/static/js/{base-input.DtNLPEYc.js → base-input.CyYBBCqT.js} +1 -1
- streamlit/static/static/js/{checkbox.De5lDKlG.js → checkbox.EwRwlfrN.js} +1 -1
- streamlit/static/static/js/{createSuper.DUfdjejQ.js → createSuper.CZLLU1gy.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.ByFOuSZw.js → data-grid-overlay-editor.B9qrlUd6.js} +1 -1
- streamlit/static/static/js/{downloader.Bndt7ayy.js → downloader.O1knmGpz.js} +1 -1
- streamlit/static/static/js/{es6.B9axslaM.js → es6.qhuPBmb4.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.C19fTVqS.js → iframeResizer.contentWindow.nwPvRFph.js} +1 -1
- streamlit/static/static/js/{index.DWQ-qPH7.js → index.7rsEhQWb.js} +1 -1
- streamlit/static/static/js/{index.CVbLNEv4.js → index.B0cliXfV.js} +1 -1
- streamlit/static/static/js/{index.CYG25qUi.js → index.B3Q5Y9yF.js} +1 -1
- streamlit/static/static/js/{index.BTbDncVq.js → index.BBpWQQgl.js} +1 -1
- streamlit/static/static/js/{index.BELm1MW6.js → index.BfZU6Baz.js} +1 -1
- streamlit/static/static/js/{index.BKhwcUMH.js → index.BoGQMxwQ.js} +6 -6
- streamlit/static/static/js/{index.DJzV_Hd9.js → index.BoiwdkHj.js} +1 -1
- streamlit/static/static/js/{index.Bu7fiR4T.js → index.BzrIY8ls.js} +1 -1
- streamlit/static/static/js/{index.DQ8O6p2Z.js → index.C5JMUfSW.js} +1 -1
- streamlit/static/static/js/{index.BBkaxxeO.js → index.CVjcxZTQ.js} +1 -1
- streamlit/static/static/js/{index.CBtAFng_.js → index.Ca52mv8y.js} +1 -1
- streamlit/static/static/js/{index.xvt4PCc-.js → index.Cez--pxr.js} +1 -1
- streamlit/static/static/js/{index.CGzFdF4L.js → index.CxprXN11.js} +1 -1
- streamlit/static/static/js/{index.B9N7bKyh.js → index.DCNJotj9.js} +1 -1
- streamlit/static/static/js/{index.BVKRKiWg.js → index.DEAvt50T.js} +1 -1
- streamlit/static/static/js/{index.BKE695Zg.js → index.DEkQ7-4x.js} +1 -1
- streamlit/static/static/js/{index.BpkIFU8i.js → index.DKCVmING.js} +1 -1
- streamlit/static/static/js/{index.BQkmoKYZ.js → index.DLUxbvxL.js} +1 -1
- streamlit/static/static/js/{index.Bk2R3MJ7.js → index.DLZWj5Wx.js} +1 -1
- streamlit/static/static/js/{index.BRjv0YAi.js → index.DVtEu8XG.js} +1 -1
- streamlit/static/static/js/{index.bco4avsR.js → index.DmMT9-rF.js} +1 -1
- streamlit/static/static/js/{index.DxsZ6SOh.js → index.Dp1D2WwI.js} +1 -1
- streamlit/static/static/js/{index.8fEQ0naY.js → index.DpDZXc5A.js} +1 -1
- streamlit/static/static/js/{index.cHVEPjHw.js → index.DrZbpcih.js} +1 -1
- streamlit/static/static/js/{index.Bbd47eDn.js → index.DrcgL_1W.js} +1 -1
- streamlit/static/static/js/{index.TXEfAqTZ.js → index.DsAgncrv.js} +1 -1
- streamlit/static/static/js/{index.KmpTf7BC.js → index.DsqZ46tn.js} +5 -5
- streamlit/static/static/js/{index.3vPW8lC3.js → index.DwhrLk1V.js} +1 -1
- streamlit/static/static/js/index.Q9qfT6Yw.js +1 -0
- streamlit/static/static/js/{index.C4zUVQy-.js → index.RIvbbwSs.js} +1 -1
- streamlit/static/static/js/{index.BrZWnIcP.js → index.Wmp1JsUa.js} +1 -1
- streamlit/static/static/js/{index.DCgNoHge.js → index.YXZoRre5.js} +1 -1
- streamlit/static/static/js/{index.BDWxQ6IH.js → index.jrTYlvfq.js} +1 -1
- streamlit/static/static/js/{index.K2n8XAB3.js → index.kxnglcal.js} +1 -1
- streamlit/static/static/js/{index.BOsCHoek.js → index.qDmk2AC0.js} +1 -1
- streamlit/static/static/js/{index.D8rVyQy1.js → index.t--hEgTQ.js} +2 -2
- streamlit/static/static/js/{index.BoIgF6Mf.js → index.t5u3HMw8.js} +1 -1
- streamlit/static/static/js/{index.TIHw6394.js → index.yt3O_h8P.js} +1 -1
- streamlit/static/static/js/{input.5dHsg5IP.js → input.DYN2hm8h.js} +1 -1
- streamlit/static/static/js/{memory.7AvKwFql.js → memory.DcwTlUfH.js} +1 -1
- streamlit/static/static/js/{mergeWith.Bz2fCjZ-.js → mergeWith.C6Lut-Ce.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.BzFQCoPo.js → number-overlay-editor.hbp0nFAA.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.BWYpSIhJ.js → possibleConstructorReturn.GmuwO8nJ.js} +1 -1
- streamlit/static/static/js/{sandbox.DDDzfccc.js → sandbox.Czx1NrMq.js} +1 -1
- streamlit/static/static/js/{textarea.UlZOYsGE.js → textarea.-FtGYA3f.js} +1 -1
- streamlit/static/static/js/{timepicker.C8uTDs22.js → timepicker.5NDJbOBG.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.CdG0Nv6r.js → toConsumableArray.CdqshcAD.js} +1 -1
- streamlit/static/static/js/{uniqueId.hWzaDSRc.js → uniqueId.BwgQc4e5.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.CtYBARrn.js → useBasicWidgetState.C-ydtpV8.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.Cpz9bdhf.js → useOnInputChange.o1RUPHsO.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.BcDfXDtz.js → withFullScreenWrapper.CPl_bcPk.js} +1 -1
- {streamlit_nightly-1.43.3.dev20250319.dist-info → streamlit_nightly-1.43.3.dev20250320.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.43.3.dev20250319.dist-info → streamlit_nightly-1.43.3.dev20250320.dist-info}/RECORD +73 -73
- {streamlit_nightly-1.43.3.dev20250319.dist-info → streamlit_nightly-1.43.3.dev20250320.dist-info}/WHEEL +1 -1
- streamlit/static/static/js/index.CKmyhCjm.js +0 -1
- {streamlit_nightly-1.43.3.dev20250319.data → streamlit_nightly-1.43.3.dev20250320.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.43.3.dev20250319.dist-info → streamlit_nightly-1.43.3.dev20250320.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.43.3.dev20250319.dist-info → streamlit_nightly-1.43.3.dev20250320.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
|
|
1
|
-
import{r as M,E as T,_ as O,n as I,J as K,C as P,j as h,bu as Y,ba as z,bp as Z,b5 as ee,bo as j,bB as $,d as te,g as re,aL as ie,z as ae,bC as ne,bD as oe,bE as se,R as le,l as de,aA as ce,M as x,bl as ue,bk as pe,br as fe,bF as he,bs as ge,bt as me,F as ve}from"./index.BKhwcUMH.js";import{a as V}from"./index.D8rVyQy1.js";import{F as Se}from"./FormClearHelper.B5ARMjis.js";import{U as L}from"./UploadFileInfo.C-jY39rj.js";import{P as ye,S as be}from"./ProgressBar.DOjGuUdH.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}}}})}):null]})}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:z.TOP_RIGHT,children:h(Z,{kind:ee.MINIMAL,onClick:t,children:h(j,{content:H,size:"twoXL",color:$.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,J={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(Q){e.video=Q},style:X},R)),f&&f(J))},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:$.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:z.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};
|
1
|
+
import{r as M,E as T,_ as O,n as I,J as K,C as P,j as h,bu as Y,ba as z,bp as Z,b5 as ee,bo as j,bB as $,d as te,g as re,aL as ie,z as ae,bC as ne,bD as oe,bE as se,R as le,l as de,aA as ce,M as x,bl as ue,bk as pe,br as fe,bF as he,bs as ge,bt as me,F as ve}from"./index.BoGQMxwQ.js";import{a as V}from"./index.t--hEgTQ.js";import{F as Se}from"./FormClearHelper.B96mvJBl.js";import{U as L}from"./UploadFileInfo.C-jY39rj.js";import{P as ye,S as be}from"./ProgressBar.C5PvfYoT.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}}}})}):null]})}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:z.TOP_RIGHT,children:h(Z,{kind:ee.MINIMAL,onClick:t,children:h(j,{content:H,size:"twoXL",color:$.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,J={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(Q){e.video=Q},style:X},R)),f&&f(J))},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:$.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:z.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};
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import{bv as _,bM as ve,bw as $,r as u,z as me,C as te,j as O,bz as ye,bs as $e,ba as Oe,bt as Re,aC as re,br as _e}from"./index.
|
1
|
+
import{bv as _,bM as ve,bw as $,r as u,z as me,C as te,j as O,bz as ye,bs as $e,ba as Oe,bt as Re,aC as re,br as _e}from"./index.BoGQMxwQ.js";import{a as Pe}from"./useBasicWidgetState.C-ydtpV8.js";import"./FormClearHelper.B96mvJBl.js";var ne={vertical:"vertical",horizontal:"horizontal"};function oe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function j(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?oe(Object(r),!0).forEach(function(n){R(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):oe(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function R(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var E=0,I=1,L=2;function x(e){return e.$isActive?L:e.$isHovered?I:E}function we(e){var t=e.$theme.colors,r=e.$disabled,n=e.$checked,o=e.$isFocusVisible,i=e.$error;if(r)return t.tickFillDisabled;if(n)if(i)switch(x(e)){case E:return t.tickFillErrorSelected;case I:return t.tickFillErrorSelectedHover;case L:return t.tickFillErrorSelectedHoverActive}else switch(x(e)){case E:return t.tickFillSelected;case I:return t.tickFillSelectedHover;case L:return t.tickFillSelectedHoverActive}else return o?t.borderSelected:i?t.tickBorderError:t.tickBorder;return null}function Se(e){var t=e.$theme.colors;if(e.$disabled)return t.tickMarkFillDisabled;if(e.$checked)return t.tickMarkFill;if(e.$error)switch(x(e)){case E:return t.tickFillError;case I:return t.tickFillErrorHover;case L:return t.tickFillErrorHoverActive}else switch(x(e)){case E:return t.tickFill;case I:return t.tickFillHover;case L:return t.tickFillActive}}function Me(e){var t=e.$labelPlacement,r=t===void 0?"":t,n=e.$theme,o;switch(r){case"top":o="Bottom";break;case"bottom":o="Top";break;case"left":o=n.direction==="rtl"?"Left":"Right";break;default:case"right":o=n.direction==="rtl"?"Right":"Left";break}var i=n.sizing,l=i.scale300;return R({},"padding".concat(o),l)}function ke(e){var t=e.$disabled,r=e.$theme,n=r.colors;return t?n.contentSecondary:n.contentPrimary}var G=_("div",function(e){var t=e.$disabled,r=e.$align;return{display:"flex",flexWrap:"wrap",flexDirection:r==="horizontal"?"row":"column",alignItems:r==="horizontal"?"center":"flex-start",cursor:t?"not-allowed":"pointer","-webkit-tap-highlight-color":"transparent"}});G.displayName="RadioGroupRoot";G.displayName="RadioGroupRoot";var W=_("label",function(e){var t,r=e.$disabled,n=e.$hasDescription,o=e.$labelPlacement,i=e.$theme,l=e.$align,s=i.sizing,c=l==="horizontal",f=i.direction==="rtl"?"Left":"Right";return t={flexDirection:o==="top"||o==="bottom"?"column":"row",display:"flex",alignItems:"center",cursor:r?"not-allowed":"pointer",marginTop:s.scale200},R(t,"margin".concat(f),c?s.scale200:null),R(t,"marginBottom",n&&!c?null:s.scale200),t});W.displayName="Root";W.displayName="Root";var q=_("div",function(e){var t=e.$theme,r=t.animation,n=t.sizing;return{backgroundColor:Se(e),borderTopLeftRadius:"50%",borderTopRightRadius:"50%",borderBottomRightRadius:"50%",borderBottomLeftRadius:"50%",height:e.$checked?n.scale200:n.scale550,transitionDuration:r.timing200,transitionTimingFunction:r.easeOutCurve,width:e.$checked?n.scale200:n.scale550}});q.displayName="RadioMarkInner";q.displayName="RadioMarkInner";var X=_("div",function(e){var t=e.$theme,r=t.animation,n=t.sizing;return{alignItems:"center",backgroundColor:we(e),borderTopLeftRadius:"50%",borderTopRightRadius:"50%",borderBottomRightRadius:"50%",borderBottomLeftRadius:"50%",boxShadow:e.$isFocusVisible&&e.$checked?"0 0 0 3px ".concat(e.$theme.colors.accent):"none",display:"flex",height:n.scale700,justifyContent:"center",marginTop:n.scale0,marginRight:n.scale0,marginBottom:n.scale0,marginLeft:n.scale0,outline:"none",verticalAlign:"middle",width:n.scale700,flexShrink:0,transitionDuration:r.timing200,transitionTimingFunction:r.easeOutCurve}});X.displayName="RadioMarkOuter";X.displayName="RadioMarkOuter";var K=_("div",function(e){var t=e.$theme.typography;return j(j({verticalAlign:"middle"},Me(e)),{},{color:ke(e)},t.LabelMedium)});K.displayName="Label";K.displayName="Label";var J=_("input",{width:0,height:0,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0,clip:"rect(0 0 0 0)",position:"absolute"});J.displayName="Input";J.displayName="Input";var Q=_("div",function(e){var t,r=e.$theme,n=e.$align,o=n==="horizontal",i=r.direction==="rtl"?"Right":"Left",l=r.direction==="rtl"?"Left":"Right";return j(j({},r.typography.ParagraphSmall),{},(t={color:r.colors.contentSecondary,cursor:"auto"},R(t,"margin".concat(i),n==="horizontal"?null:r.sizing.scale900),R(t,"margin".concat(l),o?r.sizing.scale200:null),R(t,"maxWidth","240px"),t))});Q.displayName="Description";Q.displayName="Description";function z(e){"@babel/helpers - typeof";return z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},z(e)}function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},H.apply(this,arguments)}function Fe(e,t){return Te(e)||Le(e,t)||Ie(e,t)||Ee()}function Ee(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ie(e,t){if(e){if(typeof e=="string")return ie(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ie(e,t)}}function ie(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Le(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],o=!0,i=!1,l,s;try{for(r=r.call(e);!(o=(l=r.next()).done)&&(n.push(l.value),!(t&&n.length===t));o=!0);}catch(c){i=!0,s=c}finally{try{!o&&r.return!=null&&r.return()}finally{if(i)throw s}}return n}}function Te(e){if(Array.isArray(e))return e}function Ae(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function je(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function xe(e,t,r){return t&&je(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function De(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&N(e,t)}function N(e,t){return N=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},N(e,t)}function Be(e){var t=ze();return function(){var n=D(e),o;if(t){var i=D(this).constructor;o=Reflect.construct(n,arguments,i)}else o=n.apply(this,arguments);return Ce(this,o)}}function Ce(e,t){if(t&&(z(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return T(e)}function T(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ze(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function D(e){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},D(e)}function A(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var se=function(e){De(r,e);var t=Be(r);function r(){var n;Ae(this,r);for(var o=arguments.length,i=new Array(o),l=0;l<o;l++)i[l]=arguments[l];return n=t.call.apply(t,[this].concat(i)),A(T(n),"state",{isFocusVisible:!1,focusedRadioIndex:-1}),A(T(n),"handleFocus",function(s,c){ve(s)&&n.setState({isFocusVisible:!0}),n.setState({focusedRadioIndex:c}),n.props.onFocus&&n.props.onFocus(s)}),A(T(n),"handleBlur",function(s,c){n.state.isFocusVisible!==!1&&n.setState({isFocusVisible:!1}),n.setState({focusedRadioIndex:-1}),n.props.onBlur&&n.props.onBlur(s)}),n}return xe(r,[{key:"render",value:function(){var o=this,i=this.props.overrides,l=i===void 0?{}:i,s=$(l.RadioGroupRoot,G),c=Fe(s,2),f=c[0],b=c[1];return u.createElement(f,H({id:this.props.id,role:"radiogroup","aria-describedby":this.props["aria-describedby"],"aria-errormessage":this.props["aria-errormessage"],"aria-invalid":this.props.error||null,"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],$align:this.props.align,$disabled:this.props.disabled,$error:this.props.error,$required:this.props.required},b),u.Children.map(this.props.children,function(p,a){if(!u.isValidElement(p))return null;var d=o.props.value===p.props.value;return u.cloneElement(p,{align:o.props.align,autoFocus:o.props.autoFocus,checked:d,disabled:o.props.disabled||p.props.disabled,error:o.props.error,isFocused:o.state.focusedRadioIndex===a,isFocusVisible:o.state.isFocusVisible,tabIndex:a===0&&!o.props.value||d?"0":"-1",labelPlacement:o.props.labelPlacement,name:o.props.name,onBlur:function(g){return o.handleBlur(g,a)},onFocus:function(g){return o.handleFocus(g,a)},onChange:o.props.onChange,onMouseEnter:o.props.onMouseEnter,onMouseLeave:o.props.onMouseLeave})}))}}]),r}(u.Component);A(se,"defaultProps",{name:"",value:"",disabled:!1,autoFocus:!1,labelPlacement:"right",align:"vertical",error:!1,required:!1,onChange:function(){},onMouseEnter:function(){},onMouseLeave:function(){},onFocus:function(){},onBlur:function(){},overrides:{}});function V(e){"@babel/helpers - typeof";return V=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},V(e)}function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},y.apply(this,arguments)}function M(e,t){return Ue(e)||Ve(e,t)||Ne(e,t)||He()}function He(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
3
3
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ne(e,t){if(e){if(typeof e=="string")return ae(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ae(e,t)}}function ae(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Ve(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],o=!0,i=!1,l,s;try{for(r=r.call(e);!(o=(l=r.next()).done)&&(n.push(l.value),!(t&&n.length===t));o=!0);}catch(c){i=!0,s=c}finally{try{!o&&r.return!=null&&r.return()}finally{if(i)throw s}}return n}}function Ue(e){if(Array.isArray(e))return e}function Ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function We(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function qe(e,t,r){return t&&We(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Xe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&U(e,t)}function U(e,t){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},U(e,t)}function Ke(e){var t=Qe();return function(){var n=B(e),o;if(t){var i=B(this).constructor;o=Reflect.construct(n,arguments,i)}else o=n.apply(this,arguments);return Je(this,o)}}function Je(e,t){if(t&&(V(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return k(e)}function k(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Qe(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function B(e){return B=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},B(e)}function F(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ye(e){return e==="top"||e==="left"}function Ze(e){return e==="bottom"||e==="right"}var et=function(t){return t.stopPropagation()},le=function(e){Xe(r,e);var t=Ke(r);function r(){var n;Ge(this,r);for(var o=arguments.length,i=new Array(o),l=0;l<o;l++)i[l]=arguments[l];return n=t.call.apply(t,[this].concat(i)),F(k(n),"state",{isActive:!1,isHovered:!1}),F(k(n),"onMouseEnter",function(s){n.setState({isHovered:!0}),n.props.onMouseEnter&&n.props.onMouseEnter(s)}),F(k(n),"onMouseLeave",function(s){n.setState({isHovered:!1}),n.props.onMouseLeave&&n.props.onMouseLeave(s)}),F(k(n),"onMouseDown",function(s){n.setState({isActive:!0}),n.props.onMouseDown&&n.props.onMouseDown(s)}),F(k(n),"onMouseUp",function(s){n.setState({isActive:!1}),n.props.onMouseUp&&n.props.onMouseUp(s)}),n}return qe(r,[{key:"componentDidMount",value:function(){var o;this.props.autoFocus&&(o=this.props.inputRef)!==null&&o!==void 0&&o.current&&this.props.inputRef.current.focus()}},{key:"render",value:function(){var o=this.props.overrides,i=o===void 0?{}:o,l=$(i.Root,W),s=M(l,2),c=s[0],f=s[1],b=$(i.Label,K),p=M(b,2),a=p[0],d=p[1],P=$(i.Input,J),g=M(P,2),w=g[0],C=g[1],v=$(i.Description,Q),h=M(v,2),m=h[0],ue=h[1],ce=$(i.RadioMarkInner,q),Y=M(ce,2),pe=Y[0],fe=Y[1],de=$(i.RadioMarkOuter,X),Z=M(de,2),he=Z[0],be=Z[1],S={$align:this.props.align,$checked:this.props.checked,$disabled:this.props.disabled,$hasDescription:!!this.props.description,$isActive:this.state.isActive,$error:this.props.error,$isFocused:this.props.isFocused,$isFocusVisible:this.props.isFocused&&this.props.isFocusVisible,$isHovered:this.state.isHovered,$labelPlacement:this.props.labelPlacement,$required:this.props.required,$value:this.props.value},ee=u.createElement(a,y({},S,d),this.props.containsInteractiveElement?u.createElement("div",{onClick:function(ge){return ge.preventDefault()}},this.props.children):this.props.children);return u.createElement(u.Fragment,null,u.createElement(c,y({"data-baseweb":"radio",onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp},S,f),Ye(this.props.labelPlacement)&&ee,u.createElement(he,y({},S,be),u.createElement(pe,y({},S,fe))),u.createElement(w,y({"aria-invalid":this.props.error||null,checked:this.props.checked,disabled:this.props.disabled,name:this.props.name,onBlur:this.props.onBlur,onFocus:this.props.onFocus,onClick:et,onChange:this.props.onChange,ref:this.props.inputRef,required:this.props.required,tabIndex:this.props.tabIndex,type:"radio",value:this.props.value},S,C)),Ze(this.props.labelPlacement)&&ee),!!this.props.description&&u.createElement(m,y({},S,ue),this.props.description))}}]),r}(u.Component);F(le,"defaultProps",{overrides:{},containsInteractiveElement:!1,checked:!1,disabled:!1,autoFocus:!1,inputRef:u.createRef(),align:"vertical",error:!1,onChange:function(){},onMouseEnter:function(){},onMouseLeave:function(){},onMouseDown:function(){},onMouseUp:function(){},onFocus:function(){},onBlur:function(){}});function tt({disabled:e,horizontal:t,value:r,onChange:n,options:o,captions:i,label:l,labelVisibility:s,help:c}){const[f,b]=u.useState(r??null);u.useEffect(()=>{r!==f&&b(r??null)},[r]);const p=u.useCallback(v=>{const h=parseInt(v.target.value,10);b(h),n(h)},[n]),a=me(),d=i.length>0,P=o.length>0,g=P?o:["No options to select."],w=e||!P,C=v=>v==""&&t&&d?" ":v;return te("div",{className:"stRadio","data-testid":"stRadio",children:[O(Re,{label:l,disabled:w,labelVisibility:s,children:c&&O(ye,{children:O($e,{content:c,placement:Oe.TOP_RIGHT})})}),O(se,{onChange:p,value:f!==null?f.toString():void 0,disabled:w,align:t?ne.horizontal:ne.vertical,"aria-label":l,"data-testid":"stRadioGroup",overrides:{RadioGroupRoot:{style:{gap:d?a.spacing.sm:a.spacing.none,minHeight:a.sizes.minElementHeight}}},children:g.map((v,h)=>te(le,{value:h.toString(),overrides:{Root:{style:({$isFocusVisible:m})=>({marginBottom:a.spacing.none,marginTop:a.spacing.none,marginRight:d?a.spacing.sm:a.spacing.lg,paddingLeft:a.spacing.none,alignItems:"start",paddingRight:a.spacing.threeXS,backgroundColor:m?a.colors.darkenedBgMix25:""})},RadioMarkOuter:{style:({$checked:m})=>({width:a.sizes.checkbox,height:a.sizes.checkbox,marginTop:"0.35rem",marginRight:a.spacing.none,marginLeft:a.spacing.none,backgroundColor:m&&!w?a.colors.primary:a.colors.fadedText40})},RadioMarkInner:{style:({$checked:m})=>({height:m?"37.5%":`calc(${a.sizes.checkbox} - ${a.spacing.threeXS})`,width:m?"37.5%":`calc(${a.sizes.checkbox} - ${a.spacing.threeXS})`})},Label:{style:{color:w?a.colors.fadedText40:a.colors.bodyText,position:"relative",top:a.spacing.px}}},children:[O(re,{source:v,allowHTML:!1,isLabel:!0,largerLabel:!0}),d&&O(re,{source:C(i[h]),allowHTML:!1,isCaption:!0,isLabel:!0})]},h))})]})}const rt=u.memo(tt);function nt({disabled:e,element:t,widgetMgr:r,fragmentId:n}){const[o,i]=Pe({getStateFromWidgetMgr:ot,getDefaultStateFromProto:it,getCurrStateFromProto:at,updateWidgetMgrState:st,element:t,widgetMgr:r,fragmentId:n}),l=u.useCallback(d=>{i({value:d,fromUi:!0})},[i]),{horizontal:s,options:c,captions:f,label:b,labelVisibility:p,help:a}=t;return O(rt,{label:b,onChange:l,options:c,captions:f,disabled:e,horizontal:s,labelVisibility:_e(p==null?void 0:p.value),value:o??null,help:a})}function ot(e,t){return e.getIntValue(t)}function it(e){return e.default??null}function at(e){return e.value??null}function st(e,t,r,n){t.setIntValue(e,r.value??null,{fromUi:r.fromUi},n)}const ft=u.memo(nt);export{ft as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{n as U,r as a,bi as R,j as m,l as w}from"./index.
|
1
|
+
import{n as U,r as a,bi as R,j as m,l as w}from"./index.BoGQMxwQ.js";const A=U("iframe",{target:"eymnmwl0"})(({theme:r})=>({colorScheme:"normal",border:"none",padding:r.spacing.none,margin:r.spacing.none,width:"100%",aspectRatio:"16 / 9"})),O=w.getLogger("Video"),P={width:"100%"};function $({element:r,endpoints:i,elementMgr:p}){const s=a.useRef(null),{type:v,url:f,startTime:n,subtitles:u,endTime:c,loop:l,autoplay:S,muted:g}=r,T=a.useMemo(()=>{if(!r.id)return!0;const e=p.getElementState(r.id,"preventAutoplay");return e||p.setElementState(r.id,"preventAutoplay",!0),e??!1},[r.id,p]),E=a.useMemo(()=>JSON.stringify(u?u.map(e=>i.buildMediaURL(`${e.url}`)):[]),[u,i]);a.useEffect(()=>{const e=JSON.parse(E);e.length!==0&&e.forEach(t=>{i.checkSourceUrlResponse(t,"Video Subtitle")})},[E,i]),a.useEffect(()=>{s.current&&(s.current.currentTime=n)},[n]),a.useEffect(()=>{const e=s.current,t=()=>{e&&(e.currentTime=r.startTime)};return e&&e.addEventListener("loadedmetadata",t),()=>{e&&e.removeEventListener("loadedmetadata",t)}},[r]),a.useEffect(()=>{const e=s.current;if(!e)return;let t=!1;const d=()=>{c>0&&e.currentTime>=c&&(l?(e.currentTime=n||0,e.play()):t||(t=!0,e.pause()))};return c>0&&e.addEventListener("timeupdate",d),()=>{e&&c>0&&e.removeEventListener("timeupdate",d)}},[c,l,n]),a.useEffect(()=>{const e=s.current;if(!e)return;const t=()=>{l&&(e.currentTime=n||0,e.play())};return e.addEventListener("ended",t),()=>{e&&e.removeEventListener("ended",t)}},[l,n]);const V=e=>{const{startTime:t,endTime:d,loop:b,autoplay:L,muted:N}=r,o=new URL(e);if(t&&!isNaN(t)&&o.searchParams.append("start",t.toString()),d&&!isNaN(d)&&o.searchParams.append("end",d.toString()),b){o.searchParams.append("loop","1");const y=o.pathname.split("/").pop();y&&o.searchParams.append("playlist",y)}return L&&o.searchParams.append("autoplay","1"),N&&o.searchParams.append("mute","1"),o.toString()};if(v===R.Type.YOUTUBE_IFRAME)return m(A,{className:"stVideo","data-testid":"stVideo",title:f,src:V(f),allow:"autoplay; encrypted-media",allowFullScreen:!0});const h=e=>{const t=e.currentTarget.src;O.error(`Client Error: Video source error - ${t}`),i.sendClientErrorToHost("Video","Video source failed to load","onerror triggered",t)};return m("video",{className:"stVideo","data-testid":"stVideo",ref:s,controls:!0,muted:g,autoPlay:S&&!T,src:i.buildMediaURL(f),style:P,crossOrigin:void 0,onError:h,children:u&&u.map((e,t)=>m("track",{kind:"captions",src:i.buildMediaURL(`${e.url}`),label:`${e.label}`,default:t===0,"data-testid":"stVideoSubtitle"},t))})}const M=a.memo($);export{M as default};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{n as s,k as i,r as m,j as e}from"./index.
|
1
|
+
import{n as s,k as i,r as m,j as e}from"./index.BoGQMxwQ.js";import{P as c,R as l}from"./RenderInPortalIfExists.CsAqYz6S.js";const p=""+new URL("../media/flake-0.DgWaVvm5.png",import.meta.url).href,d=""+new URL("../media/flake-1.B2r5AHMK.png",import.meta.url).href,f=""+new URL("../media/flake-2.BnWSExPC.png",import.meta.url).href,o=150,S=150,g=10,E=90,u=4e3,n=(t,a=0)=>Math.random()*(t-a)+a,w=()=>i(`from{transform:translateY(0)
|
2
2
|
rotateX(`,n(360),`deg)
|
3
3
|
rotateY(`,n(360),`deg)
|
4
4
|
rotateZ(`,n(360),"deg);}to{transform:translateY(calc(100vh + ",o,`px))
|
@@ -1 +1 @@
|
|
1
|
-
import{r as s,bh as U,z as k,cr as W,C as A,j as l,br as L,bF as P,bs as B,ba as D,bt as j}from"./index.
|
1
|
+
import{r as s,bh as U,z as k,cr as W,C as A,j as l,br as L,bF as P,bs as B,ba as D,bt as j}from"./index.BoGQMxwQ.js";import{u as _}from"./uniqueId.BwgQc4e5.js";import{u as w,a as K,b as O}from"./useOnInputChange.o1RUPHsO.js";import{I as $}from"./InputInstructions.BUcruzQw.js";import{a as q}from"./useBasicWidgetState.C-ydtpV8.js";import{T as G}from"./textarea.-FtGYA3f.js";import"./inputUtils.CQWz5UKz.js";import"./FormClearHelper.B96mvJBl.js";import"./base-input.CyYBBCqT.js";const x=(a,t)=>a.getStringValue(t)??t.default??null,N=a=>a.default??null,J=a=>a.value??null,Q=(a,t,o,u)=>{t.setStringValue(a,o.value,{fromUi:o.fromUi},u)},X=({disabled:a,element:t,widgetMgr:o,fragmentId:u})=>{var f;const p=s.useRef(_("text_area_")).current,[T,S]=U(),[r,n]=s.useState(!1),[C,b]=s.useState(!1),[i,d]=s.useState(()=>x(o,t)??null),I=s.useCallback(()=>{d(t.default??null),n(!0)},[t]),[y,c]=q({getStateFromWidgetMgr:x,getDefaultStateFromProto:N,getCurrStateFromProto:J,updateWidgetMgrState:Q,element:t,widgetMgr:o,fragmentId:u,onFormCleared:I});w(y,i,d,r);const e=k(),h=s.useCallback(()=>{n(!1),c({value:i,fromUi:!0})},[i,c]),F=s.useCallback(()=>{r&&h(),b(!1)},[r,h]),V=s.useCallback(()=>{b(!0)},[]),v=K({formId:t.formId,maxChars:t.maxChars,setDirty:n,setUiValue:d,setValueWithSource:c}),z=O(t.formId,h,r,o,u,!0),{height:g,placeholder:E,formId:m}=t,R=W({formId:m})?o.allowFormEnterToSubmit(m):r,H=C&&T>e.breakpoints.hideWidgetDetails;return A("div",{className:"stTextArea","data-testid":"stTextArea",ref:S,children:[l(j,{label:t.label,disabled:a,labelVisibility:L((f=t.labelVisibility)==null?void 0:f.value),htmlFor:p,children:t.help&&l(P,{children:l(B,{content:t.help,placement:D.TOP_RIGHT})})}),l(G,{value:i??"",placeholder:E,onBlur:F,onFocus:V,onChange:v,onKeyDown:z,"aria-label":t.label,disabled:a,id:p,overrides:{Input:{style:{lineHeight:e.lineHeights.inputWidget,height:g?`${g}px`:"",minHeight:e.sizes.largestElementHeight,resize:"vertical","::placeholder":{opacity:"0.7"},paddingRight:e.spacing.lg,paddingLeft:e.spacing.lg,paddingBottom:e.spacing.lg,paddingTop:e.spacing.lg}},Root:{props:{"data-testid":"stTextAreaRootElement"},style:{borderLeftWidth:e.sizes.borderWidth,borderRightWidth:e.sizes.borderWidth,borderTopWidth:e.sizes.borderWidth,borderBottomWidth:e.sizes.borderWidth}}}}),H&&l($,{dirty:r,value:i??"",maxLength:t.maxChars,type:"multiline",inForm:W({formId:m}),allowEnterToSubmit:R})]})},it=s.memo(X);export{it as default};
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{bv as q,bw as J,r as f,bx as Q,z as Y,by as s,j as S,C as ee,br as te,bz as re,bs as ne,ba as oe,bA as ie,bt as ae,bp as ue,b5 as C,b4 as W,b7 as le}from"./index.
|
1
|
+
import{bv as q,bw as J,r as f,bx as Q,z as Y,by as s,j as S,C as ee,br as te,bz as re,bs as ne,ba as oe,bA as ie,bt as ae,bp as ue,b5 as C,b4 as W,b7 as le}from"./index.BoGQMxwQ.js";import{a as ce}from"./useBasicWidgetState.C-ydtpV8.js";import"./FormClearHelper.B96mvJBl.js";var se={secondary:"secondary"},G={default:"default"},fe={default:"default"},k=Object.freeze({radio:"radio",checkbox:"checkbox"}),z=q("div",function(e){var t=e.$shape,r=e.$length,n=e.$theme,o=r===1?void 0:t!==G.default?"-".concat(n.sizing.scale100):"-0.5px";return{display:"flex",marginLeft:o,marginRight:o}});z.displayName="StyledRoot";z.displayName="StyledRoot";function j(e){"@babel/helpers - typeof";return j=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},j(e)}function M(){return M=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},M.apply(this,arguments)}function x(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function pe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?x(Object(r),!0).forEach(function(n){N(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function de(e,t){return me(e)||he(e,t)||be(e,t)||ye()}function ye(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function be(e,t){if(e){if(typeof e=="string")return X(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return X(e,t)}}function X(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function he(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],o=!0,i=!1,a,p;try{for(r=r.call(e);!(o=(a=r.next()).done)&&(n.push(a.value),!(t&&n.length===t));o=!0);}catch(c){i=!0,p=c}finally{try{!o&&r.return!=null&&r.return()}finally{if(i)throw p}}return n}}function me(e){if(Array.isArray(e))return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ve(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Se(e,t,r){return t&&ve(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Oe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&$(e,t)}function $(e,t){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},$(e,t)}function Ee(e){var t=we();return function(){var n=A(e),o;if(t){var i=A(this).constructor;o=Reflect.construct(n,arguments,i)}else o=n.apply(this,arguments);return _e(this,o)}}function _e(e,t){if(t&&(j(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return K(e)}function K(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function we(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function A(e){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},A(e)}function N(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Le(e,t){return!Array.isArray(e)&&typeof e!="number"?!1:Array.isArray(e)?e.includes(t):e===t}var F=function(e){Oe(r,e);var t=Ee(r);function r(){var n;ge(this,r);for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return n=t.call.apply(t,[this].concat(i)),N(K(n),"childRefs",{}),n}return Se(r,[{key:"render",value:function(){var o=this,i=this.props,a=i.overrides,p=a===void 0?{}:a,c=i.mode,P=c===void 0?k.checkbox:c,d=i.children,y=i.selected,h=i.disabled,l=i.onClick,_=i.kind,m=i.shape,w=i.size,I=J(p.Root,z),O=de(I,2),E=O[0],L=O[1],H=this.props["aria-label"]||this.props.ariaLabel,g=P===k.radio,V=f.Children.count(d);return f.createElement(Q.Consumer,null,function(Z){return f.createElement(E,M({"aria-label":H||Z.buttongroup.ariaLabel,"data-baseweb":"button-group",role:g?"radiogroup":"group",$shape:m,$length:d.length},L),f.Children.map(d,function(b,R){if(!f.isValidElement(b))return null;var T=b.props.isSelected?b.props.isSelected:Le(y,R);return g&&(o.childRefs[R]=f.createRef()),f.cloneElement(b,{disabled:h||b.props.disabled,isSelected:T,ref:g?o.childRefs[R]:void 0,tabIndex:!g||T||g&&(!y||y===-1)&&R===0?0:-1,onKeyDown:function(u){if(g){var v=Number(y)?Number(y):0;if(u.key==="ArrowUp"||u.key==="ArrowLeft"){u.preventDefault&&u.preventDefault();var B=v-1<0?V-1:v-1;l&&l(u,B),o.childRefs[B].current&&o.childRefs[B].current.focus()}if(u.key==="ArrowDown"||u.key==="ArrowRight"){u.preventDefault&&u.preventDefault();var D=v+1>V-1?0:v+1;l&&l(u,D),o.childRefs[D].current&&o.childRefs[D].current.focus()}}},kind:_,onClick:function(u){h||(b.props.onClick&&b.props.onClick(u),l&&l(u,R))},shape:m,size:w,overrides:pe({BaseButton:{style:function(u){var v=u.$theme;return d.length===1?{}:m!==G.default?{marginLeft:v.sizing.scale100,marginRight:v.sizing.scale100}:{marginLeft:"0.5px",marginRight:"0.5px"}},props:{"aria-checked":T,role:g?"radio":"checkbox"}}},b.props.overrides)})}))})}}]),r}(f.Component);N(F,"defaultProps",{disabled:!1,onClick:function(){},shape:G.default,size:fe.default,kind:se.secondary});function Re(e,t){return t.includes(e)?t.filter(r=>r!==e):[...t,e]}function Ce(e,t,r){return e==s.ClickMode.MULTI_SELECT?Re(t,r??[]):r!=null&&r.includes(t)?[]:[t]}function Pe(e){return e.length===0?-1:e[0]}function ke(e,t,r,n){t.setIntArrayValue(e,r.value,{fromUi:r.fromUi},n)}function Ae(e,t,r){const n=r===s.Style.PILLS?C.PILLS:r===s.Style.BORDERLESS?C.BORDERLESS_ICON:C.SEGMENTED_CONTROL,o=r===s.Style.BORDERLESS?W.XSMALL:W.MEDIUM,i=n===C.PILLS||n===C.SEGMENTED_CONTROL,a=r===s.Style.BORDERLESS?"lg":"base";return{element:S(le,{icon:t,label:e,iconSize:a,useSmallerFont:i}),kind:n,size:o}}function Ie(e,t,r,n){return r.indexOf(n)>-1?!0:t!==s.ClickMode.SINGLE_SELECT||e!==s.SelectionVisualization.ALL_UP_TO_SELECTED?!1:r.length>0&&n<r[0]}function Te(e,t){return e&&(t=`${t}Active`),t}function Be(e,t){const r={flexWrap:"wrap",maxWidth:"fit-content"};switch(e){case s.Style.BORDERLESS:return{...r,columnGap:t.threeXS,rowGap:t.threeXS};case s.Style.PILLS:return{...r,columnGap:t.twoXS,rowGap:t.twoXS};case s.Style.SEGMENTED_CONTROL:return{...r,columnGap:t.none,rowGap:t.twoXS,"::after":{content:"''",flex:1e4}};default:return r}}function De(e,t,r,n,o,i){const a=Ie(r,n,o,t);let p=e.content,c=e.contentIcon;return a&&(p=e.selectedContent?e.selectedContent:p,c=e.selectedContentIcon?e.selectedContentIcon:c),f.forwardRef(function(d,y){const{element:h,kind:l,size:_}=Ae(p??"",c??void 0,i),m=Te(!!(a&&!e.selectedContent&&!e.selectedContentIcon),l);return S(ue,{...d,size:_,kind:m,children:h})})}function je(e,t){return e.getIntArrayValue(t)}function Me(e){return e.default??null}function $e(e){return e.value??null}function Ge(e){const{disabled:t,element:r,fragmentId:n,widgetMgr:o}=e,{clickMode:i,options:a,selectionVisualization:p,style:c,label:P,labelVisibility:d,help:y}=r,h=Y(),[l,_]=ce({getStateFromWidgetMgr:je,getDefaultStateFromProto:Me,getCurrStateFromProto:$e,updateWidgetMgrState:ke,element:r,widgetMgr:o,fragmentId:n}),m=(O,E)=>{const L=Ce(i,E,l);_({value:L,fromUi:!0})};let w;i===s.ClickMode.SINGLE_SELECT?w=k.radio:i===s.ClickMode.MULTI_SELECT&&(w=k.checkbox);const I=f.useMemo(()=>a.map((O,E)=>{const L=De(O,E,p,i,l,c);return S(L,{},`${O.content}-${E}`)}),[i,a,p,c,l]);return ee("div",{className:"stButtonGroup","data-testid":"stButtonGroup",children:[S(ae,{label:P,disabled:t,labelVisibility:te((d==null?void 0:d.value)??ie.LabelVisibilityOptions.COLLAPSED),children:y&&S(re,{children:S(ne,{content:y,placement:oe.TOP})})}),S(F,{disabled:t,mode:w,onClick:m,selected:i===s.ClickMode.MULTI_SELECT?l:Pe(l),overrides:{Root:{style:f.useCallback(()=>Be(c,h.spacing),[c,h.spacing])}},children:I})]})}const Ue=f.memo(Ge);export{Ue as default};
|