streamlit 1.53.0__py3-none-any.whl → 1.53.1__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/connections/snowflake_connection.py +1 -0
- streamlit/elements/lib/options_selector_utils.py +63 -19
- streamlit/elements/widgets/multiselect.py +31 -7
- streamlit/elements/widgets/selectbox.py +38 -16
- streamlit/static/index.html +1 -1
- streamlit/static/manifest.json +291 -291
- streamlit/static/static/js/{ErrorOutline.esm.Cxoit62D.js → ErrorOutline.esm.CScZvf44.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.Cym2KVOR.js → FileDownload.esm.COCxTZxP.js} +1 -1
- streamlit/static/static/js/{FileHelper.C47VLeXF.js → FileHelper.Bhs-iVRI.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.CUrwwEeX.js → FormClearHelper.CA_5b-Ut.js} +1 -1
- streamlit/static/static/js/{InputInstructions.DyVOE42q.js → InputInstructions.Bzb0MCfv.js} +1 -1
- streamlit/static/static/js/{Particles.D5ZUTvE6.js → Particles.ix5_l22I.js} +1 -1
- streamlit/static/static/js/{ProgressBar.qKdiDYyx.js → ProgressBar.DyQNhVsJ.js} +1 -1
- streamlit/static/static/js/{StreamlitSyntaxHighlighter.DUPp9dS3.js → StreamlitSyntaxHighlighter.BOkJThtV.js} +1 -1
- streamlit/static/static/js/{TableChart.esm.C_g2CvCE.js → TableChart.esm.a60nntBC.js} +1 -1
- streamlit/static/static/js/{Toolbar.BbO8bxwz.js → Toolbar.CxkcuBQ8.js} +1 -1
- streamlit/static/static/js/{WidgetLabelHelpIconInline.Dy4yV6I2.js → WidgetLabelHelpIconInline.BjIku2ic.js} +1 -1
- streamlit/static/static/js/{base-input.DQAb60v0.js → base-input.avGkArOc.js} +1 -1
- streamlit/static/static/js/{checkbox.C0HE0ojW.js → checkbox.Q8mCuqps.js} +1 -1
- streamlit/static/static/js/{createDownloadLinkElement.DBMfH8_e.js → createDownloadLinkElement.CfqHRpxo.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.CSZWem5Q.js → data-grid-overlay-editor.PuoMl3yV.js} +1 -1
- streamlit/static/static/js/{downloader.Bp8c7mYD.js → downloader.CjG2csSm.js} +1 -1
- streamlit/static/static/js/{embed.DQBlGL9Q.js → embed.DZ-CLCPz.js} +1 -1
- streamlit/static/static/js/{es6.j7akTCaI.js → es6.CQD6uUK7.js} +2 -2
- streamlit/static/static/js/{formatNumber.CfuUiEpF.js → formatNumber.CtjUO-if.js} +1 -1
- streamlit/static/static/js/{iconPosition.BVSTKfGd.js → iconPosition.7Qt6oUiI.js} +1 -1
- streamlit/static/static/js/{iframeResizer.contentWindow.BZ3lugzo.js → iframeResizer.contentWindow._oj2Xh0v.js} +1 -1
- streamlit/static/static/js/{index.Dk0CU4R6.js → index.B-XrnnK6.js} +1 -1
- streamlit/static/static/js/{index.DBIRzFM7.js → index.B2fAYU1N.js} +1 -1
- streamlit/static/static/js/{index.BMFt07G_.js → index.B5wmZkRW.js} +1 -1
- streamlit/static/static/js/{index.5CsPRetw.js → index.B6ZAXv47.js} +1 -1
- streamlit/static/static/js/{index.dgs1TGpP.js → index.B8PovXCX.js} +1 -1
- streamlit/static/static/js/{index.CZzy-Gct.js → index.BDm-Ia27.js} +1 -1
- streamlit/static/static/js/{index.CTQ8QcOV.js → index.BOTEMJfV.js} +1 -1
- streamlit/static/static/js/{index.1PD6f3vh.js → index.BOafPwIE.js} +1 -1
- streamlit/static/static/js/{index.BiVJWMS-.js → index.BRegnbUa.js} +1 -1
- streamlit/static/static/js/{index.DysJZEAt.js → index.BVX_bqnf.js} +1 -1
- streamlit/static/static/js/{index.BXfSsjdq.js → index.BWCFtBS4.js} +1 -1
- streamlit/static/static/js/{index.DtZTtufl.js → index.B_ylV_tl.js} +1 -1
- streamlit/static/static/js/{index.By8GIgDH.js → index.BeCZLkzg.js} +1 -1
- streamlit/static/static/js/{index.DgJeIFb5.js → index.Bg-9YNUa.js} +1 -1
- streamlit/static/static/js/{index.DSaE74nc.js → index.BhJwyXH6.js} +1 -1
- streamlit/static/static/js/{index.nEa8y_He.js → index.BksGMsW0.js} +1 -1
- streamlit/static/static/js/{index.C9QftD-S.js → index.BlJhnb4M.js} +1 -1
- streamlit/static/static/js/{index.Bukztsaz.js → index.BmDXWfgx.js} +1 -1
- streamlit/static/static/js/{index.Z0mB4zBp.js → index.BrRuSP42.js} +1 -1
- streamlit/static/static/js/{index.D0tXFTaW.js → index.BuBkymZd.js} +1 -1
- streamlit/static/static/js/{index.CeFdbzfR.js → index.BuEBeckn.js} +1 -1
- streamlit/static/static/js/{index.NtSfVVJe.js → index.CBqST2Yj.js} +1 -1
- streamlit/static/static/js/{index.FfR9SXQv.js → index.CIizdLeb.js} +1 -1
- streamlit/static/static/js/{index.CkmNfvPD.js → index.CL2eCR01.js} +1 -1
- streamlit/static/static/js/{index.Cow0Hs9V.js → index.CMBgAPh6.js} +1 -1
- streamlit/static/static/js/{index.iboGgrkh.js → index.CVRgrLT-.js} +1 -1
- streamlit/static/static/js/{index.BGzJYcHz.js → index.CdLlbsiN.js} +1 -1
- streamlit/static/static/js/{index.CAMxgVFm.js → index.Cptu1tS-.js} +1 -1
- streamlit/static/static/js/index.CsoN0h7K.js +188 -0
- streamlit/static/static/js/{index.Bk5wGJXh.js → index.CwIIk90V.js} +1 -1
- streamlit/static/static/js/{index.DpU0Bc2F.js → index.D1bkwsLT.js} +1 -1
- streamlit/static/static/js/{index.BDA5l7b9.js → index.D8t7R4QQ.js} +1 -1
- streamlit/static/static/js/{index.svncz-Ad.js → index.DDk0U8rh.js} +1 -1
- streamlit/static/static/js/{index.DYkkO_of.js → index.DJsqD2Sc.js} +1 -1
- streamlit/static/static/js/{index.CsmTnJl4.js → index.DNB79dOd.js} +1 -1
- streamlit/static/static/js/{index.C8VoW8Ph.js → index.DNj5S4tY.js} +1 -1
- streamlit/static/static/js/{index.DZGCJu4I.js → index.DOY0ZriT.js} +1 -1
- streamlit/static/static/js/{index.DFT9nVK6.js → index.DSTThs-t.js} +5 -5
- streamlit/static/static/js/{index.CWAvu1Qu.js → index.DVtfSohT.js} +1 -1
- streamlit/static/static/js/{index.C0F0G-wg.js → index.DXQ_Fvpt.js} +1 -1
- streamlit/static/static/js/{index.BgCYNmov.js → index.DZE_91Ym.js} +1 -1
- streamlit/static/static/js/{index.95DldRtG.js → index.DxQuXlXH.js} +1 -1
- streamlit/static/static/js/{index.7S_sCSRx.js → index.Egabyb7u.js} +1 -1
- streamlit/static/static/js/{index.BU3d_gp1.js → index.Ft2Zxbhr.js} +1 -1
- streamlit/static/static/js/{index.gPUFpUqs.js → index.KuLql7H0.js} +1 -1
- streamlit/static/static/js/{index.B2fTHpId.js → index.XGft6-dq.js} +1 -1
- streamlit/static/static/js/{index.Tq2okoAU.js → index.euRMkmNi.js} +1 -1
- streamlit/static/static/js/{index.BNpEDrb2.js → index.r0gCrMFP.js} +1 -1
- streamlit/static/static/js/{input.Pz8Lwzsi.js → input.Cf97CQME.js} +1 -1
- streamlit/static/static/js/{main.BeiYkHRo.js → main.Ccuk53yQ.js} +1 -1
- streamlit/static/static/js/{memory.Dyx_JBbb.js → memory.Bng6Ij0g.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.NLIdF6b9.js → number-overlay-editor.CFLv-CWC.js} +1 -1
- streamlit/static/static/js/{pandasStylerUtils.DsNlDEqS.js → pandasStylerUtils.C2hcAKiv.js} +1 -1
- streamlit/static/static/js/{sandbox.bER7qtR1.js → sandbox.BXdeD-wA.js} +1 -1
- streamlit/static/static/js/{styled-components.DcoFBb7G.js → styled-components.Br04Ogac.js} +1 -1
- streamlit/static/static/js/{throttle.DOaQWO4U.js → throttle.mI9ItGre.js} +1 -1
- streamlit/static/static/js/{timepicker.RjHB2IT4.js → timepicker.poFdB0sd.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.DFAIugL0.js → toConsumableArray.92-fANS-.js} +1 -1
- streamlit/static/static/js/uniqueId.BUj-C6GA.js +1 -0
- streamlit/static/static/js/{useBasicWidgetState.CTtyymrp.js → useBasicWidgetState.DzKGLAv_.js} +1 -1
- streamlit/static/static/js/{useIntlLocale.DG5haQGX.js → useIntlLocale.BMma2iiY.js} +1 -1
- streamlit/static/static/js/{useTextInputAutoExpand.Cnfcep1Z.js → useTextInputAutoExpand.DQbIhdma.js} +1 -1
- streamlit/static/static/js/{useUpdateUiValue.BWnXwmrp.js → useUpdateUiValue.Bk5OIXup.js} +1 -1
- streamlit/static/static/js/{useWaveformController.DozaayUB.js → useWaveformController.AH0ggRyc.js} +1 -1
- streamlit/static/static/js/{withCalculatedWidth.SNNFFxhJ.js → withCalculatedWidth.G5xJ-MbS.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.Dl2f8_gt.js → withFullScreenWrapper.rdRu6zZ4.js} +1 -1
- {streamlit-1.53.0.dist-info → streamlit-1.53.1.dist-info}/METADATA +1 -1
- {streamlit-1.53.0.dist-info → streamlit-1.53.1.dist-info}/RECORD +99 -99
- {streamlit-1.53.0.dist-info → streamlit-1.53.1.dist-info}/WHEEL +1 -1
- streamlit/static/static/js/index.BGgra9Bb.js +0 -188
- streamlit/static/static/js/uniqueId.DEvFPH9n.js +0 -1
- {streamlit-1.53.0.data → streamlit-1.53.1.data}/scripts/streamlit.cmd +0 -0
- {streamlit-1.53.0.dist-info → streamlit-1.53.1.dist-info}/entry_points.txt +0 -0
- {streamlit-1.53.0.dist-info → streamlit-1.53.1.dist-info}/top_level.txt +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as f,r as a,l as m,o as x,j as i,Z as v,q as L,$ as r,a0 as R,m as C,n as k,a1 as B,a2 as E}from"./index.
|
|
1
|
+
import{F as f,r as a,l as m,o as x,j as i,Z as v,q as L,$ as r,a0 as R,m as C,n as k,a1 as B,a2 as E}from"./index.DSTThs-t.js";const z=f("button",{target:"e1a81sb30"})(({theme:o})=>({fontSize:o.fontSizes.sm,lineHeight:o.lineHeights.base,color:o.colors.fadedText60,backgroundColor:o.colors.transparent,fontFamily:"inherit",margin:o.spacing.none,border:"none",boxShadow:"none",padding:o.spacing.none,"&:hover, &:active, &:focus":{border:"none",outline:"none",boxShadow:"none"},"&:hover":{color:o.colors.primary}})),H=f("div",{target:"e1a81sb31"})(({theme:o})=>({display:"flex",flexDirection:"row",gap:o.spacing.lg,"> span":{marginTop:o.spacing.twoXS}})),D=f("div",{target:"e1a81sb32"})(({theme:o})=>({display:"flex",flexDirection:"column",gap:o.spacing.sm,alignItems:"start",justifyContent:"center",overflow:"hidden",minHeight:"100%",fontSize:o.fontSizes.sm,lineHeight:o.lineHeights.base,div:{display:"inline-flex"}}));function M(o){const t=C(o);return{Body:{props:{"data-testid":"stToast",className:"stToast"},style:{display:"flex",flexDirection:"row",gap:o.spacing.md,width:o.sizes.toastWidth,marginTop:o.spacing.sm,borderTopLeftRadius:o.radii.default,borderTopRightRadius:o.radii.default,borderBottomLeftRadius:o.radii.default,borderBottomRightRadius:o.radii.default,paddingTop:o.spacing.lg,paddingBottom:o.spacing.lg,paddingLeft:o.spacing.twoXL,paddingRight:o.spacing.twoXL,backgroundColor:o.colors.bgColor,filter:t?"brightness(0.98)":"brightness(1.2)",color:o.colors.bodyText,boxShadow:t?"0px 4px 16px rgba(0, 0, 0, 0.16)":"0px 4px 16px rgba(0, 0, 0, 0.7)"}},CloseIcon:{style:{color:o.colors.fadedText40,width:o.fontSizes.lg,height:o.fontSizes.lg,marginRight:`calc(-1 * ${o.spacing.lg} / 2)`,":hover":{color:o.colors.bodyText}}}}}function I(o){if(o.length>104){let s=o.replace(/^(.{104}[^\s]*).*/,"$1");return s.length>104&&(s=s.substring(0,104).split(" ").slice(0,-1).join(" ")),s.trim()}return o}function j({element:o}){const{body:t,icon:s,duration:d}=o,n=m(),c=I(t),l=t!==c,[e,T]=a.useState(!l),[b,S]=a.useState(0),y=a.useCallback(()=>{T(!e)},[e]),g=a.useMemo(()=>M(n),[n]),p=a.useMemo(()=>x(H,{expanded:e,children:[s&&i(v,{iconValue:s,size:"xl",testid:"stToastDynamicIcon"}),x(D,{children:[i(L,{source:e?t:c,allowHTML:!1,isToast:!0}),l&&i(z,{"data-testid":"stToastViewButton",onClick:y,children:e?"view less":"view more"})]})]}),[l,e,t,s,c,y]);a.useEffect(()=>{if(n.inSidebar)return;const w=k(d)?d===0?0:d*1e3:4e3,u=r.info(p,{overrides:{...g},autoHideDuration:w});return S(u),()=>{r.update(u,{overrides:{Body:{style:{display:"none"}}}}),r.clear(u)}},[]),a.useEffect(()=>{r.update(b,{children:p,overrides:{...g}})},[b,p,g]);const h=i(E,{kind:B.ERROR,body:"Streamlit API Error: `st.toast` cannot be called directly on the sidebar with `st.sidebar.toast`. See our `st.toast` API [docs](https://docs.streamlit.io/develop/api-reference/status/st.toast) for more information."});return i(R,{children:n.inSidebar&&h})}const O=a.memo(j);export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,E as G,_ as Z,F as V,be as C,e as h,n as J,W as dt,l as pt,k as ft,aa as mt,ab as k,o as B,j as d,p as bt,ac as ht,ad as gt,ae as yt,Z as It,az as j}from"./index.
|
|
1
|
+
import{r as a,E as G,_ as Z,F as V,be as C,e as h,n as J,W as dt,l as pt,k as ft,aa as mt,ab as k,o as B,j as d,p as bt,ac as ht,ad as gt,ae as yt,Z as It,az as j}from"./index.DSTThs-t.js";import{I as Ct}from"./InputInstructions.Bzb0MCfv.js";import{u as Tt}from"./useBasicWidgetState.DzKGLAv_.js";import{s as St}from"./sprintf.DpPCfzXw.js";import{u as wt}from"./uniqueId.BUj-C6GA.js";import{I as vt}from"./input.Cf97CQME.js";import"./FormClearHelper.CA_5b-Ut.js";import"./base-input.avGkArOc.js";var Q=a.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return a.createElement(G,Z({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),a.createElement("path",{d:"M0 3v2h8V3H0z"}))});Q.displayName="Minus";var Y=a.forwardRef(function(t,e){var r={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return a.createElement(G,Z({iconAttrs:r,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),a.createElement("path",{d:"M3 0v3H0v2h3v3h2V5h3V3H5V0H3z"}))});Y.displayName="Plus";const xt=V("div",{target:"eaeic2i0"})(({theme:t})=>({display:"flex",flexDirection:"row",flexWrap:"nowrap",alignItems:"center",height:t.sizes.minElementHeight,borderWidth:t.sizes.borderWidth,borderStyle:"solid",borderColor:t.colors.widgetBorderColor??t.colors.secondaryBg,transitionDuration:"200ms",transitionProperty:"border",transitionTimingFunction:"cubic-bezier(0.2, 0.8, 0.4, 1)",borderRadius:t.radii.default,overflow:"hidden","&.focused":{borderColor:t.colors.primary},input:{MozAppearance:"textfield","&::-webkit-inner-spin-button, &::-webkit-outer-spin-button":{WebkitAppearance:"none",margin:t.spacing.none}}})),Dt=V("div",{target:"eaeic2i1"})({display:"flex",flexDirection:"row",alignSelf:"stretch"}),K=V("button",{target:"eaeic2i2"})(({theme:t})=>({margin:t.spacing.none,border:"none",height:t.sizes.full,display:"flex",alignItems:"center",width:t.sizes.numberInputControlsWidth,justifyContent:"center",color:t.colors.bodyText,transition:"color 300ms, backgroundColor 300ms",backgroundColor:t.colors.secondaryBg,"&:hover:enabled, &:focus:enabled":{color:t.colors.white,backgroundColor:t.colors.primary,transition:"none",outline:"none"},"&:active":{outline:"none",border:"none"},"&:disabled":{cursor:"not-allowed",color:t.colors.fadedText40}})),kt=V("div",{target:"eaeic2i3"})(({theme:t,clearable:e})=>({position:"absolute",marginRight:t.spacing.twoXS,left:0,right:`calc(${t.sizes.numberInputControlsWidth} * 2 + ${e?"1em":"0em"})`})),Vt=dt.getLogger("NumberInput");function Nt(t){return h(t)||t===""?void 0:t}const tt=t=>{const e=t.toString();if(e.includes("e-")){const r=e.match(/(\d+(?:\.\d+)?)e-(\d+)/);if(r){const s=(r[1]?.split(".")[1]||"").length,n=parseInt(r[2],10);return s+n}return 0}return(e.split(".")[1]||"").length},_=({value:t,format:e,step:r,dataType:s})=>{if(h(t))return null;let n=Nt(e);if(h(n)&&J(r)&&s===C.DataType.FLOAT&&r!==0){const l=tt(r);l>0&&(n=`%0.${l}f`)}if(h(n))return t.toString();try{return St.sprintf(n,t)}catch(l){return Vt.warn(`Error in sprintf(${n}, ${t}): ${l}`),String(t)}},Et=(t,e,r)=>h(t)?!1:t-e>=r,Ft=(t,e,r)=>h(t)?!1:t+e<=r,X=(t,e,r)=>{const s=tt(e);if(s===0)switch(r){case"add":return t+e;case"subtract":return t-e}const n=Math.pow(10,s),l=Math.round(t*n),p=Math.round(e*n);switch(r){case"add":return(l+p)/n;case"subtract":return(l-p)/n}},Rt=({step:t,dataType:e})=>t||(e===C.DataType.INT?1:.01);function q(t,e){return e.dataType===C.DataType.INT?t.getIntValue(e):t.getDoubleValue(e)}function Wt(t){return t.default??null}function zt(t){return t.value??t.default??null}function Bt(t,e,r,s){switch(t.dataType){case C.DataType.INT:e.setIntValue(t,r.value,{fromUi:r.fromUi},s);break;case C.DataType.FLOAT:e.setDoubleValue(t,r.value,{fromUi:r.fromUi},s);break;default:throw new Error("Invalid data type")}}const Lt=({disabled:t,element:e,widgetMgr:r,fragmentId:s})=>{const n=pt(),{dataType:l,formId:p,default:T,format:N,icon:E,min:g,max:y}=e,{width:L,elementRef:et}=ft(),c=a.useMemo(()=>Rt({step:e.step,dataType:e.dataType}),[e.step,e.dataType]),I=a.useCallback(o=>_({value:o,dataType:l,format:N,step:c}),[l,N,c]),[f,w]=a.useState(!1),[b,S]=a.useState(()=>{const o=q(r,e)??T??null;return _({value:o,dataType:l,format:N,step:c})}),[P,U]=Tt({getStateFromWidgetMgr:q,getDefaultStateFromProto:Wt,getCurrStateFromProto:zt,updateWidgetMgrState:Bt,element:e,widgetMgr:r,fragmentId:s,onFormCleared:a.useCallback(()=>{const o=T??null;w(!1),S(I(o))},[T,I])}),[A,H]=a.useState(!1),F=a.useRef(null),[$]=a.useState(()=>wt("number_input_")),M=mt({formId:p}),nt=M?r.allowFormEnterToSubmit(p):f,rt=A&&L>k(n.breakpoints.hideWidgetDetails);a.useEffect(()=>{f||S(I(P))},[P,f,I]);const m=a.useCallback(({value:o,fromUi:i})=>{if(J(o)&&(g>o||o>y)){F.current?.reportValidity();return}const D=o??T??null;U({value:D,fromUi:i}),w(!1),S(I(D))},[g,y,T,I,U]),ot=a.useCallback(()=>{H(!0)},[]);a.useEffect(()=>{const o=F.current;if(o){const i=D=>{D.preventDefault()};return o.addEventListener("wheel",i),()=>{o.removeEventListener("wheel",i)}}},[]);const R=h(e.default)&&!t,at=a.useCallback(o=>{const{value:i}=o.target;i===""?(w(!0),S(null)):(w(!0),S(i))},[]),u=a.useMemo(()=>{if(b===null||b==="")return null;if(e.dataType===C.DataType.INT){const i=parseInt(b,10);return isNaN(i)?null:i}const o=parseFloat(b);return isNaN(o)?null:o},[b,e.dataType]),v=Et(u,c,g),x=Ft(u,c,y),st=a.useCallback(()=>{f&&m({value:u,fromUi:!0}),H(!1)},[f,u,m]),W=a.useCallback(()=>{if(x){const o=X(u??g,c,"add");m({value:o,fromUi:!0})}},[u,g,c,x,m]),z=a.useCallback(()=>{if(v){const o=X(u??y,c,"subtract");m({value:o,fromUi:!0})}},[u,y,c,v,m]),it=a.useCallback(o=>{const{key:i}=o;switch(i){case"ArrowUp":o.preventDefault(),W();break;case"ArrowDown":o.preventDefault(),z();break}},[W,z]),lt=a.useCallback(o=>{o.key==="Enter"&&(f&&m({value:u,fromUi:!0}),r.allowFormEnterToSubmit(p)&&r.submitForm(p,s))},[f,u,m,r,p,s]),ct=k(n.iconSizes.lg)+2*k(n.spacing.twoXS),O=k(n.breakpoints.hideNumberInputControls),ut=E?O+ct:O;return B("div",{className:"stNumberInput","data-testid":"stNumberInput",ref:et,children:[d(gt,{label:e.label,disabled:t,labelVisibility:bt(e.labelVisibility?.value),htmlFor:$,children:e.help&&d(ht,{content:e.help,label:e.label})}),B(xt,{className:A?"focused":"","data-testid":"stNumberInputContainer",children:[d(vt,{type:"number",inputRef:F,value:b??"",placeholder:e.placeholder,onBlur:st,onFocus:ot,onChange:at,onKeyPress:lt,onKeyDown:it,clearable:R,clearOnEscape:R,disabled:t,"aria-label":e.label,startEnhancer:e.icon&&d(It,{"data-testid":"stNumberInputIcon",iconValue:e.icon,size:"lg"}),id:$,overrides:{ClearIconContainer:{style:{padding:0}},ClearIcon:{props:{overrides:{Svg:{style:{color:n.colors.grayTextColor,padding:n.spacing.threeXS,height:n.sizes.clearIconSize,width:n.sizes.clearIconSize,":hover":{fill:n.colors.bodyText}}}}}},Input:{props:{"data-testid":"stNumberInputField",step:c,min:g,max:y,type:"number",inputMode:""},style:{fontWeight:n.fontWeights.normal,lineHeight:n.lineHeights.inputWidget,paddingRight:n.spacing.sm,paddingLeft:n.spacing.md,paddingBottom:n.spacing.sm,paddingTop:n.spacing.sm,"::placeholder":{color:n.colors.fadedText60}}},InputContainer:{style:()=>({borderTopRightRadius:0,borderBottomRightRadius:0})},Root:{style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:0,borderRightWidth:0,borderTopWidth:0,borderBottomWidth:0,paddingRight:0,paddingLeft:E?n.spacing.sm:0}},StartEnhancer:{style:{paddingLeft:0,paddingRight:0,minWidth:n.iconSizes.lg,color:yt(E)?n.colors.fadedText60:"inherit"}}}}),L>ut&&B(Dt,{children:[d(K,{"data-testid":"stNumberInputStepDown",onClick:z,disabled:!v||t,tabIndex:-1,children:d(j,{content:Q,size:"xs",color:v?"inherit":n.colors.fadedText40})}),d(K,{"data-testid":"stNumberInputStepUp",onClick:W,disabled:!x||t,tabIndex:-1,children:d(j,{content:Y,size:"xs",color:x?"inherit":n.colors.fadedText40})})]})]}),rt&&d(kt,{clearable:R,children:d(Ct,{dirty:f,value:b??"",inForm:M,allowEnterToSubmit:nt})})]})},Kt=a.memo(Lt);export{Kt as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ao as q,x as J,r as c,b9 as Q,l as Y,ba as ee,bb as l,j as L,o as te,p as re,P as ne,bc as oe,ad as ie,bd as ae,b as ue,B as C,c as x,D as le}from"./index.
|
|
1
|
+
import{ao as q,x as J,r as c,b9 as Q,l as Y,ba as ee,bb as l,j as L,o as te,p as re,P as ne,bc as oe,ad as ie,bd as ae,b as ue,B as C,c as x,D as le}from"./index.DSTThs-t.js";import{W as ce}from"./WidgetLabelHelpIconInline.BjIku2ic.js";import{u as se}from"./useBasicWidgetState.DzKGLAv_.js";import"./FormClearHelper.CA_5b-Ut.js";var fe={secondary:"secondary"},N={default:"default"},pe={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!==N.default?"-".concat(n.sizing.scale100):"-0.5px";return{display:"flex",marginLeft:o,marginRight:o}});z.displayName="StyledRoot";z.displayName="StyledRoot";function M(e){"@babel/helpers - typeof";return M=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},M(e)}function $(){return $=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},$.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 de(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){V(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 ye(e,t){return Se(e)||me(e,t)||he(e,t)||be()}function be(){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 he(e,t){if(e){if(typeof e=="string")return K(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 K(e,t)}}function K(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 me(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,d;try{for(r=r.call(e);!(o=(a=r.next()).done)&&(n.push(a.value),!(t&&n.length===t));o=!0);}catch(s){i=!0,d=s}finally{try{!o&&r.return!=null&&r.return()}finally{if(i)throw d}}return n}}function Se(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 Oe(e,t,r){return t&&ve(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ee(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&&G(e,t)}function G(e,t){return G=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},G(e,t)}function _e(e){var t=Le();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 we(this,o)}}function we(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return F(e)}function F(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Le(){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 V(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Re(e,t){return!Array.isArray(e)&&typeof e!="number"?!1:Array.isArray(e)?e.includes(t):e===t}var H=(function(e){Ee(r,e);var t=_e(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)),V(F(n),"childRefs",{}),n}return Oe(r,[{key:"render",value:function(){var o=this,i=this.props,a=i.overrides,d=a===void 0?{}:a,s=i.mode,y=s===void 0?k.checkbox:s,S=i.children,b=i.selected,E=i.disabled,f=i.onClick,h=i.kind,v=i.shape,m=i.size,I=J(d.Root,z),_=ye(I,2),A=_[0],R=_[1],w=this.props["aria-label"]||this.props.ariaLabel,p=y===k.radio,W=c.Children.count(S);return c.createElement(Q.Consumer,null,function(Z){return c.createElement(A,$({"aria-label":w||Z.buttongroup.ariaLabel,"data-baseweb":"button-group",role:p?"radiogroup":"group",$shape:v,$length:S.length},R),c.Children.map(S,function(g,P){if(!c.isValidElement(g))return null;var D=g.props.isSelected?g.props.isSelected:Re(b,P);return p&&(o.childRefs[P]=c.createRef()),c.cloneElement(g,{disabled:E||g.props.disabled,isSelected:D,ref:p?o.childRefs[P]:void 0,tabIndex:!p||D||p&&(!b||b===-1)&&P===0?0:-1,onKeyDown:function(u){if(p){var O=Number(b)?Number(b):0;if(u.key==="ArrowUp"||u.key==="ArrowLeft"){u.preventDefault&&u.preventDefault();var T=O-1<0?W-1:O-1;f&&f(u,T),o.childRefs[T].current&&o.childRefs[T].current.focus()}if(u.key==="ArrowDown"||u.key==="ArrowRight"){u.preventDefault&&u.preventDefault();var j=O+1>W-1?0:O+1;f&&f(u,j),o.childRefs[j].current&&o.childRefs[j].current.focus()}}},kind:h,onClick:function(u){E||(g.props.onClick&&g.props.onClick(u),f&&f(u,P))},shape:v,size:m,overrides:de({BaseButton:{style:function(u){var O=u.$theme;return S.length===1?{}:v!==N.default?{marginLeft:O.sizing.scale100,marginRight:O.sizing.scale100}:{marginLeft:"0.5px",marginRight:"0.5px"}},props:{"aria-checked":D,role:p?"radio":"checkbox"}}},g.props.overrides)})}))})}}]),r})(c.Component);V(H,"defaultProps",{disabled:!1,onClick:function(){},shape:N.default,size:pe.default,kind:fe.secondary});function Pe(e,t){return t.includes(e)?t.filter(r=>r!==e):[...t,e]}function Ce(e,t,r){return e===l.ClickMode.MULTI_SELECT?Pe(t,r??[]):r?.includes(t)?[]:[t]}function ke(e){return e.length===0?-1:e[0]}function Be(e,t,r,n){t.setIntArrayValue(e,r.value,{fromUi:r.fromUi},n)}function Ie(e,t,r){const n=r===l.Style.PILLS?C.PILLS:r===l.Style.BORDERLESS?C.BORDERLESS_ICON:C.SEGMENTED_CONTROL,o=r===l.Style.BORDERLESS?x.XSMALL:x.MEDIUM,i=n===C.PILLS||n===C.SEGMENTED_CONTROL,a=r===l.Style.BORDERLESS?"lg":"base";return{element:L(le,{icon:t,label:e,iconSize:a,useSmallerFont:i}),kind:n,size:o}}function Ae(e,t,r,n){return r.indexOf(n)>-1?!0:t!==l.ClickMode.SINGLE_SELECT||e!==l.SelectionVisualization.ALL_UP_TO_SELECTED?!1:r.length>0&&n<r[0]}function De(e,t){return e&&(t=`${t}Active`),t}function Te(e,t,r){const n={flexWrap:"wrap",maxWidth:r?"100%":"fit-content",margin:"0 0"},o=r?"100%":"auto";switch(e){case l.Style.BORDERLESS:return{...n,columnGap:t.threeXS,rowGap:t.threeXS};case l.Style.PILLS:return{...n,columnGap:t.twoXS,rowGap:t.twoXS,width:o};case l.Style.SEGMENTED_CONTROL:return{...n,columnGap:t.none,rowGap:t.twoXS,width:o};default:return n}}function je(e,t,r,n,o,i,a){const d=Ae(r,n,o,t);let s=e.content,y=e.contentIcon;return d&&(s=e.selectedContent?e.selectedContent:s,y=e.selectedContentIcon?e.selectedContentIcon:y),c.forwardRef(function(b,E){const{element:f,kind:h,size:v}=Ie(s??"",y??void 0,i),m=De(!!(d&&!e.selectedContent&&!e.selectedContentIcon),h);return L(ue,{...b,size:v,kind:m,containerWidth:a,children:f})})}function Me(e,t){return e.getIntArrayValue(t)}function $e(e){return e.default??[]}function Ge(e){return e.value??[]}function Ne(e){const{disabled:t,element:r,fragmentId:n,widgetMgr:o,widthConfig:i}=e,{clickMode:a,options:d,selectionVisualization:s,style:y,label:S,labelVisibility:b,help:E}=r,f=Y(),[h,v]=se({getStateFromWidgetMgr:Me,getDefaultStateFromProto:$e,getCurrStateFromProto:Ge,updateWidgetMgrState:Be,element:r,widgetMgr:o,fragmentId:n}),m=ee(i),I=(R,w)=>{const p=Ce(a,w,h);v({value:p,fromUi:!0})};let _;a===l.ClickMode.SINGLE_SELECT?_=k.radio:a===l.ClickMode.MULTI_SELECT&&(_=k.checkbox);const A=c.useMemo(()=>d.map((R,w)=>{const p=je(R,w,s,a,h,y,m);return L(p,{},`${R.content}-${w}`)}),[a,d,s,y,h,m]);return te(ae,{className:"stButtonGroup","data-testid":"stButtonGroup",containerWidth:m,children:[L(ie,{label:S,disabled:t,labelVisibility:re(b?.value??oe.LabelVisibilityOptions.COLLAPSED),children:E&&L(ce,{content:E,placement:ne.TOP,label:S})}),L(H,{disabled:t,mode:_,onClick:I,selected:a===l.ClickMode.MULTI_SELECT?h:ke(h),overrides:{Root:{style:c.useCallback(()=>Te(y,f.spacing,m),[y,f.spacing,m])}},children:A})]})}const xe=c.memo(Ne);export{xe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,E as H,_ as D,F as _,aj as he,o as O,j as U,aA as ge,P as ve,b as me,B as Se,az as q,bQ as re,an as be,ah as ye,bi as Ce,l as Ue,bR as we,k as Me,al as Ee,e as L,W as xe,bj as Ie,p as Fe,ac as Re,ad as _e,a0 as Pe,bS as Oe,bT as ke}from"./index.DFT9nVK6.js";import{U as ie}from"./UploadFileInfo.Dr-zDST7.js";import{u as Te}from"./FormClearHelper.CUrwwEeX.js";import{P as We,S as Le}from"./ProgressBar.qKdiDYyx.js";import{b as je}from"./urls.BwSlolu9.js";var oe=n.forwardRef(function(e,a){var d={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return n.createElement(H,D({iconAttrs:d,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:a}),n.createElement("rect",{width:24,height:24,fill:"none"}),n.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"}))});oe.displayName="SwitchCamera";var ne=n.forwardRef(function(e,a){var d={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return n.createElement(H,D({iconAttrs:d,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},e,{ref:a}),n.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"}))});ne.displayName="Video";var ae=n.forwardRef(function(e,a){var d={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return n.createElement(H,D({iconAttrs:d,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},e,{ref:a}),n.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"}))});ae.displayName="X";function Be(e,a){switch(e){case"xsmall":return{padding:`${a.spacing.twoXS} ${a.spacing.sm}`,fontSize:a.fontSizes.sm};case"small":return{padding:`${a.spacing.twoXS} ${a.spacing.md}`};case"large":return{padding:`${a.spacing.md} ${a.spacing.md}`};default:return{padding:`${a.spacing.xs} ${a.spacing.md}`}}}const se=_("div",{target:"e1dr6u8s0"})({position:"relative",overflow:"hidden",width:"100%",objectFit:"contain"}),G=_("div",{target:"e1dr6u8s1"})(({theme:e,width:a})=>({backgroundColor:e.colors.secondaryBg,borderRadius:`${e.radii.default} ${e.radii.default} 0 0`,width:"100%",height:a*9/16,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"})),Ve=_("p",{target:"e1dr6u8s2"})(({theme:e})=>({marginTop:e.spacing.sm,textAlign:"center"})),Ae=_("img",{target:"e1dr6u8s3"})(({theme:e,opacity:a})=>({borderRadius:`${e.radii.default} ${e.radii.default} 0 0`,objectFit:"contain",opacity:a})),ze=_("a",{target:"e1dr6u8s4"})(({theme:e})=>({color:e.colors.link,textDecoration:e.linkUnderline?"underline":"none",display:"block"})),$e=_("span",{target:"e1dr6u8s5"})({display:"flex",alignItems:"center"}),Ne=_("div",{target:"e1dr6u8s6"})(({theme:e})=>({position:"absolute",top:e.spacing.lg,right:e.spacing.lg,zIndex:e.zIndices.priority,color:e.colors.fadedText40,mixBlendMode:"difference",opacity:.6})),He=_("div",{target:"e1dr6u8s8"})({height:"fit-content",width:"100%",position:"absolute",bottom:0}),De=_("button",{target:"e1dr6u8s9"})(({theme:e})=>({position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:e.colors.lightenedBg05,border:`${e.sizes.borderWidth} solid ${e.colors.borderColor}`,borderRadius:`0 0 ${e.radii.default} ${e.radii.default}`,"&:hover":{borderColor:e.colors.primary,color:e.colors.primary},"&:active":{color:e.colors.white,borderColor:e.colors.primary,backgroundColor:e.colors.primary},"&:focus:not(:active)":{borderColor:e.colors.primary,color:e.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{color:e.colors.fadedText40,borderColor:e.colors.borderColor,backgroundColor:e.colors.lightenedBg05,cursor:"not-allowed"},fontWeight:e.fontWeights.normal,padding:`${e.spacing.xs} ${e.spacing.md}`,margin:e.spacing.none,lineHeight:e.lineHeights.base,color:"inherit",width:"100%",userSelect:"none","&:focus":{outline:"none"},"&:focus-visible":{boxShadow:he(e)},...Be("medium",e)}));function qe({disabled:e,onClick:a,children:d,progress:g}){return O(De,{disabled:e||!1,onClick:a||(()=>{}),progress:g||null,"data-testid":"stCameraInputButton",children:[d,g?U(He,{children:U(We,{value:g,size:Le.EXTRASMALL,overrides:{Bar:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarProgress:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarContainer:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}}}})}):null]})}const le=n.memo(qe);var V=(function(e){return e.USER="user",e.ENVIRONMENT="environment",e})({});const Ge=({switchFacingMode:e})=>U(Ne,{"data-testid":"stCameraInputSwitchButton",children:U(ge,{content:"Switch camera",placement:ve.TOP_RIGHT,children:U(me,{kind:Se.MINIMAL,onClick:e,children:U(q,{content:oe,size:"twoXL",color:re.white})})})}),Xe=n.memo(Ge);var A={exports:{}},Qe=A.exports,te;function Je(){return te||(te=1,(function(e,a){(function(g,v){e.exports=v(be())})(Qe,function(d){return(function(g){var v={};function p(o){if(v[o])return v[o].exports;var f=v[o]={i:o,l:!1,exports:{}};return g[o].call(f.exports,f,f.exports,p),f.l=!0,f.exports}return p.m=g,p.c=v,p.d=function(o,f,m){p.o(o,f)||Object.defineProperty(o,f,{enumerable:!0,get:m})},p.r=function(o){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},p.t=function(o,f){if(f&1&&(o=p(o)),f&8||f&4&&typeof o=="object"&&o&&o.__esModule)return o;var m=Object.create(null);if(p.r(m),Object.defineProperty(m,"default",{enumerable:!0,value:o}),f&2&&typeof o!="string")for(var F in o)p.d(m,F,(function(I){return o[I]}).bind(null,F));return m},p.n=function(o){var f=o&&o.__esModule?function(){return o.default}:function(){return o};return p.d(f,"a",f),f},p.o=function(o,f){return Object.prototype.hasOwnProperty.call(o,f)},p.p="",p(p.s="./src/react-webcam.tsx")})({"./src/react-webcam.tsx":(function(g,v,p){p.r(v);var o=p("react"),f=(function(){var b=function(i,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var l in s)s.hasOwnProperty(l)&&(r[l]=s[l])},b(i,t)};return function(i,t){b(i,t);function r(){this.constructor=i}i.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}})(),m=function(){return m=Object.assign||function(b){for(var i,t=1,r=arguments.length;t<r;t++){i=arguments[t];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(b[s]=i[s])}return b},m.apply(this,arguments)},F=function(b,i){var t={};for(var r in b)Object.prototype.hasOwnProperty.call(b,r)&&i.indexOf(r)<0&&(t[r]=b[r]);if(b!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(b);s<r.length;s++)i.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(b,r[s])&&(t[r[s]]=b[r[s]]);return t};(function(){typeof window>"u"||(navigator.mediaDevices===void 0&&(navigator.mediaDevices={}),navigator.mediaDevices.getUserMedia===void 0&&(navigator.mediaDevices.getUserMedia=function(i){var t=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return t?new Promise(function(r,s){t.call(navigator,i,r,s)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}))})();function I(){return!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)}var R=(function(b){f(i,b);function i(t){var r=b.call(this,t)||this;return r.canvas=null,r.ctx=null,r.requestUserMediaId=0,r.unmounted=!1,r.state={hasUserMedia:!1},r}return i.prototype.componentDidMount=function(){var t=this,r=t.state,s=t.props;if(this.unmounted=!1,!I()){s.onUserMediaError("getUserMedia not supported");return}r.hasUserMedia||this.requestUserMedia(),s.children&&typeof s.children!="function"&&console.warn("children must be a function")},i.prototype.componentDidUpdate=function(t){var r=this.props;if(!I()){r.onUserMediaError("getUserMedia not supported");return}var s=JSON.stringify(t.audioConstraints)!==JSON.stringify(r.audioConstraints),l=JSON.stringify(t.videoConstraints)!==JSON.stringify(r.videoConstraints),M=t.minScreenshotWidth!==r.minScreenshotWidth,y=t.minScreenshotHeight!==r.minScreenshotHeight;(l||M||y)&&(this.canvas=null,this.ctx=null),(s||l)&&(this.stopAndCleanup(),this.requestUserMedia())},i.prototype.componentWillUnmount=function(){this.unmounted=!0,this.stopAndCleanup()},i.stopMediaStream=function(t){t&&(t.getVideoTracks&&t.getAudioTracks?(t.getVideoTracks().map(function(r){t.removeTrack(r),r.stop()}),t.getAudioTracks().map(function(r){t.removeTrack(r),r.stop()})):t.stop())},i.prototype.stopAndCleanup=function(){var t=this.state;t.hasUserMedia&&(i.stopMediaStream(this.stream),t.src&&window.URL.revokeObjectURL(t.src))},i.prototype.getScreenshot=function(t){var r=this,s=r.state,l=r.props;if(!s.hasUserMedia)return null;var M=this.getCanvas(t);return M&&M.toDataURL(l.screenshotFormat,l.screenshotQuality)},i.prototype.getCanvas=function(t){var r=this,s=r.state,l=r.props;if(!this.video||!s.hasUserMedia||!this.video.videoHeight)return null;if(!this.ctx){var M=this.video.videoWidth,y=this.video.videoHeight;if(!this.props.forceScreenshotSourceSize){var C=M/y;M=l.minScreenshotWidth||this.video.clientWidth,y=M/C,l.minScreenshotHeight&&y<l.minScreenshotHeight&&(y=l.minScreenshotHeight,M=y*C)}this.canvas=document.createElement("canvas"),this.canvas.width=t?.width||M,this.canvas.height=t?.height||y,this.ctx=this.canvas.getContext("2d")}var x=this,w=x.ctx,S=x.canvas;return w&&S&&(S.width=t?.width||S.width,S.height=t?.height||S.height,l.mirrored&&(w.translate(S.width,0),w.scale(-1,1)),w.imageSmoothingEnabled=l.imageSmoothing,w.drawImage(this.video,0,0,t?.width||S.width,t?.height||S.height),l.mirrored&&(w.scale(-1,1),w.translate(-S.width,0))),S},i.prototype.requestUserMedia=function(){var t=this,r=this.props,s=function(y,C){var x={video:typeof C<"u"?C:!0};r.audio&&(x.audio=typeof y<"u"?y:!0),t.requestUserMediaId++;var w=t.requestUserMediaId;navigator.mediaDevices.getUserMedia(x).then(function(S){t.unmounted||w!==t.requestUserMediaId?i.stopMediaStream(S):t.handleUserMedia(null,S)}).catch(function(S){t.handleUserMedia(S)})};if("mediaDevices"in navigator)s(r.audioConstraints,r.videoConstraints);else{var l=function(y){return{optional:[{sourceId:y}]}},M=function(y){var C=y.deviceId;return typeof C=="string"?C:Array.isArray(C)&&C.length>0?C[0]:typeof C=="object"&&C.ideal?C.ideal:null};MediaStreamTrack.getSources(function(y){var C=null,x=null;y.forEach(function(P){P.kind==="audio"?C=P.id:P.kind==="video"&&(x=P.id)});var w=M(r.audioConstraints);w&&(C=w);var S=M(r.videoConstraints);S&&(x=S),s(l(C),l(x))})}},i.prototype.handleUserMedia=function(t,r){var s=this.props;if(t||!r){this.setState({hasUserMedia:!1}),s.onUserMediaError(t);return}this.stream=r;try{this.video&&(this.video.srcObject=r),this.setState({hasUserMedia:!0})}catch{this.setState({hasUserMedia:!0,src:window.URL.createObjectURL(r)})}s.onUserMedia(r)},i.prototype.render=function(){var t=this,r=this,s=r.state,l=r.props,M=l.audio;l.forceScreenshotSourceSize;var y=l.disablePictureInPicture;l.onUserMedia,l.onUserMediaError,l.screenshotFormat,l.screenshotQuality,l.minScreenshotWidth,l.minScreenshotHeight,l.audioConstraints,l.videoConstraints,l.imageSmoothing;var C=l.mirrored,x=l.style,w=x===void 0?{}:x,S=l.children,P=F(l,["audio","forceScreenshotSourceSize","disablePictureInPicture","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored","style","children"]),z=C?m(m({},w),{transform:(w.transform||"")+" scaleX(-1)"}):w,j={getScreenshot:this.getScreenshot.bind(this)};return o.createElement(o.Fragment,null,o.createElement("video",m({autoPlay:!0,disablePictureInPicture:y,src:s.src,muted:!M,playsInline:!0,ref:function(B){t.video=B},style:z},P)),S&&S(j))},i.defaultProps={audio:!1,disablePictureInPicture:!1,forceScreenshotSourceSize:!1,imageSmoothing:!0,mirrored:!1,onUserMedia:function(){},onUserMediaError:function(){},screenshotFormat:"image/webp",screenshotQuality:.92},i})(o.Component);v.default=R}),react:(function(g,v){g.exports=d})}).default})})(A)),A.exports}var Ke=Je();const Ye=ye(Ke),Ze=({width:e})=>O(G,{width:e,children:[U(q,{size:"threeXL",color:re.gray60,content:ne}),O(Ve,{children:["This app would like to use your camera.",U(ze,{href:je,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]})]}),et=({handleCapture:e,width:a,disabled:d,clearPhotoInProgress:g,setClearPhotoInProgress:v,facingMode:p,setFacingMode:o,testOverride:f})=>{const[m,F]=n.useState(f||"pending"),I=n.useRef(null),[R,b]=n.useState(a),i=n.useCallback(Ce(1e3,b),[]);n.useEffect(()=>{i(a)},[a,i]);function t(){if(I.current!==null){const s=I.current.getScreenshot();e(s)}}const r=Ue();return O(se,{"data-testid":"stCameraInputWebcamComponent",children:[m!=="success"&&!d&&!g?U(Ze,{width:R}):we()&&U(Xe,{switchFacingMode:o}),U(G,{"data-testid":"stCameraInputWebcamStyledBox",hidden:m!=="success"&&!d&&!g,width:R,children:!d&&U(Ye,{audio:!1,ref:I,screenshotFormat:"image/jpeg",screenshotQuality:1,width:R,height:R*9/16,style:{borderRadius:`${r.radii.default} ${r.radii.default} 0 0`},onUserMediaError:()=>{F("error")},onUserMedia:()=>{F("success"),v(!1)},videoConstraints:{width:{ideal:R},facingMode:p}})}),U(le,{onClick:t,disabled:m!=="success"||d||g,children:"Take Photo"})]})},tt=n.memo(et),ce="RESTORED_FROM_WIDGET",rt=150,it=xe.getLogger("CameraInput"),N=e=>{const a=e.filter(d=>d.status.type==="uploaded").map(d=>{const{name:g,size:v,status:p}=d,{fileId:o,fileUrls:f}=p;return new Oe({fileId:o,fileUrls:f,name:g,size:v})});return new ke({uploadedFileInfo:a})},ot=(e,a)=>{const d=a.getFileUploaderStateValue(e);if(L(d))return{files:[],nextLocalId:1,imgSrc:null};const{uploadedFileInfo:g}=d;if(L(g)||g.length===0)return{files:[],nextLocalId:1,imgSrc:null};let v=1;const p=g.map(o=>{const f=o.name,m=o.size,F=o.fileId,I=o.fileUrls,R=new ie(f,m,v,{type:"uploaded",fileId:F,fileUrls:I});return v+=1,R});return{files:p,nextLocalId:v,imgSrc:p.length>0?ce:null}};function nt(e,a){return fetch(e).then(d=>d.arrayBuffer()).then(d=>new File([d],a,{type:"image/jpeg"}))}const at=({element:e,widgetMgr:a,uploadClient:d,disabled:g,fragmentId:v,testOverride:p})=>{const{width:o,elementRef:f}=Me(),m=n.useRef(null);m.current===null&&(m.current=ot(e,a));const{files:F,nextLocalId:I,imgSrc:R}=m.current,b=n.useRef(I),[i,t]=n.useState(()=>F),r=n.useRef(i);n.useLayoutEffect(()=>{r.current=i},[i]);const[s,l]=n.useState(()=>R),[M,y]=n.useState(!1),[C,x]=n.useState(!0),[w,S]=n.useState(!1),[P,z]=n.useState(V.USER),j=n.useCallback(()=>{const c=b.current;return b.current+=1,c},[]),B=n.useMemo(()=>{const c=u=>u.status.type==="uploading";return i.some(c)?"updating":"ready"},[i]),$=n.useMemo(()=>{if(i.length>0&&i[i.length-1].status.type==="uploading")return i[i.length-1].status.progress},[i]),de=n.useCallback(()=>{z(c=>c===V.USER?V.ENVIRONMENT:V.USER)},[]),k=n.useCallback(c=>r.current.find(u=>u.id===c),[]),X=n.useCallback(c=>{Ee.flushSync(()=>{t(u=>[...u,c])})},[]),Q=n.useCallback(c=>{t(u=>u.filter(h=>h.id!==c))},[]),T=n.useCallback((c,u)=>{t(h=>h.map(E=>E.id===c?u:E))},[]),J=n.useCallback((c,u)=>{y(!1);const h=k(c);L(h)||h.status.type!=="uploading"||T(h.id,h.setStatus({type:"uploaded",fileId:u.fileId,fileUrls:u}))},[k,T]),K=n.useCallback((c,u)=>{const h=k(u);if(L(h)||h.status.type!=="uploading")return;const E=Math.round(c.loaded*100/c.total);h.status.progress!==E&&T(u,h.setStatus({type:"uploading",abortController:h.status.abortController,progress:E}))},[k,T]),Y=n.useCallback((c,u)=>{const h=new AbortController,E=new ie(u.name,u.size,j(),{type:"uploading",abortController:h,progress:1});X(E),d.uploadFile(e,c.uploadUrl,u,W=>K(W,E.id),h.signal).then(()=>J(E.id,c)).catch(W=>{W instanceof DOMException&&W.name==="AbortError"||T(E.id,E.setStatus({type:"error",errorMessage:W?W.toString():"Unknown error"}))})},[X,e,j,J,K,T,d]),Z=n.useCallback(c=>{const u=k(c);L(u)||(u.status.type==="uploading"&&u.status.abortController.abort(),u.status.type==="uploaded"&&u.status.fileUrls.deleteUrl&&d.deleteFile(u.status.fileUrls.deleteUrl),Q(c))},[k,Q,d]),ee=n.useCallback(c=>{if(c===null)return Promise.resolve();l(c),y(!0),x(!1);const u=h=>new Promise(E=>setTimeout(E,h));return nt(c,`camera-input-${new Date().toISOString().replace(/:/g,"_")}.jpg`).then(h=>d.fetchFileURLs([h]).then(E=>({file:h,fileUrls:E[0]}))).then(({file:h,fileUrls:E})=>Y(E,h)).then(()=>u(rt)).then(()=>{x(!0)}).catch(h=>{it.error(h)})},[d,Y]),ue=n.useCallback(c=>{ee(c)},[ee]),fe=n.useCallback(()=>{i.length!==0&&(i.forEach(c=>Z(c.id)),l(null),S(!0))},[i,Z]);n.useEffect(()=>{a.getFileUploaderStateValue(e)===void 0&&a.setFileUploaderStateValue(e,N(i),{fromUi:!1},v)},[]),n.useEffect(()=>{if(B!=="ready")return;const c=N(i),u=a.getFileUploaderStateValue(e);Ie(c,u)||a.setFileUploaderStateValue(e,c,{fromUi:!0},v)},[B,i,a,e,v]);const pe=n.useCallback(()=>{t([]),l(null);const c=N([]);a.setFileUploaderStateValue(e,c,{fromUi:!0},v)},[e,v,a]);return Te({element:e,widgetMgr:a,onFormCleared:pe}),O(se,{className:"stCameraInput","data-testid":"stCameraInput",ref:f,children:[U(_e,{label:e.label,disabled:g,labelVisibility:Fe(e.labelVisibility?.value),children:e.help&&U(Re,{content:e.help,label:e.label})}),s?O(Pe,{children:[U(G,{width:o,children:s!==ce&&U(Ae,{src:s,alt:"Snapshot",opacity:M||!C?"50%":"100%",width:o,height:o*9/16})}),U(le,{onClick:fe,progress:$,disabled:!!$||g,children:$?"Uploading...":O($e,{children:[U(q,{content:ae,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):U(tt,{handleCapture:ue,width:o,disabled:g,clearPhotoInProgress:w,setClearPhotoInProgress:S,facingMode:P,setFacingMode:de,testOverride:p})]})},ft=n.memo(at);export{ft as default};
|
|
1
|
+
import{r as n,E as H,_ as D,F as _,aj as he,o as O,j as U,aA as ge,P as ve,b as me,B as Se,az as q,bQ as re,an as be,ah as ye,bi as Ce,l as Ue,bR as we,k as Me,al as Ee,e as L,W as xe,bj as Ie,p as Fe,ac as Re,ad as _e,a0 as Pe,bS as Oe,bT as ke}from"./index.DSTThs-t.js";import{U as ie}from"./UploadFileInfo.Dr-zDST7.js";import{u as Te}from"./FormClearHelper.CA_5b-Ut.js";import{P as We,S as Le}from"./ProgressBar.DyQNhVsJ.js";import{b as je}from"./urls.BwSlolu9.js";var oe=n.forwardRef(function(e,a){var d={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return n.createElement(H,D({iconAttrs:d,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:a}),n.createElement("rect",{width:24,height:24,fill:"none"}),n.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"}))});oe.displayName="SwitchCamera";var ne=n.forwardRef(function(e,a){var d={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return n.createElement(H,D({iconAttrs:d,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},e,{ref:a}),n.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"}))});ne.displayName="Video";var ae=n.forwardRef(function(e,a){var d={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return n.createElement(H,D({iconAttrs:d,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},e,{ref:a}),n.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"}))});ae.displayName="X";function Be(e,a){switch(e){case"xsmall":return{padding:`${a.spacing.twoXS} ${a.spacing.sm}`,fontSize:a.fontSizes.sm};case"small":return{padding:`${a.spacing.twoXS} ${a.spacing.md}`};case"large":return{padding:`${a.spacing.md} ${a.spacing.md}`};default:return{padding:`${a.spacing.xs} ${a.spacing.md}`}}}const se=_("div",{target:"e1dr6u8s0"})({position:"relative",overflow:"hidden",width:"100%",objectFit:"contain"}),G=_("div",{target:"e1dr6u8s1"})(({theme:e,width:a})=>({backgroundColor:e.colors.secondaryBg,borderRadius:`${e.radii.default} ${e.radii.default} 0 0`,width:"100%",height:a*9/16,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"})),Ve=_("p",{target:"e1dr6u8s2"})(({theme:e})=>({marginTop:e.spacing.sm,textAlign:"center"})),Ae=_("img",{target:"e1dr6u8s3"})(({theme:e,opacity:a})=>({borderRadius:`${e.radii.default} ${e.radii.default} 0 0`,objectFit:"contain",opacity:a})),ze=_("a",{target:"e1dr6u8s4"})(({theme:e})=>({color:e.colors.link,textDecoration:e.linkUnderline?"underline":"none",display:"block"})),$e=_("span",{target:"e1dr6u8s5"})({display:"flex",alignItems:"center"}),Ne=_("div",{target:"e1dr6u8s6"})(({theme:e})=>({position:"absolute",top:e.spacing.lg,right:e.spacing.lg,zIndex:e.zIndices.priority,color:e.colors.fadedText40,mixBlendMode:"difference",opacity:.6})),He=_("div",{target:"e1dr6u8s8"})({height:"fit-content",width:"100%",position:"absolute",bottom:0}),De=_("button",{target:"e1dr6u8s9"})(({theme:e})=>({position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:e.colors.lightenedBg05,border:`${e.sizes.borderWidth} solid ${e.colors.borderColor}`,borderRadius:`0 0 ${e.radii.default} ${e.radii.default}`,"&:hover":{borderColor:e.colors.primary,color:e.colors.primary},"&:active":{color:e.colors.white,borderColor:e.colors.primary,backgroundColor:e.colors.primary},"&:focus:not(:active)":{borderColor:e.colors.primary,color:e.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{color:e.colors.fadedText40,borderColor:e.colors.borderColor,backgroundColor:e.colors.lightenedBg05,cursor:"not-allowed"},fontWeight:e.fontWeights.normal,padding:`${e.spacing.xs} ${e.spacing.md}`,margin:e.spacing.none,lineHeight:e.lineHeights.base,color:"inherit",width:"100%",userSelect:"none","&:focus":{outline:"none"},"&:focus-visible":{boxShadow:he(e)},...Be("medium",e)}));function qe({disabled:e,onClick:a,children:d,progress:g}){return O(De,{disabled:e||!1,onClick:a||(()=>{}),progress:g||null,"data-testid":"stCameraInputButton",children:[d,g?U(He,{children:U(We,{value:g,size:Le.EXTRASMALL,overrides:{Bar:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarProgress:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarContainer:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}}}})}):null]})}const le=n.memo(qe);var V=(function(e){return e.USER="user",e.ENVIRONMENT="environment",e})({});const Ge=({switchFacingMode:e})=>U(Ne,{"data-testid":"stCameraInputSwitchButton",children:U(ge,{content:"Switch camera",placement:ve.TOP_RIGHT,children:U(me,{kind:Se.MINIMAL,onClick:e,children:U(q,{content:oe,size:"twoXL",color:re.white})})})}),Xe=n.memo(Ge);var A={exports:{}},Qe=A.exports,te;function Je(){return te||(te=1,(function(e,a){(function(g,v){e.exports=v(be())})(Qe,function(d){return(function(g){var v={};function p(o){if(v[o])return v[o].exports;var f=v[o]={i:o,l:!1,exports:{}};return g[o].call(f.exports,f,f.exports,p),f.l=!0,f.exports}return p.m=g,p.c=v,p.d=function(o,f,m){p.o(o,f)||Object.defineProperty(o,f,{enumerable:!0,get:m})},p.r=function(o){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},p.t=function(o,f){if(f&1&&(o=p(o)),f&8||f&4&&typeof o=="object"&&o&&o.__esModule)return o;var m=Object.create(null);if(p.r(m),Object.defineProperty(m,"default",{enumerable:!0,value:o}),f&2&&typeof o!="string")for(var F in o)p.d(m,F,(function(I){return o[I]}).bind(null,F));return m},p.n=function(o){var f=o&&o.__esModule?function(){return o.default}:function(){return o};return p.d(f,"a",f),f},p.o=function(o,f){return Object.prototype.hasOwnProperty.call(o,f)},p.p="",p(p.s="./src/react-webcam.tsx")})({"./src/react-webcam.tsx":(function(g,v,p){p.r(v);var o=p("react"),f=(function(){var b=function(i,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var l in s)s.hasOwnProperty(l)&&(r[l]=s[l])},b(i,t)};return function(i,t){b(i,t);function r(){this.constructor=i}i.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}})(),m=function(){return m=Object.assign||function(b){for(var i,t=1,r=arguments.length;t<r;t++){i=arguments[t];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(b[s]=i[s])}return b},m.apply(this,arguments)},F=function(b,i){var t={};for(var r in b)Object.prototype.hasOwnProperty.call(b,r)&&i.indexOf(r)<0&&(t[r]=b[r]);if(b!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(b);s<r.length;s++)i.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(b,r[s])&&(t[r[s]]=b[r[s]]);return t};(function(){typeof window>"u"||(navigator.mediaDevices===void 0&&(navigator.mediaDevices={}),navigator.mediaDevices.getUserMedia===void 0&&(navigator.mediaDevices.getUserMedia=function(i){var t=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return t?new Promise(function(r,s){t.call(navigator,i,r,s)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}))})();function I(){return!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)}var R=(function(b){f(i,b);function i(t){var r=b.call(this,t)||this;return r.canvas=null,r.ctx=null,r.requestUserMediaId=0,r.unmounted=!1,r.state={hasUserMedia:!1},r}return i.prototype.componentDidMount=function(){var t=this,r=t.state,s=t.props;if(this.unmounted=!1,!I()){s.onUserMediaError("getUserMedia not supported");return}r.hasUserMedia||this.requestUserMedia(),s.children&&typeof s.children!="function"&&console.warn("children must be a function")},i.prototype.componentDidUpdate=function(t){var r=this.props;if(!I()){r.onUserMediaError("getUserMedia not supported");return}var s=JSON.stringify(t.audioConstraints)!==JSON.stringify(r.audioConstraints),l=JSON.stringify(t.videoConstraints)!==JSON.stringify(r.videoConstraints),M=t.minScreenshotWidth!==r.minScreenshotWidth,y=t.minScreenshotHeight!==r.minScreenshotHeight;(l||M||y)&&(this.canvas=null,this.ctx=null),(s||l)&&(this.stopAndCleanup(),this.requestUserMedia())},i.prototype.componentWillUnmount=function(){this.unmounted=!0,this.stopAndCleanup()},i.stopMediaStream=function(t){t&&(t.getVideoTracks&&t.getAudioTracks?(t.getVideoTracks().map(function(r){t.removeTrack(r),r.stop()}),t.getAudioTracks().map(function(r){t.removeTrack(r),r.stop()})):t.stop())},i.prototype.stopAndCleanup=function(){var t=this.state;t.hasUserMedia&&(i.stopMediaStream(this.stream),t.src&&window.URL.revokeObjectURL(t.src))},i.prototype.getScreenshot=function(t){var r=this,s=r.state,l=r.props;if(!s.hasUserMedia)return null;var M=this.getCanvas(t);return M&&M.toDataURL(l.screenshotFormat,l.screenshotQuality)},i.prototype.getCanvas=function(t){var r=this,s=r.state,l=r.props;if(!this.video||!s.hasUserMedia||!this.video.videoHeight)return null;if(!this.ctx){var M=this.video.videoWidth,y=this.video.videoHeight;if(!this.props.forceScreenshotSourceSize){var C=M/y;M=l.minScreenshotWidth||this.video.clientWidth,y=M/C,l.minScreenshotHeight&&y<l.minScreenshotHeight&&(y=l.minScreenshotHeight,M=y*C)}this.canvas=document.createElement("canvas"),this.canvas.width=t?.width||M,this.canvas.height=t?.height||y,this.ctx=this.canvas.getContext("2d")}var x=this,w=x.ctx,S=x.canvas;return w&&S&&(S.width=t?.width||S.width,S.height=t?.height||S.height,l.mirrored&&(w.translate(S.width,0),w.scale(-1,1)),w.imageSmoothingEnabled=l.imageSmoothing,w.drawImage(this.video,0,0,t?.width||S.width,t?.height||S.height),l.mirrored&&(w.scale(-1,1),w.translate(-S.width,0))),S},i.prototype.requestUserMedia=function(){var t=this,r=this.props,s=function(y,C){var x={video:typeof C<"u"?C:!0};r.audio&&(x.audio=typeof y<"u"?y:!0),t.requestUserMediaId++;var w=t.requestUserMediaId;navigator.mediaDevices.getUserMedia(x).then(function(S){t.unmounted||w!==t.requestUserMediaId?i.stopMediaStream(S):t.handleUserMedia(null,S)}).catch(function(S){t.handleUserMedia(S)})};if("mediaDevices"in navigator)s(r.audioConstraints,r.videoConstraints);else{var l=function(y){return{optional:[{sourceId:y}]}},M=function(y){var C=y.deviceId;return typeof C=="string"?C:Array.isArray(C)&&C.length>0?C[0]:typeof C=="object"&&C.ideal?C.ideal:null};MediaStreamTrack.getSources(function(y){var C=null,x=null;y.forEach(function(P){P.kind==="audio"?C=P.id:P.kind==="video"&&(x=P.id)});var w=M(r.audioConstraints);w&&(C=w);var S=M(r.videoConstraints);S&&(x=S),s(l(C),l(x))})}},i.prototype.handleUserMedia=function(t,r){var s=this.props;if(t||!r){this.setState({hasUserMedia:!1}),s.onUserMediaError(t);return}this.stream=r;try{this.video&&(this.video.srcObject=r),this.setState({hasUserMedia:!0})}catch{this.setState({hasUserMedia:!0,src:window.URL.createObjectURL(r)})}s.onUserMedia(r)},i.prototype.render=function(){var t=this,r=this,s=r.state,l=r.props,M=l.audio;l.forceScreenshotSourceSize;var y=l.disablePictureInPicture;l.onUserMedia,l.onUserMediaError,l.screenshotFormat,l.screenshotQuality,l.minScreenshotWidth,l.minScreenshotHeight,l.audioConstraints,l.videoConstraints,l.imageSmoothing;var C=l.mirrored,x=l.style,w=x===void 0?{}:x,S=l.children,P=F(l,["audio","forceScreenshotSourceSize","disablePictureInPicture","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored","style","children"]),z=C?m(m({},w),{transform:(w.transform||"")+" scaleX(-1)"}):w,j={getScreenshot:this.getScreenshot.bind(this)};return o.createElement(o.Fragment,null,o.createElement("video",m({autoPlay:!0,disablePictureInPicture:y,src:s.src,muted:!M,playsInline:!0,ref:function(B){t.video=B},style:z},P)),S&&S(j))},i.defaultProps={audio:!1,disablePictureInPicture:!1,forceScreenshotSourceSize:!1,imageSmoothing:!0,mirrored:!1,onUserMedia:function(){},onUserMediaError:function(){},screenshotFormat:"image/webp",screenshotQuality:.92},i})(o.Component);v.default=R}),react:(function(g,v){g.exports=d})}).default})})(A)),A.exports}var Ke=Je();const Ye=ye(Ke),Ze=({width:e})=>O(G,{width:e,children:[U(q,{size:"threeXL",color:re.gray60,content:ne}),O(Ve,{children:["This app would like to use your camera.",U(ze,{href:je,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]})]}),et=({handleCapture:e,width:a,disabled:d,clearPhotoInProgress:g,setClearPhotoInProgress:v,facingMode:p,setFacingMode:o,testOverride:f})=>{const[m,F]=n.useState(f||"pending"),I=n.useRef(null),[R,b]=n.useState(a),i=n.useCallback(Ce(1e3,b),[]);n.useEffect(()=>{i(a)},[a,i]);function t(){if(I.current!==null){const s=I.current.getScreenshot();e(s)}}const r=Ue();return O(se,{"data-testid":"stCameraInputWebcamComponent",children:[m!=="success"&&!d&&!g?U(Ze,{width:R}):we()&&U(Xe,{switchFacingMode:o}),U(G,{"data-testid":"stCameraInputWebcamStyledBox",hidden:m!=="success"&&!d&&!g,width:R,children:!d&&U(Ye,{audio:!1,ref:I,screenshotFormat:"image/jpeg",screenshotQuality:1,width:R,height:R*9/16,style:{borderRadius:`${r.radii.default} ${r.radii.default} 0 0`},onUserMediaError:()=>{F("error")},onUserMedia:()=>{F("success"),v(!1)},videoConstraints:{width:{ideal:R},facingMode:p}})}),U(le,{onClick:t,disabled:m!=="success"||d||g,children:"Take Photo"})]})},tt=n.memo(et),ce="RESTORED_FROM_WIDGET",rt=150,it=xe.getLogger("CameraInput"),N=e=>{const a=e.filter(d=>d.status.type==="uploaded").map(d=>{const{name:g,size:v,status:p}=d,{fileId:o,fileUrls:f}=p;return new Oe({fileId:o,fileUrls:f,name:g,size:v})});return new ke({uploadedFileInfo:a})},ot=(e,a)=>{const d=a.getFileUploaderStateValue(e);if(L(d))return{files:[],nextLocalId:1,imgSrc:null};const{uploadedFileInfo:g}=d;if(L(g)||g.length===0)return{files:[],nextLocalId:1,imgSrc:null};let v=1;const p=g.map(o=>{const f=o.name,m=o.size,F=o.fileId,I=o.fileUrls,R=new ie(f,m,v,{type:"uploaded",fileId:F,fileUrls:I});return v+=1,R});return{files:p,nextLocalId:v,imgSrc:p.length>0?ce:null}};function nt(e,a){return fetch(e).then(d=>d.arrayBuffer()).then(d=>new File([d],a,{type:"image/jpeg"}))}const at=({element:e,widgetMgr:a,uploadClient:d,disabled:g,fragmentId:v,testOverride:p})=>{const{width:o,elementRef:f}=Me(),m=n.useRef(null);m.current===null&&(m.current=ot(e,a));const{files:F,nextLocalId:I,imgSrc:R}=m.current,b=n.useRef(I),[i,t]=n.useState(()=>F),r=n.useRef(i);n.useLayoutEffect(()=>{r.current=i},[i]);const[s,l]=n.useState(()=>R),[M,y]=n.useState(!1),[C,x]=n.useState(!0),[w,S]=n.useState(!1),[P,z]=n.useState(V.USER),j=n.useCallback(()=>{const c=b.current;return b.current+=1,c},[]),B=n.useMemo(()=>{const c=u=>u.status.type==="uploading";return i.some(c)?"updating":"ready"},[i]),$=n.useMemo(()=>{if(i.length>0&&i[i.length-1].status.type==="uploading")return i[i.length-1].status.progress},[i]),de=n.useCallback(()=>{z(c=>c===V.USER?V.ENVIRONMENT:V.USER)},[]),k=n.useCallback(c=>r.current.find(u=>u.id===c),[]),X=n.useCallback(c=>{Ee.flushSync(()=>{t(u=>[...u,c])})},[]),Q=n.useCallback(c=>{t(u=>u.filter(h=>h.id!==c))},[]),T=n.useCallback((c,u)=>{t(h=>h.map(E=>E.id===c?u:E))},[]),J=n.useCallback((c,u)=>{y(!1);const h=k(c);L(h)||h.status.type!=="uploading"||T(h.id,h.setStatus({type:"uploaded",fileId:u.fileId,fileUrls:u}))},[k,T]),K=n.useCallback((c,u)=>{const h=k(u);if(L(h)||h.status.type!=="uploading")return;const E=Math.round(c.loaded*100/c.total);h.status.progress!==E&&T(u,h.setStatus({type:"uploading",abortController:h.status.abortController,progress:E}))},[k,T]),Y=n.useCallback((c,u)=>{const h=new AbortController,E=new ie(u.name,u.size,j(),{type:"uploading",abortController:h,progress:1});X(E),d.uploadFile(e,c.uploadUrl,u,W=>K(W,E.id),h.signal).then(()=>J(E.id,c)).catch(W=>{W instanceof DOMException&&W.name==="AbortError"||T(E.id,E.setStatus({type:"error",errorMessage:W?W.toString():"Unknown error"}))})},[X,e,j,J,K,T,d]),Z=n.useCallback(c=>{const u=k(c);L(u)||(u.status.type==="uploading"&&u.status.abortController.abort(),u.status.type==="uploaded"&&u.status.fileUrls.deleteUrl&&d.deleteFile(u.status.fileUrls.deleteUrl),Q(c))},[k,Q,d]),ee=n.useCallback(c=>{if(c===null)return Promise.resolve();l(c),y(!0),x(!1);const u=h=>new Promise(E=>setTimeout(E,h));return nt(c,`camera-input-${new Date().toISOString().replace(/:/g,"_")}.jpg`).then(h=>d.fetchFileURLs([h]).then(E=>({file:h,fileUrls:E[0]}))).then(({file:h,fileUrls:E})=>Y(E,h)).then(()=>u(rt)).then(()=>{x(!0)}).catch(h=>{it.error(h)})},[d,Y]),ue=n.useCallback(c=>{ee(c)},[ee]),fe=n.useCallback(()=>{i.length!==0&&(i.forEach(c=>Z(c.id)),l(null),S(!0))},[i,Z]);n.useEffect(()=>{a.getFileUploaderStateValue(e)===void 0&&a.setFileUploaderStateValue(e,N(i),{fromUi:!1},v)},[]),n.useEffect(()=>{if(B!=="ready")return;const c=N(i),u=a.getFileUploaderStateValue(e);Ie(c,u)||a.setFileUploaderStateValue(e,c,{fromUi:!0},v)},[B,i,a,e,v]);const pe=n.useCallback(()=>{t([]),l(null);const c=N([]);a.setFileUploaderStateValue(e,c,{fromUi:!0},v)},[e,v,a]);return Te({element:e,widgetMgr:a,onFormCleared:pe}),O(se,{className:"stCameraInput","data-testid":"stCameraInput",ref:f,children:[U(_e,{label:e.label,disabled:g,labelVisibility:Fe(e.labelVisibility?.value),children:e.help&&U(Re,{content:e.help,label:e.label})}),s?O(Pe,{children:[U(G,{width:o,children:s!==ce&&U(Ae,{src:s,alt:"Snapshot",opacity:M||!C?"50%":"100%",width:o,height:o*9/16})}),U(le,{onClick:fe,progress:$,disabled:!!$||g,children:$?"Uploading...":O($e,{children:[U(q,{content:ae,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):U(tt,{handleCapture:ue,width:o,disabled:g,clearPhotoInProgress:w,setClearPhotoInProgress:S,facingMode:P,setFacingMode:de,testOverride:p})]})},ft=n.memo(at);export{ft as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{X as f,a7 as p,B as i,r as l,u as h,j as o,a as S,b as F,c as I,D as R,d as C,a8 as M}from"./index.
|
|
1
|
+
import{X as f,a7 as p,B as i,r as l,u as h,j as o,a as S,b as F,c as I,D as R,d as C,a8 as M}from"./index.DSTThs-t.js";import{a9 as D}from"./index.DSTThs-t.js";import{m as x}from"./iconPosition.7Qt6oUiI.js";import{F as E,u as O}from"./FormClearHelper.CA_5b-Ut.js";function y(a){const{disabled:d,element:t,widgetMgr:e,fragmentId:u}=a,{formId:s}=t,m=t.shortcut?t.shortcut:void 0,{formsData:B}=f(p),b=B.formsWithUploads.has(s);let n=i.SECONDARY_FORM_SUBMIT;t.type==="primary"?n=i.PRIMARY_FORM_SUBMIT:t.type==="tertiary"&&(n=i.TERTIARY_FORM_SUBMIT);const r=d||b;l.useEffect(()=>(e.addSubmitButton(s,t),()=>e.removeSubmitButton(s,t)),[e,s,t]);const c=l.useCallback(()=>{r||e.submitForm(t.formId,u,t)},[r,e,t,u]);return h({shortcut:m,disabled:r,onActivate:c}),o(C,{className:"stFormSubmitButton","data-testid":"stFormSubmitButton",children:o(S,{help:t.help,containerWidth:!0,children:o(F,{kind:n,size:I.SMALL,containerWidth:!0,disabled:r,onClick:c,children:o(R,{icon:t.icon,iconPosition:x(t.iconPosition),label:t.label,shortcut:m})})})})}function _(a){return o(M,{children:o(y,{...a})})}export{E as FormClearHelper,y as FormSubmitButton,_ as FormSubmitContent,D as default,O as useFormClearHelper};
|