streamlit-nightly 1.46.2.dev20250708__py3-none-any.whl → 1.46.2.dev20250710__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/elements/vega_charts.py +8 -0
- streamlit/elements/widgets/chat.py +35 -5
- streamlit/runtime/secrets.py +4 -8
- streamlit/static/index.html +1 -1
- streamlit/static/manifest.json +214 -214
- streamlit/static/static/js/{ErrorOutline.esm.CO5UETnI.js → ErrorOutline.esm.DcxmqjUD.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.BodlLZ2E.js → FileDownload.esm.jHGWeFoc.js} +1 -1
- streamlit/static/static/js/{FileHelper.BJWG5mWZ.js → FileHelper.Zrnryqu0.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.Bfl6Fb0k.js → FormClearHelper.BYxFNamA.js} +1 -1
- streamlit/static/static/js/{Hooks.BZNasbgB.js → Hooks.Bf489OB5.js} +1 -1
- streamlit/static/static/js/{InputInstructions.D9_advjq.js → InputInstructions.BOAAgTvb.js} +1 -1
- streamlit/static/static/js/{ProgressBar.BOxvIdHT.js → ProgressBar.CHyAN4g4.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.B-maQ3lr.js → RenderInPortalIfExists.BnEeVRFq.js} +1 -1
- streamlit/static/static/js/{Toolbar.BulWrSVh.js → Toolbar.CXl8zpFb.js} +1 -1
- streamlit/static/static/js/{base-input.oeeD4NYL.js → base-input.Df0b6Qry.js} +1 -1
- streamlit/static/static/js/{checkbox.BqkhIzEX.js → checkbox._czeraZi.js} +1 -1
- streamlit/static/static/js/{createSuper.bxk9uEsc.js → createSuper.ZqMAxMzx.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.BFUaa7qj.js → data-grid-overlay-editor.Bok03B1i.js} +1 -1
- streamlit/static/static/js/{downloader.CkJ9l-mW.js → downloader.C4jTgaKc.js} +1 -1
- streamlit/static/static/js/{es6.CwBeRZxt.js → es6.Do-e8HO9.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.B4xDykub.js → iframeResizer.contentWindow.mWYZgJrl.js} +1 -1
- streamlit/static/static/js/{index.CFoM9W4u.js → index.-qN84VXE.js} +1 -1
- streamlit/static/static/js/{index.um9CUbiU.js → index.35y_AzR4.js} +1 -1
- streamlit/static/static/js/{index.FerMd1cU.js → index.B1l9OvXj.js} +1 -1
- streamlit/static/static/js/index.BF_sb0WL.js +73 -0
- streamlit/static/static/js/{index.BHzjJ3JF.js → index.BIEGVO6Q.js} +5 -5
- streamlit/static/static/js/{index.DQXLgrs8.js → index.BPbIttLy.js} +1 -1
- streamlit/static/static/js/{index.BffMV8Pv.js → index.BVdmv4f9.js} +1 -1
- streamlit/static/static/js/{index.zT8XLZtx.js → index.BnBtCCi7.js} +1 -1
- streamlit/static/static/js/{index.D3TXItBH.js → index.Bys870gz.js} +1 -1
- streamlit/static/static/js/{index.DgSLJq20.js → index.BzF3lrfB.js} +1 -1
- streamlit/static/static/js/{index.Bejef4Pk.js → index.C3rroFP9.js} +3 -3
- streamlit/static/static/js/{index.D4WIU5V6.js → index.CF7mP-ZJ.js} +1 -1
- streamlit/static/static/js/{index.B0vAXwMf.js → index.Ca2H30nP.js} +1 -1
- streamlit/static/static/js/{index.BNmqvLux.js → index.Ci7nbB2g.js} +1 -1
- streamlit/static/static/js/{index.aAeBp5Oj.js → index.CjIM7ERG.js} +1 -1
- streamlit/static/static/js/{index.BAyahmk4.js → index.CoYJofEx.js} +1 -1
- streamlit/static/static/js/{index.BPKHA8Id.js → index.CqLB334S.js} +1 -1
- streamlit/static/static/js/{index.DFRMOZ8C.js → index.DFXciakO.js} +173 -173
- streamlit/static/static/js/{index.BGGyfLIH.js → index.DGHrEEt1.js} +1 -1
- streamlit/static/static/js/{index.VY0EoknV.js → index.DHdGt5Y8.js} +1 -1
- streamlit/static/static/js/{index.C795t44A.js → index.DLiM-whD.js} +1 -1
- streamlit/static/static/js/{index.BdnKKSPg.js → index.DTxuG-7x.js} +1 -1
- streamlit/static/static/js/{index.JlbLrYBv.js → index.D_0R5OBc.js} +7 -7
- streamlit/static/static/js/{index.CIeZ4fAx.js → index.DcO57awd.js} +1 -1
- streamlit/static/static/js/{index.CL4vTLmN.js → index.DmGoE186.js} +1 -1
- streamlit/static/static/js/{index.BTHnpf1I.js → index.DmjIEMLZ.js} +1 -1
- streamlit/static/static/js/{index.CfqX1ZBe.js → index.DsGIFS7a.js} +1 -1
- streamlit/static/static/js/{index.D-8V3tc4.js → index.GgXBejJs.js} +1 -1
- streamlit/static/static/js/{index.Ba65H8D9.js → index.MiKM7bk8.js} +1 -1
- streamlit/static/static/js/{index.BP1DQKkm.js → index.QaE_KRXJ.js} +1 -1
- streamlit/static/static/js/{index.BypmpIBL.js → index.dGEV5Rcv.js} +1 -1
- streamlit/static/static/js/{index.B6ClyDWN.js → index.eyf91ITY.js} +1 -1
- streamlit/static/static/js/{index.Dl-ChXDk.js → index.fAtLaEj3.js} +1 -1
- streamlit/static/static/js/{index.oJk4Ge1s.js → index.kBQMwU6d.js} +1 -1
- streamlit/static/static/js/{index.BxVKLNUY.js → index.mvbBbK3q.js} +1 -1
- streamlit/static/static/js/{index.CIEFJvy6.js → index.rOGHN7Ug.js} +1 -1
- streamlit/static/static/js/{index.CGqm8hCs.js → index.rvtw60Rz.js} +1 -1
- streamlit/static/static/js/{input.C3tznRn_.js → input.CbSNLKWI.js} +1 -1
- streamlit/static/static/js/{memory.OHbOX5Ru.js → memory.jXCvhbgc.js} +1 -1
- streamlit/static/static/js/{mergeWith._KN0v5Xp.js → mergeWith.DrPpfkW2.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.BKok-OUE.js → number-overlay-editor.DcUxabQJ.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.BfCdE8Gx.js → possibleConstructorReturn.CzPR4xGM.js} +1 -1
- streamlit/static/static/js/{sandbox.BeWP76j9.js → sandbox.Bd0m3BOh.js} +1 -1
- streamlit/static/static/js/{timepicker.C8LfA2ZU.js → timepicker.CpLBXuBk.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.BHlwNsw4.js → toConsumableArray.D_piEkI9.js} +1 -1
- streamlit/static/static/js/{uniqueId.Ds4mfmXu.js → uniqueId.wDqRFq8o.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.Ds5amAnj.js → useBasicWidgetState.rpbnEZqG.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.CnPrmPV-.js → useOnInputChange.DLCh37tX.js} +1 -1
- streamlit/static/static/js/{useTextInputAutoExpand.DRi3Jfhk.js → useTextInputAutoExpand.Ba7vlWvW.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.DtwYvNjS.js → withFullScreenWrapper.Cqo3BmOl.js} +1 -1
- streamlit/watcher/event_based_path_watcher.py +3 -2
- streamlit/watcher/polling_path_watcher.py +2 -1
- {streamlit_nightly-1.46.2.dev20250708.dist-info → streamlit_nightly-1.46.2.dev20250710.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.46.2.dev20250708.dist-info → streamlit_nightly-1.46.2.dev20250710.dist-info}/RECORD +79 -79
- streamlit/static/static/js/index.D-sXGL7m.js +0 -73
- {streamlit_nightly-1.46.2.dev20250708.data → streamlit_nightly-1.46.2.dev20250710.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.46.2.dev20250708.dist-info → streamlit_nightly-1.46.2.dev20250710.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.46.2.dev20250708.dist-info → streamlit_nightly-1.46.2.dev20250710.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.46.2.dev20250708.dist-info → streamlit_nightly-1.46.2.dev20250710.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
|
|
1
|
-
import{s as H,r as a,aP as U,z as k,cu as S,C as B,j as n,br as j,bH as O,bs as _,b9 as K,bt as $,D as q,cv as w}from"./index.
|
1
|
+
import{s as H,r as a,aP as U,z as k,cu as S,C as B,j as n,br as j,bH as O,bs as _,b9 as K,bt as $,D as q,cv as w}from"./index.D_0R5OBc.js";import{u as A}from"./uniqueId.wDqRFq8o.js";import{u as G,a as N,b as J}from"./useOnInputChange.DLCh37tX.js";import{a as M}from"./useBasicWidgetState.rpbnEZqG.js";import{I as Q}from"./InputInstructions.BOAAgTvb.js";import{I as X}from"./input.CbSNLKWI.js";import"./inputUtils.CptNuJwn.js";import"./FormClearHelper.BYxFNamA.js";import"./base-input.Df0b6Qry.js";const Y=H("div",{target:"e1o1zy6o0"})("position:relative;");function Z({disabled:o,element:t,widgetMgr:s,fragmentId:u}){const[r,c]=a.useState(()=>W(s,t)??null),[T,y]=U(),[i,p]=a.useState(!1),x=a.useCallback(()=>{c(t.default??null),p(!0)},[t.default]),[V,m]=M({getStateFromWidgetMgr:W,getDefaultStateFromProto:tt,getCurrStateFromProto:et,updateWidgetMgrState:ot,element:t,widgetMgr:s,fragmentId:u,onFormCleared:x});G(V,r,c,i);const[C,g]=a.useState(!1),e=k(),[f]=a.useState(()=>A("text_input_")),{placeholder:F,formId:l,icon:d,maxChars:b}=t,h=a.useCallback(()=>{p(!1),m({value:r,fromUi:!0})},[r,m]),v=S({formId:l})?s.allowFormEnterToSubmit(l):i,z=C&&T>e.breakpoints.hideWidgetDetails,E=a.useCallback(()=>{i&&h(),g(!1)},[i,h]),P=a.useCallback(()=>{g(!0)},[]),R=N({formId:l,maxChars:b,setDirty:p,setUiValue:c,setValueWithSource:m}),L=J(l,h,i,s,u),I=d?.startsWith(":material"),D=I?"lg":"base";return B(Y,{className:"stTextInput","data-testid":"stTextInput",ref:y,children:[n($,{label:t.label,disabled:o,labelVisibility:j(t.labelVisibility?.value),htmlFor:f,children:t.help&&n(O,{children:n(_,{content:t.help,placement:K.TOP_RIGHT})})}),n(X,{value:r??"",placeholder:F,onBlur:E,onFocus:P,onChange:R,onKeyPress:L,"aria-label":t.label,disabled:o,id:f,type:at(t),autoComplete:t.autocomplete,startEnhancer:d&&n(q,{"data-testid":"stTextInputIcon",iconValue:d,size:D}),overrides:{Input:{style:{fontWeight:e.fontWeights.normal,minWidth:0,lineHeight:e.lineHeights.inputWidget,paddingRight:e.spacing.sm,paddingLeft:e.spacing.md,paddingBottom:e.spacing.sm,paddingTop:e.spacing.sm,"::placeholder":{color:e.colors.fadedText60}}},Root:{props:{"data-testid":"stTextInputRootElement"},style:{height:e.sizes.minElementHeight,borderLeftWidth:e.sizes.borderWidth,borderRightWidth:e.sizes.borderWidth,borderTopWidth:e.sizes.borderWidth,borderBottomWidth:e.sizes.borderWidth,paddingLeft:d?e.spacing.sm:0}},StartEnhancer:{style:{paddingLeft:0,paddingRight:0,minWidth:e.iconSizes.lg,color:I?e.colors.fadedText60:"inherit"}}}}),z&&n(Q,{dirty:i,value:r??"",maxLength:b,inForm:S({formId:l}),allowEnterToSubmit:v})]})}function W(o,t){return o.getStringValue(t)??null}function tt(o){return o.default??null}function et(o){return o.value??null}function ot(o,t,s,u){t.setStringValue(o,s.value,{fromUi:s.fromUi},u)}function at(o){return o.type===w.Type.PASSWORD?"password":"text"}const mt=a.memo(Z);export{mt as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{r as y,E as T,_ as O,s as I,J,C as F,j as f,bu as Q,b9 as L,bp as K,b4 as Y,bo as W,bC as B,d as Z,g as ee,aO as te,z as re,bD as ie,bE as oe,bF as ne,l as ae,aE as se,M as P,bG as z,bl as le,bk as de,br as ce,bH as ue,bs as he,bt as pe,F as fe}from"./index.JlbLrYBv.js";import{F as ge}from"./FormClearHelper.Bfl6Fb0k.js";import{U as k}from"./UploadFileInfo.C-jY39rj.js";import{P as me,S as ve}from"./ProgressBar.BOxvIdHT.js";var $=y.forwardRef(function(i,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(T,O({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},i,{ref:l}),y.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"}))});$.displayName="Video";var A=y.forwardRef(function(i,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(T,O({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},i,{ref:l}),y.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"}))});A.displayName="X";var N=y.forwardRef(function(i,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(T,O({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},i,{ref:l}),y.createElement("rect",{width:24,height:24,fill:"none"}),y.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"}))});N.displayName="SwitchCamera";function Se(i,l){switch(i){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 H=I("div",{target:"etzmx8d0"})({position:"relative",overflow:"hidden",width:"100%",objectFit:"contain"}),V=I("div",{target:"etzmx8d1"})(({theme:i,width:l})=>({backgroundColor:i.colors.secondaryBg,borderRadius:`${i.radii.default} ${i.radii.default} 0 0`,width:"100%",height:l*9/16,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"})),ye=I("p",{target:"etzmx8d2"})(({theme:i})=>({marginTop:i.spacing.sm,textAlign:"center"})),be=I("img",{target:"etzmx8d3"})(({theme:i,opacity:l})=>({borderRadius:`${i.radii.default} ${i.radii.default} 0 0`,objectFit:"contain",opacity:l})),Ce=I("a",{target:"etzmx8d4"})(({theme:i})=>({color:i.colors.link,textDecoration:i.linkUnderline?"underline":"none",display:"block"})),Me=I("span",{target:"etzmx8d5"})({display:"flex",alignItems:"center"}),we=I("div",{target:"etzmx8d6"})(({theme:i})=>({position:"absolute",top:i.spacing.lg,right:i.spacing.lg,zIndex:i.zIndices.priority,color:i.colors.fadedText40,mixBlendMode:"difference",opacity:.6})),Ue=I("div",{target:"etzmx8d8"})({height:"fit-content",width:"100%",position:"absolute",bottom:0}),Ie=I("button",{target:"etzmx8d9"})(({theme:i})=>({position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:i.colors.lightenedBg05,border:`${i.sizes.borderWidth} solid ${i.colors.borderColor}`,borderRadius:`0 0 ${i.radii.default} ${i.radii.default}`,"&:hover":{borderColor:i.colors.primary,color:i.colors.primary},"&:active":{color:i.colors.white,borderColor:i.colors.primary,backgroundColor:i.colors.primary},"&:focus:not(:active)":{borderColor:i.colors.primary,color:i.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{color:i.colors.fadedText40,borderColor:i.colors.borderColor,backgroundColor:i.colors.lightenedBg05,cursor:"not-allowed"},fontWeight:i.fontWeights.normal,padding:`${i.spacing.xs} ${i.spacing.md}`,margin:i.spacing.none,lineHeight:i.lineHeights.base,color:"inherit",width:"100%",userSelect:"none","&:focus":{outline:"none"},"&:focus-visible":{boxShadow:`0 0 0 0.2rem ${J(i.colors.primary,.5)}`},...Se("medium",i)}));function Ee({disabled:i,onClick:l,children:t,progress:n}){return F(Ie,{disabled:i||!1,onClick:l||(()=>{}),progress:n||null,"data-testid":"stCameraInputButton",children:[t,n?f(Ue,{children:f(me,{value:n,size:ve.EXTRASMALL,overrides:{Bar:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarProgress:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarContainer:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}}}})}):null]})}const D=y.memo(Ee);var R=function(i){return i.USER="user",i.ENVIRONMENT="environment",i}({});const Fe=({switchFacingMode:i})=>f(we,{"data-testid":"stCameraInputSwitchButton",children:f(Q,{content:"Switch camera",placement:L.TOP_RIGHT,children:f(K,{kind:Y.MINIMAL,onClick:i,children:f(W,{content:N,size:"twoXL",color:B.white})})})}),xe=y.memo(Fe);var _={exports:{}},Pe=_.exports,j;function Re(){return j||(j=1,function(i,l){(function(n,o){i.exports=o(Z())})(Pe,function(t){return function(n){var o={};function a(s){if(o[s])return o[s].exports;var h=o[s]={i:s,l:!1,exports:{}};return n[s].call(h.exports,h,h.exports,a),h.l=!0,h.exports}return a.m=n,a.c=o,a.d=function(s,h,g){a.o(s,h)||Object.defineProperty(s,h,{enumerable:!0,get:g})},a.r=function(s){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},a.t=function(s,h){if(h&1&&(s=a(s)),h&8||h&4&&typeof s=="object"&&s&&s.__esModule)return s;var g=Object.create(null);if(a.r(g),Object.defineProperty(g,"default",{enumerable:!0,value:s}),h&2&&typeof s!="string")for(var U in s)a.d(g,U,(function(w){return s[w]}).bind(null,U));return g},a.n=function(s){var h=s&&s.__esModule?function(){return s.default}:function(){return s};return a.d(h,"a",h),h},a.o=function(s,h){return Object.prototype.hasOwnProperty.call(s,h)},a.p="",a(a.s="./src/react-webcam.tsx")}({"./src/react-webcam.tsx":function(n,o,a){a.r(o);var s=a("react"),h=function(){var m=function(u,e){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,d){r.__proto__=d}||function(r,d){for(var c in d)d.hasOwnProperty(c)&&(r[c]=d[c])},m(u,e)};return function(u,e){m(u,e);function r(){this.constructor=u}u.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}}(),g=function(){return g=Object.assign||function(m){for(var u,e=1,r=arguments.length;e<r;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 r in m)Object.prototype.hasOwnProperty.call(m,r)&&u.indexOf(r)<0&&(e[r]=m[r]);if(m!=null&&typeof Object.getOwnPropertySymbols=="function")for(var d=0,r=Object.getOwnPropertySymbols(m);d<r.length;d++)u.indexOf(r[d])<0&&Object.prototype.propertyIsEnumerable.call(m,r[d])&&(e[r[d]]=m[r[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(r,d){e.call(navigator,u,r,d)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}))})();function w(){return!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)}var E=function(m){h(u,m);function u(e){var r=m.call(this,e)||this;return r.canvas=null,r.ctx=null,r.requestUserMediaId=0,r.unmounted=!1,r.state={hasUserMedia:!1},r}return u.prototype.componentDidMount=function(){var e=this,r=e.state,d=e.props;if(this.unmounted=!1,!w()){d.onUserMediaError("getUserMedia not supported");return}r.hasUserMedia||this.requestUserMedia(),d.children&&typeof d.children!="function"&&console.warn("children must be a function")},u.prototype.componentDidUpdate=function(e){var r=this.props;if(!w()){r.onUserMediaError("getUserMedia not supported");return}var d=JSON.stringify(e.audioConstraints)!==JSON.stringify(r.audioConstraints),c=JSON.stringify(e.videoConstraints)!==JSON.stringify(r.videoConstraints),C=e.minScreenshotWidth!==r.minScreenshotWidth,S=e.minScreenshotHeight!==r.minScreenshotHeight;(c||C||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(r){e.removeTrack(r),r.stop()}),e.getAudioTracks().map(function(r){e.removeTrack(r),r.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 r=this,d=r.state,c=r.props;if(!d.hasUserMedia)return null;var C=this.getCanvas(e);return C&&C.toDataURL(c.screenshotFormat,c.screenshotQuality)},u.prototype.getCanvas=function(e){var r=this,d=r.state,c=r.props;if(!this.video||!d.hasUserMedia||!this.video.videoHeight)return null;if(!this.ctx){var C=this.video.videoWidth,S=this.video.videoHeight;if(!this.props.forceScreenshotSourceSize){var v=C/S;C=c.minScreenshotWidth||this.video.clientWidth,S=C/v,c.minScreenshotHeight&&S<c.minScreenshotHeight&&(S=c.minScreenshotHeight,C=S*v)}this.canvas=document.createElement("canvas"),this.canvas.width=e?.width||C,this.canvas.height=e?.height||S,this.ctx=this.canvas.getContext("2d")}var M=this,b=M.ctx,p=M.canvas;return b&&p&&(p.width=e?.width||p.width,p.height=e?.height||p.height,c.mirrored&&(b.translate(p.width,0),b.scale(-1,1)),b.imageSmoothingEnabled=c.imageSmoothing,b.drawImage(this.video,0,0,e?.width||p.width,e?.height||p.height),c.mirrored&&(b.scale(-1,1),b.translate(-p.width,0))),p},u.prototype.requestUserMedia=function(){var e=this,r=this.props,d=function(S,v){var M={video:typeof v<"u"?v:!0};r.audio&&(M.audio=typeof S<"u"?S:!0),e.requestUserMediaId++;var b=e.requestUserMediaId;navigator.mediaDevices.getUserMedia(M).then(function(p){e.unmounted||b!==e.requestUserMediaId?u.stopMediaStream(p):e.handleUserMedia(null,p)}).catch(function(p){e.handleUserMedia(p)})};if("mediaDevices"in navigator)d(r.audioConstraints,r.videoConstraints);else{var c=function(S){return{optional:[{sourceId:S}]}},C=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,M=null;S.forEach(function(x){x.kind==="audio"?v=x.id:x.kind==="video"&&(M=x.id)});var b=C(r.audioConstraints);b&&(v=b);var p=C(r.videoConstraints);p&&(M=p),d(c(v),c(M))})}},u.prototype.handleUserMedia=function(e,r){var d=this.props;if(e||!r){this.setState({hasUserMedia:!1}),d.onUserMediaError(e);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)})}d.onUserMedia(r)},u.prototype.render=function(){var e=this,r=this,d=r.state,c=r.props,C=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,M=c.style,b=M===void 0?{}:M,p=c.children,x=U(c,["audio","forceScreenshotSourceSize","disablePictureInPicture","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored","style","children"]),G=v?g(g({},b),{transform:(b.transform||"")+" scaleX(-1)"}):b,q={getScreenshot:this.getScreenshot.bind(this)};return s.createElement(s.Fragment,null,s.createElement("video",g({autoPlay:!0,disablePictureInPicture:S,src:d.src,muted:!C,playsInline:!0,ref:function(X){e.video=X},style:G},x)),p&&p(q))},u.defaultProps={audio:!1,disablePictureInPicture:!1,forceScreenshotSourceSize:!1,imageSmoothing:!0,mirrored:!1,onUserMedia:function(){},onUserMediaError:function(){},screenshotFormat:"image/webp",screenshotQuality:.92},u}(s.Component);o.default=E},react:function(n,o){n.exports=t}}).default})}(_)),_.exports}var _e=Re();const Te=ee(_e),Oe=({width:i})=>F(V,{width:i,children:[f(W,{size:"threeXL",color:B.gray60,content:$}),F(ye,{children:["This app would like to use your camera.",f(Ce,{href:oe,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]})]}),We=({handleCapture:i,width:l,disabled:t,clearPhotoInProgress:n,setClearPhotoInProgress:o,facingMode:a,setFacingMode:s,testOverride:h})=>{const[g,U]=y.useState(h||"pending"),w=y.useRef(null),[E,m]=y.useState(l),u=y.useCallback(te(1e3,m),[]);y.useEffect(()=>{u(l)},[l,u]);function e(){if(w.current!==null){const d=w.current.getScreenshot();i(d)}}const r=re();return F(H,{"data-testid":"stCameraInputWebcamComponent",children:[g!=="success"&&!t&&!n?f(Oe,{width:E}):ie()&&f(xe,{switchFacingMode:s}),f(V,{"data-testid":"stCameraInputWebcamStyledBox",hidden:g!=="success"&&!t&&!n,width:E,children:!t&&f(Te,{audio:!1,ref:w,screenshotFormat:"image/jpeg",screenshotQuality:1,width:E,height:E*9/16,style:{borderRadius:`${r.radii.default} ${r.radii.default} 0 0`},onUserMediaError:()=>{U("error")},onUserMedia:()=>{U("success"),o(!1)},videoConstraints:{width:{ideal:E},facingMode:a}})}),f(D,{onClick:e,disabled:g!=="success"||t||n,children:"Take Photo"})]})},Ve=y.memo(We),ze=150,ke=ae.getLogger("CameraInput");class je extends y.PureComponent{constructor(l){super(l),this.localFileIdCounter=1,this.RESTORED_FROM_WIDGET_STRING="RESTORED_FROM_WIDGET",this.formClearHelper=new ge,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=t=>{this.setState({clearPhotoInProgress:t})},this.setFacingMode=()=>{this.setState(t=>({facingMode:t.facingMode===R.USER?R.ENVIRONMENT:R.USER}))},this.handleCapture=t=>{if(t===null)return Promise.resolve();this.setState({imgSrc:t,shutter:!0,minShutterEffectPassed:!1});const n=o=>new Promise(a=>setTimeout(a,o));return Le(t,`camera-input-${new Date().toISOString().replace(/:/g,"_")}.jpg`).then(o=>this.props.uploadClient.fetchFileURLs([o]).then(a=>({file:o,fileUrls:a[0]}))).then(({file:o,fileUrls:a})=>this.uploadFile(a,o)).then(()=>n(ze)).then(()=>{this.setState((o,a)=>({imgSrc:t,shutter:o.shutter,minShutterEffectPassed:!0}))}).catch(o=>{ke.error(o)})},this.removeCapture=()=>{this.state.files.length!==0&&(this.state.files.forEach(t=>this.deleteFile(t.id)),this.setState({imgSrc:null,clearPhotoInProgress:!0}))},this.componentDidUpdate=()=>{if(this.status!=="ready")return;const t=this.createWidgetValue(),{element:n,widgetMgr:o,fragmentId:a}=this.props,s=o.getFileUploaderStateValue(n);se(t,s)||o.setFileUploaderStateValue(n,t,{fromUi:!0},a)},this.onFormCleared=()=>{this.setState({files:[]},()=>{const t=this.createWidgetValue();if(P(t))return;this.setState({imgSrc:null});const{widgetMgr:n,element:o,fragmentId:a}=this.props;n.setFileUploaderStateValue(o,t,{fromUi:!0},a)})},this.deleteFile=t=>{const n=this.getFile(t);P(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(t))},this.addFile=t=>{this.setState(n=>({files:[...n.files,t]}))},this.removeFile=t=>{this.setState(n=>({files:n.files.filter(o=>o.id!==t)}))},this.getFile=t=>this.state.files.find(n=>n.id===t),this.updateFile=(t,n)=>{this.setState(o=>({files:o.files.map(a=>a.id===t?n:a)}))},this.onUploadComplete=(t,n)=>{this.setState(()=>({shutter:!1}));const o=this.getFile(t);P(o)||o.status.type!=="uploading"||this.updateFile(o.id,o.setStatus({type:"uploaded",fileId:n.fileId,fileUrls:n}))},this.onUploadProgress=(t,n)=>{const o=this.getFile(n);if(P(o)||o.status.type!=="uploading")return;const a=Math.round(t.loaded*100/t.total);o.status.progress!==a&&this.updateFile(n,o.setStatus({type:"uploading",cancelToken:o.status.cancelToken,progress:a}))},this.reset=()=>{this.setState({files:[],imgSrc:null})},this.uploadFile=(t,n)=>{const o=z.CancelToken.source(),a=new k(n.name,n.size,this.nextLocalFileId(),{type:"uploading",cancelToken:o,progress:1});this.addFile(a),this.props.uploadClient.uploadFile(this.props.element,t.uploadUrl,n,s=>this.onUploadProgress(s,a.id),o.token).then(()=>this.onUploadComplete(a.id,t)).catch(s=>{z.isCancel(s)||this.updateFile(a.id,a.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:R.USER},{widgetMgr:t,element:n}=this.props,o=t.getFileUploaderStateValue(n);if(P(o))return l;const{uploadedFileInfo:a}=o;return P(a)||a.length===0?l:{files:a.map(s=>{const h=s.name,g=s.size,U=s.fileId,w=s.fileUrls;return new k(h,g,this.nextLocalFileId(),{type:"uploaded",fileId:U,fileUrls:w})}),imgSrc:a.length===0?"":this.RESTORED_FROM_WIDGET_STRING,shutter:!1,minShutterEffectPassed:!1,clearPhotoInProgress:!1,facingMode:R.USER}}componentWillUnmount(){this.formClearHelper.disconnect()}get status(){const l=t=>t.status.type==="uploading";return this.state.files.some(l)?"updating":"ready"}componentDidMount(){const l=this.createWidgetValue(),{element:t,widgetMgr:n,fragmentId:o}=this.props;n.getFileUploaderStateValue(t)===void 0&&n.setFileUploaderStateValue(t,l,{fromUi:!1},o)}createWidgetValue(){const l=this.state.files.filter(t=>t.status.type==="uploaded").map(t=>{const{name:n,size:o,status:a}=t;return new le({fileId:a.fileId,fileUrls:a.fileUrls,name:n,size:o})});return new de({uploadedFileInfo:l})}render(){const{element:l,widgetMgr:t,disabled:n,width:o}=this.props;return this.formClearHelper.manageFormClearListener(t,l.formId,this.onFormCleared),F(H,{className:"stCameraInput","data-testid":"stCameraInput",children:[f(pe,{label:l.label,disabled:n,labelVisibility:ce(l.labelVisibility?.value),children:l.help&&f(ue,{children:f(he,{content:l.help,placement:L.TOP_RIGHT})})}),this.state.imgSrc?F(fe,{children:[f(V,{width:o,children:this.state.imgSrc!==this.RESTORED_FROM_WIDGET_STRING&&f(be,{src:this.state.imgSrc,alt:"Snapshot",opacity:this.state.shutter||!this.state.minShutterEffectPassed?"50%":"100%",width:o,height:o*9/16})}),f(D,{onClick:this.removeCapture,progress:this.getProgress(),disabled:!!this.getProgress()||n,children:this.getProgress()?"Uploading...":F(Me,{children:[f(W,{content:A,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):f(Ve,{handleCapture:this.handleCapture,width:o,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 Le(i,l){return fetch(i).then(t=>t.arrayBuffer()).then(t=>new File([t],l,{type:"image/jpeg"}))}const He=ne(je);export{He as default};
|
1
|
+
import{r as y,E as T,_ as O,s as I,J,C as F,j as f,bu as Q,b9 as L,bp as K,b4 as Y,bo as W,bC as B,d as Z,g as ee,aO as te,z as re,bD as ie,bE as oe,bF as ne,l as ae,aE as se,M as P,bG as z,bl as le,bk as de,br as ce,bH as ue,bs as he,bt as pe,F as fe}from"./index.D_0R5OBc.js";import{F as ge}from"./FormClearHelper.BYxFNamA.js";import{U as k}from"./UploadFileInfo.C-jY39rj.js";import{P as me,S as ve}from"./ProgressBar.CHyAN4g4.js";var $=y.forwardRef(function(i,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(T,O({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},i,{ref:l}),y.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"}))});$.displayName="Video";var A=y.forwardRef(function(i,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(T,O({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},i,{ref:l}),y.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"}))});A.displayName="X";var N=y.forwardRef(function(i,l){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return y.createElement(T,O({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},i,{ref:l}),y.createElement("rect",{width:24,height:24,fill:"none"}),y.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"}))});N.displayName="SwitchCamera";function Se(i,l){switch(i){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 H=I("div",{target:"etzmx8d0"})({position:"relative",overflow:"hidden",width:"100%",objectFit:"contain"}),V=I("div",{target:"etzmx8d1"})(({theme:i,width:l})=>({backgroundColor:i.colors.secondaryBg,borderRadius:`${i.radii.default} ${i.radii.default} 0 0`,width:"100%",height:l*9/16,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"})),ye=I("p",{target:"etzmx8d2"})(({theme:i})=>({marginTop:i.spacing.sm,textAlign:"center"})),be=I("img",{target:"etzmx8d3"})(({theme:i,opacity:l})=>({borderRadius:`${i.radii.default} ${i.radii.default} 0 0`,objectFit:"contain",opacity:l})),Ce=I("a",{target:"etzmx8d4"})(({theme:i})=>({color:i.colors.link,textDecoration:i.linkUnderline?"underline":"none",display:"block"})),Me=I("span",{target:"etzmx8d5"})({display:"flex",alignItems:"center"}),we=I("div",{target:"etzmx8d6"})(({theme:i})=>({position:"absolute",top:i.spacing.lg,right:i.spacing.lg,zIndex:i.zIndices.priority,color:i.colors.fadedText40,mixBlendMode:"difference",opacity:.6})),Ue=I("div",{target:"etzmx8d8"})({height:"fit-content",width:"100%",position:"absolute",bottom:0}),Ie=I("button",{target:"etzmx8d9"})(({theme:i})=>({position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:i.colors.lightenedBg05,border:`${i.sizes.borderWidth} solid ${i.colors.borderColor}`,borderRadius:`0 0 ${i.radii.default} ${i.radii.default}`,"&:hover":{borderColor:i.colors.primary,color:i.colors.primary},"&:active":{color:i.colors.white,borderColor:i.colors.primary,backgroundColor:i.colors.primary},"&:focus:not(:active)":{borderColor:i.colors.primary,color:i.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{color:i.colors.fadedText40,borderColor:i.colors.borderColor,backgroundColor:i.colors.lightenedBg05,cursor:"not-allowed"},fontWeight:i.fontWeights.normal,padding:`${i.spacing.xs} ${i.spacing.md}`,margin:i.spacing.none,lineHeight:i.lineHeights.base,color:"inherit",width:"100%",userSelect:"none","&:focus":{outline:"none"},"&:focus-visible":{boxShadow:`0 0 0 0.2rem ${J(i.colors.primary,.5)}`},...Se("medium",i)}));function Ee({disabled:i,onClick:l,children:t,progress:n}){return F(Ie,{disabled:i||!1,onClick:l||(()=>{}),progress:n||null,"data-testid":"stCameraInputButton",children:[t,n?f(Ue,{children:f(me,{value:n,size:ve.EXTRASMALL,overrides:{Bar:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarProgress:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarContainer:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}}}})}):null]})}const D=y.memo(Ee);var R=function(i){return i.USER="user",i.ENVIRONMENT="environment",i}({});const Fe=({switchFacingMode:i})=>f(we,{"data-testid":"stCameraInputSwitchButton",children:f(Q,{content:"Switch camera",placement:L.TOP_RIGHT,children:f(K,{kind:Y.MINIMAL,onClick:i,children:f(W,{content:N,size:"twoXL",color:B.white})})})}),xe=y.memo(Fe);var _={exports:{}},Pe=_.exports,j;function Re(){return j||(j=1,function(i,l){(function(n,o){i.exports=o(Z())})(Pe,function(t){return function(n){var o={};function a(s){if(o[s])return o[s].exports;var h=o[s]={i:s,l:!1,exports:{}};return n[s].call(h.exports,h,h.exports,a),h.l=!0,h.exports}return a.m=n,a.c=o,a.d=function(s,h,g){a.o(s,h)||Object.defineProperty(s,h,{enumerable:!0,get:g})},a.r=function(s){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},a.t=function(s,h){if(h&1&&(s=a(s)),h&8||h&4&&typeof s=="object"&&s&&s.__esModule)return s;var g=Object.create(null);if(a.r(g),Object.defineProperty(g,"default",{enumerable:!0,value:s}),h&2&&typeof s!="string")for(var U in s)a.d(g,U,(function(w){return s[w]}).bind(null,U));return g},a.n=function(s){var h=s&&s.__esModule?function(){return s.default}:function(){return s};return a.d(h,"a",h),h},a.o=function(s,h){return Object.prototype.hasOwnProperty.call(s,h)},a.p="",a(a.s="./src/react-webcam.tsx")}({"./src/react-webcam.tsx":function(n,o,a){a.r(o);var s=a("react"),h=function(){var m=function(u,e){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,d){r.__proto__=d}||function(r,d){for(var c in d)d.hasOwnProperty(c)&&(r[c]=d[c])},m(u,e)};return function(u,e){m(u,e);function r(){this.constructor=u}u.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}}(),g=function(){return g=Object.assign||function(m){for(var u,e=1,r=arguments.length;e<r;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 r in m)Object.prototype.hasOwnProperty.call(m,r)&&u.indexOf(r)<0&&(e[r]=m[r]);if(m!=null&&typeof Object.getOwnPropertySymbols=="function")for(var d=0,r=Object.getOwnPropertySymbols(m);d<r.length;d++)u.indexOf(r[d])<0&&Object.prototype.propertyIsEnumerable.call(m,r[d])&&(e[r[d]]=m[r[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(r,d){e.call(navigator,u,r,d)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}))})();function w(){return!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)}var E=function(m){h(u,m);function u(e){var r=m.call(this,e)||this;return r.canvas=null,r.ctx=null,r.requestUserMediaId=0,r.unmounted=!1,r.state={hasUserMedia:!1},r}return u.prototype.componentDidMount=function(){var e=this,r=e.state,d=e.props;if(this.unmounted=!1,!w()){d.onUserMediaError("getUserMedia not supported");return}r.hasUserMedia||this.requestUserMedia(),d.children&&typeof d.children!="function"&&console.warn("children must be a function")},u.prototype.componentDidUpdate=function(e){var r=this.props;if(!w()){r.onUserMediaError("getUserMedia not supported");return}var d=JSON.stringify(e.audioConstraints)!==JSON.stringify(r.audioConstraints),c=JSON.stringify(e.videoConstraints)!==JSON.stringify(r.videoConstraints),C=e.minScreenshotWidth!==r.minScreenshotWidth,S=e.minScreenshotHeight!==r.minScreenshotHeight;(c||C||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(r){e.removeTrack(r),r.stop()}),e.getAudioTracks().map(function(r){e.removeTrack(r),r.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 r=this,d=r.state,c=r.props;if(!d.hasUserMedia)return null;var C=this.getCanvas(e);return C&&C.toDataURL(c.screenshotFormat,c.screenshotQuality)},u.prototype.getCanvas=function(e){var r=this,d=r.state,c=r.props;if(!this.video||!d.hasUserMedia||!this.video.videoHeight)return null;if(!this.ctx){var C=this.video.videoWidth,S=this.video.videoHeight;if(!this.props.forceScreenshotSourceSize){var v=C/S;C=c.minScreenshotWidth||this.video.clientWidth,S=C/v,c.minScreenshotHeight&&S<c.minScreenshotHeight&&(S=c.minScreenshotHeight,C=S*v)}this.canvas=document.createElement("canvas"),this.canvas.width=e?.width||C,this.canvas.height=e?.height||S,this.ctx=this.canvas.getContext("2d")}var M=this,b=M.ctx,p=M.canvas;return b&&p&&(p.width=e?.width||p.width,p.height=e?.height||p.height,c.mirrored&&(b.translate(p.width,0),b.scale(-1,1)),b.imageSmoothingEnabled=c.imageSmoothing,b.drawImage(this.video,0,0,e?.width||p.width,e?.height||p.height),c.mirrored&&(b.scale(-1,1),b.translate(-p.width,0))),p},u.prototype.requestUserMedia=function(){var e=this,r=this.props,d=function(S,v){var M={video:typeof v<"u"?v:!0};r.audio&&(M.audio=typeof S<"u"?S:!0),e.requestUserMediaId++;var b=e.requestUserMediaId;navigator.mediaDevices.getUserMedia(M).then(function(p){e.unmounted||b!==e.requestUserMediaId?u.stopMediaStream(p):e.handleUserMedia(null,p)}).catch(function(p){e.handleUserMedia(p)})};if("mediaDevices"in navigator)d(r.audioConstraints,r.videoConstraints);else{var c=function(S){return{optional:[{sourceId:S}]}},C=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,M=null;S.forEach(function(x){x.kind==="audio"?v=x.id:x.kind==="video"&&(M=x.id)});var b=C(r.audioConstraints);b&&(v=b);var p=C(r.videoConstraints);p&&(M=p),d(c(v),c(M))})}},u.prototype.handleUserMedia=function(e,r){var d=this.props;if(e||!r){this.setState({hasUserMedia:!1}),d.onUserMediaError(e);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)})}d.onUserMedia(r)},u.prototype.render=function(){var e=this,r=this,d=r.state,c=r.props,C=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,M=c.style,b=M===void 0?{}:M,p=c.children,x=U(c,["audio","forceScreenshotSourceSize","disablePictureInPicture","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored","style","children"]),G=v?g(g({},b),{transform:(b.transform||"")+" scaleX(-1)"}):b,q={getScreenshot:this.getScreenshot.bind(this)};return s.createElement(s.Fragment,null,s.createElement("video",g({autoPlay:!0,disablePictureInPicture:S,src:d.src,muted:!C,playsInline:!0,ref:function(X){e.video=X},style:G},x)),p&&p(q))},u.defaultProps={audio:!1,disablePictureInPicture:!1,forceScreenshotSourceSize:!1,imageSmoothing:!0,mirrored:!1,onUserMedia:function(){},onUserMediaError:function(){},screenshotFormat:"image/webp",screenshotQuality:.92},u}(s.Component);o.default=E},react:function(n,o){n.exports=t}}).default})}(_)),_.exports}var _e=Re();const Te=ee(_e),Oe=({width:i})=>F(V,{width:i,children:[f(W,{size:"threeXL",color:B.gray60,content:$}),F(ye,{children:["This app would like to use your camera.",f(Ce,{href:oe,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]})]}),We=({handleCapture:i,width:l,disabled:t,clearPhotoInProgress:n,setClearPhotoInProgress:o,facingMode:a,setFacingMode:s,testOverride:h})=>{const[g,U]=y.useState(h||"pending"),w=y.useRef(null),[E,m]=y.useState(l),u=y.useCallback(te(1e3,m),[]);y.useEffect(()=>{u(l)},[l,u]);function e(){if(w.current!==null){const d=w.current.getScreenshot();i(d)}}const r=re();return F(H,{"data-testid":"stCameraInputWebcamComponent",children:[g!=="success"&&!t&&!n?f(Oe,{width:E}):ie()&&f(xe,{switchFacingMode:s}),f(V,{"data-testid":"stCameraInputWebcamStyledBox",hidden:g!=="success"&&!t&&!n,width:E,children:!t&&f(Te,{audio:!1,ref:w,screenshotFormat:"image/jpeg",screenshotQuality:1,width:E,height:E*9/16,style:{borderRadius:`${r.radii.default} ${r.radii.default} 0 0`},onUserMediaError:()=>{U("error")},onUserMedia:()=>{U("success"),o(!1)},videoConstraints:{width:{ideal:E},facingMode:a}})}),f(D,{onClick:e,disabled:g!=="success"||t||n,children:"Take Photo"})]})},Ve=y.memo(We),ze=150,ke=ae.getLogger("CameraInput");class je extends y.PureComponent{constructor(l){super(l),this.localFileIdCounter=1,this.RESTORED_FROM_WIDGET_STRING="RESTORED_FROM_WIDGET",this.formClearHelper=new ge,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=t=>{this.setState({clearPhotoInProgress:t})},this.setFacingMode=()=>{this.setState(t=>({facingMode:t.facingMode===R.USER?R.ENVIRONMENT:R.USER}))},this.handleCapture=t=>{if(t===null)return Promise.resolve();this.setState({imgSrc:t,shutter:!0,minShutterEffectPassed:!1});const n=o=>new Promise(a=>setTimeout(a,o));return Le(t,`camera-input-${new Date().toISOString().replace(/:/g,"_")}.jpg`).then(o=>this.props.uploadClient.fetchFileURLs([o]).then(a=>({file:o,fileUrls:a[0]}))).then(({file:o,fileUrls:a})=>this.uploadFile(a,o)).then(()=>n(ze)).then(()=>{this.setState((o,a)=>({imgSrc:t,shutter:o.shutter,minShutterEffectPassed:!0}))}).catch(o=>{ke.error(o)})},this.removeCapture=()=>{this.state.files.length!==0&&(this.state.files.forEach(t=>this.deleteFile(t.id)),this.setState({imgSrc:null,clearPhotoInProgress:!0}))},this.componentDidUpdate=()=>{if(this.status!=="ready")return;const t=this.createWidgetValue(),{element:n,widgetMgr:o,fragmentId:a}=this.props,s=o.getFileUploaderStateValue(n);se(t,s)||o.setFileUploaderStateValue(n,t,{fromUi:!0},a)},this.onFormCleared=()=>{this.setState({files:[]},()=>{const t=this.createWidgetValue();if(P(t))return;this.setState({imgSrc:null});const{widgetMgr:n,element:o,fragmentId:a}=this.props;n.setFileUploaderStateValue(o,t,{fromUi:!0},a)})},this.deleteFile=t=>{const n=this.getFile(t);P(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(t))},this.addFile=t=>{this.setState(n=>({files:[...n.files,t]}))},this.removeFile=t=>{this.setState(n=>({files:n.files.filter(o=>o.id!==t)}))},this.getFile=t=>this.state.files.find(n=>n.id===t),this.updateFile=(t,n)=>{this.setState(o=>({files:o.files.map(a=>a.id===t?n:a)}))},this.onUploadComplete=(t,n)=>{this.setState(()=>({shutter:!1}));const o=this.getFile(t);P(o)||o.status.type!=="uploading"||this.updateFile(o.id,o.setStatus({type:"uploaded",fileId:n.fileId,fileUrls:n}))},this.onUploadProgress=(t,n)=>{const o=this.getFile(n);if(P(o)||o.status.type!=="uploading")return;const a=Math.round(t.loaded*100/t.total);o.status.progress!==a&&this.updateFile(n,o.setStatus({type:"uploading",cancelToken:o.status.cancelToken,progress:a}))},this.reset=()=>{this.setState({files:[],imgSrc:null})},this.uploadFile=(t,n)=>{const o=z.CancelToken.source(),a=new k(n.name,n.size,this.nextLocalFileId(),{type:"uploading",cancelToken:o,progress:1});this.addFile(a),this.props.uploadClient.uploadFile(this.props.element,t.uploadUrl,n,s=>this.onUploadProgress(s,a.id),o.token).then(()=>this.onUploadComplete(a.id,t)).catch(s=>{z.isCancel(s)||this.updateFile(a.id,a.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:R.USER},{widgetMgr:t,element:n}=this.props,o=t.getFileUploaderStateValue(n);if(P(o))return l;const{uploadedFileInfo:a}=o;return P(a)||a.length===0?l:{files:a.map(s=>{const h=s.name,g=s.size,U=s.fileId,w=s.fileUrls;return new k(h,g,this.nextLocalFileId(),{type:"uploaded",fileId:U,fileUrls:w})}),imgSrc:a.length===0?"":this.RESTORED_FROM_WIDGET_STRING,shutter:!1,minShutterEffectPassed:!1,clearPhotoInProgress:!1,facingMode:R.USER}}componentWillUnmount(){this.formClearHelper.disconnect()}get status(){const l=t=>t.status.type==="uploading";return this.state.files.some(l)?"updating":"ready"}componentDidMount(){const l=this.createWidgetValue(),{element:t,widgetMgr:n,fragmentId:o}=this.props;n.getFileUploaderStateValue(t)===void 0&&n.setFileUploaderStateValue(t,l,{fromUi:!1},o)}createWidgetValue(){const l=this.state.files.filter(t=>t.status.type==="uploaded").map(t=>{const{name:n,size:o,status:a}=t;return new le({fileId:a.fileId,fileUrls:a.fileUrls,name:n,size:o})});return new de({uploadedFileInfo:l})}render(){const{element:l,widgetMgr:t,disabled:n,width:o}=this.props;return this.formClearHelper.manageFormClearListener(t,l.formId,this.onFormCleared),F(H,{className:"stCameraInput","data-testid":"stCameraInput",children:[f(pe,{label:l.label,disabled:n,labelVisibility:ce(l.labelVisibility?.value),children:l.help&&f(ue,{children:f(he,{content:l.help,placement:L.TOP_RIGHT})})}),this.state.imgSrc?F(fe,{children:[f(V,{width:o,children:this.state.imgSrc!==this.RESTORED_FROM_WIDGET_STRING&&f(be,{src:this.state.imgSrc,alt:"Snapshot",opacity:this.state.shutter||!this.state.minShutterEffectPassed?"50%":"100%",width:o,height:o*9/16})}),f(D,{onClick:this.removeCapture,progress:this.getProgress(),disabled:!!this.getProgress()||n,children:this.getProgress()?"Uploading...":F(Me,{children:[f(W,{content:A,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):f(Ve,{handleCapture:this.handleCapture,width:o,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 Le(i,l){return fetch(i).then(t=>t.arrayBuffer()).then(t=>new File([t],l,{type:"image/jpeg"}))}const He=ne(je);export{He as default};
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import{bv as _,bO as ye,bw as $,r as u,z as $e,C as ne,j as R,bz as Re,bs as Oe,b9 as _e,bt as Se,aG as oe,H as ie,c9 as ae,br as Pe}from"./index.
|
1
|
+
import{bv as _,bO as ye,bw as $,r as u,z as $e,C as ne,j as R,bz as Re,bs as Oe,b9 as _e,bt as Se,aG as oe,H as ie,c9 as ae,br as Pe}from"./index.D_0R5OBc.js";import{a as we}from"./useBasicWidgetState.rpbnEZqG.js";import"./FormClearHelper.BYxFNamA.js";var se={vertical:"vertical",horizontal:"horizontal"};function le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?le(Object(n),!0).forEach(function(r){O(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):le(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function O(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var E=0,L=1,T=2;function D(e){return e.$isActive?T:e.$isHovered?L:E}function Me(e){var t=e.$theme.colors,n=e.$disabled,r=e.$checked,o=e.$isFocusVisible,i=e.$error;if(n)return t.tickFillDisabled;if(r)if(i)switch(D(e)){case E:return t.tickFillErrorSelected;case L:return t.tickFillErrorSelectedHover;case T:return t.tickFillErrorSelectedHoverActive}else switch(D(e)){case E:return t.tickFillSelected;case L:return t.tickFillSelectedHover;case T:return t.tickFillSelectedHoverActive}else return o?t.borderSelected:i?t.tickBorderError:t.tickBorder;return null}function ke(e){var t=e.$theme.colors;if(e.$disabled)return t.tickMarkFillDisabled;if(e.$checked)return t.tickMarkFill;if(e.$error)switch(D(e)){case E:return t.tickFillError;case L:return t.tickFillErrorHover;case T:return t.tickFillErrorHoverActive}else switch(D(e)){case E:return t.tickFill;case L:return t.tickFillHover;case T:return t.tickFillActive}}function Fe(e){var t=e.$labelPlacement,n=t===void 0?"":t,r=e.$theme,o;switch(n){case"top":o="Bottom";break;case"bottom":o="Top";break;case"left":o=r.direction==="rtl"?"Left":"Right";break;default:case"right":o=r.direction==="rtl"?"Right":"Left";break}var i=r.sizing,s=i.scale300;return O({},"padding".concat(o),s)}function Ie(e){var t=e.$disabled,n=e.$theme,r=n.colors;return t?r.contentSecondary:r.contentPrimary}var q=_("div",function(e){var t=e.$disabled,n=e.$align;return{display:"flex",flexWrap:"wrap",flexDirection:n==="horizontal"?"row":"column",alignItems:n==="horizontal"?"center":"flex-start",cursor:t?"not-allowed":"pointer","-webkit-tap-highlight-color":"transparent"}});q.displayName="RadioGroupRoot";q.displayName="RadioGroupRoot";var X=_("label",function(e){var t,n=e.$disabled,r=e.$hasDescription,o=e.$labelPlacement,i=e.$theme,s=e.$align,a=i.sizing,c=s==="horizontal",p=i.direction==="rtl"?"Left":"Right";return t={flexDirection:o==="top"||o==="bottom"?"column":"row",display:"flex",alignItems:"center",cursor:n?"not-allowed":"pointer",marginTop:a.scale200},O(t,"margin".concat(p),c?a.scale200:null),O(t,"marginBottom",r&&!c?null:a.scale200),t});X.displayName="Root";X.displayName="Root";var K=_("div",function(e){var t=e.$theme,n=t.animation,r=t.sizing;return{backgroundColor:ke(e),borderTopLeftRadius:"50%",borderTopRightRadius:"50%",borderBottomRightRadius:"50%",borderBottomLeftRadius:"50%",height:e.$checked?r.scale200:r.scale550,transitionDuration:n.timing200,transitionTimingFunction:n.easeOutCurve,width:e.$checked?r.scale200:r.scale550}});K.displayName="RadioMarkInner";K.displayName="RadioMarkInner";var J=_("div",function(e){var t=e.$theme,n=t.animation,r=t.sizing;return{alignItems:"center",backgroundColor:Me(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:r.scale700,justifyContent:"center",marginTop:r.scale0,marginRight:r.scale0,marginBottom:r.scale0,marginLeft:r.scale0,outline:"none",verticalAlign:"middle",width:r.scale700,flexShrink:0,transitionDuration:n.timing200,transitionTimingFunction:n.easeOutCurve}});J.displayName="RadioMarkOuter";J.displayName="RadioMarkOuter";var Q=_("div",function(e){var t=e.$theme.typography;return z(z({verticalAlign:"middle"},Fe(e)),{},{color:Ie(e)},t.LabelMedium)});Q.displayName="Label";Q.displayName="Label";var Y=_("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"});Y.displayName="Input";Y.displayName="Input";var Z=_("div",function(e){var t,n=e.$theme,r=e.$align,o=r==="horizontal",i=n.direction==="rtl"?"Right":"Left",s=n.direction==="rtl"?"Left":"Right";return z(z({},n.typography.ParagraphSmall),{},(t={color:n.colors.contentSecondary,cursor:"auto"},O(t,"margin".concat(i),r==="horizontal"?null:n.sizing.scale900),O(t,"margin".concat(s),o?n.sizing.scale200:null),O(t,"maxWidth","240px"),t))});Z.displayName="Description";Z.displayName="Description";function N(e){"@babel/helpers - typeof";return N=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},N(e)}function V(){return V=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},V.apply(this,arguments)}function Ee(e,t){return Ae(e)||xe(e,t)||Te(e,t)||Le()}function Le(){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 Te(e,t){if(e){if(typeof e=="string")return ue(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ue(e,t)}}function ue(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function xe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r=[],o=!0,i=!1,s,a;try{for(n=n.call(e);!(o=(s=n.next()).done)&&(r.push(s.value),!(t&&r.length===t));o=!0);}catch(c){i=!0,a=c}finally{try{!o&&n.return!=null&&n.return()}finally{if(i)throw a}}return r}}function Ae(e){if(Array.isArray(e))return e}function je(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ze(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function De(e,t,n){return t&&ze(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Be(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(r,o){return r.__proto__=o,r},U(e,t)}function Ce(e){var t=Ne();return function(){var r=B(e),o;if(t){var i=B(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return He(this,o)}}function He(e,t){if(t&&(N(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return A(e)}function A(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ne(){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(n){return n.__proto__||Object.getPrototypeOf(n)},B(e)}function j(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var pe=function(e){Be(n,e);var t=Ce(n);function n(){var r;je(this,n);for(var o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=t.call.apply(t,[this].concat(i)),j(A(r),"state",{isFocusVisible:!1,focusedRadioIndex:-1}),j(A(r),"handleFocus",function(a,c){ye(a)&&r.setState({isFocusVisible:!0}),r.setState({focusedRadioIndex:c}),r.props.onFocus&&r.props.onFocus(a)}),j(A(r),"handleBlur",function(a,c){r.state.isFocusVisible!==!1&&r.setState({isFocusVisible:!1}),r.setState({focusedRadioIndex:-1}),r.props.onBlur&&r.props.onBlur(a)}),r}return De(n,[{key:"render",value:function(){var o=this,i=this.props.overrides,s=i===void 0?{}:i,a=$(s.RadioGroupRoot,q),c=Ee(a,2),p=c[0],b=c[1];return u.createElement(p,V({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(f,l){if(!u.isValidElement(f))return null;var d=o.props.value===f.props.value;return u.cloneElement(f,{align:o.props.align,autoFocus:o.props.autoFocus,checked:d,disabled:o.props.disabled||f.props.disabled,error:o.props.error,isFocused:o.state.focusedRadioIndex===l,isFocusVisible:o.state.isFocusVisible,tabIndex:l===0&&!o.props.value||d?"0":"-1",labelPlacement:o.props.labelPlacement,name:o.props.name,onBlur:function(g){return o.handleBlur(g,l)},onFocus:function(g){return o.handleFocus(g,l)},onChange:o.props.onChange,onMouseEnter:o.props.onMouseEnter,onMouseLeave:o.props.onMouseLeave})}))}}]),n}(u.Component);j(pe,"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 G(e){"@babel/helpers - typeof";return G=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},G(e)}function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},y.apply(this,arguments)}function M(e,t){return We(e)||Ge(e,t)||Ue(e,t)||Ve()}function Ve(){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 Ue(e,t){if(e){if(typeof e=="string")return ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ce(e,t)}}function ce(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Ge(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r=[],o=!0,i=!1,s,a;try{for(n=n.call(e);!(o=(s=n.next()).done)&&(r.push(s.value),!(t&&r.length===t));o=!0);}catch(c){i=!0,a=c}finally{try{!o&&n.return!=null&&n.return()}finally{if(i)throw a}}return r}}function We(e){if(Array.isArray(e))return e}function qe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Xe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ke(e,t,n){return t&&Xe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Je(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&&W(e,t)}function W(e,t){return W=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},W(e,t)}function Qe(e){var t=Ze();return function(){var r=C(e),o;if(t){var i=C(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return Ye(this,o)}}function Ye(e,t){if(t&&(G(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 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 C(e){return C=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},C(e)}function F(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function et(e){return e==="top"||e==="left"}function tt(e){return e==="bottom"||e==="right"}var rt=function(t){return t.stopPropagation()},fe=function(e){Je(n,e);var t=Qe(n);function n(){var r;qe(this,n);for(var o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=t.call.apply(t,[this].concat(i)),F(k(r),"state",{isActive:!1,isHovered:!1}),F(k(r),"onMouseEnter",function(a){r.setState({isHovered:!0}),r.props.onMouseEnter&&r.props.onMouseEnter(a)}),F(k(r),"onMouseLeave",function(a){r.setState({isHovered:!1}),r.props.onMouseLeave&&r.props.onMouseLeave(a)}),F(k(r),"onMouseDown",function(a){r.setState({isActive:!0}),r.props.onMouseDown&&r.props.onMouseDown(a)}),F(k(r),"onMouseUp",function(a){r.setState({isActive:!1}),r.props.onMouseUp&&r.props.onMouseUp(a)}),r}return Ke(n,[{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,s=$(i.Root,X),a=M(s,2),c=a[0],p=a[1],b=$(i.Label,Q),f=M(b,2),l=f[0],d=f[1],S=$(i.Input,Y),g=M(S,2),P=g[0],H=g[1],x=$(i.Description,Z),I=M(x,2),v=I[0],h=I[1],m=$(i.RadioMarkInner,K),ee=M(m,2),de=ee[0],he=ee[1],be=$(i.RadioMarkOuter,J),te=M(be,2),ge=te[0],ve=te[1],w={$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},re=u.createElement(l,y({},w,d),this.props.containsInteractiveElement?u.createElement("div",{onClick:function(me){return me.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},w,p),et(this.props.labelPlacement)&&re,u.createElement(ge,y({},w,ve),u.createElement(de,y({},w,he))),u.createElement(P,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:rt,onChange:this.props.onChange,ref:this.props.inputRef,required:this.props.required,tabIndex:this.props.tabIndex,type:"radio",value:this.props.value},w,H)),tt(this.props.labelPlacement)&&re),!!this.props.description&&u.createElement(v,y({},w,h),this.props.description))}}]),n}(u.Component);F(fe,"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 nt(e){const t=parseFloat(e.sizes.checkbox),n=parseFloat(e.spacing.threeXS),r=ie(t.toString()),o=Math.round(r*.375);let i=Math.round(ie((t-n).toString()));return i>=r&&(i-=1),[ae(o,"px"),ae(i,"px")]}function ot({disabled:e,horizontal:t,value:n,onChange:r,options:o,captions:i,label:s,labelVisibility:a,help:c}){const[p,b]=u.useState(n??null);u.useEffect(()=>{n!==p&&b(n??null)},[n]);const f=u.useCallback(v=>{const h=parseInt(v.target.value,10);b(h),r(h)},[r]),l=$e(),d=i.length>0,S=o.length>0,g=S?o:["No options to select."],P=e||!S,H=v=>v==""&&t&&d?" ":v,[x,I]=nt(l);return ne("div",{className:"stRadio","data-testid":"stRadio",children:[R(Se,{label:s,disabled:P,labelVisibility:a,children:c&&R(Re,{children:R(Oe,{content:c,placement:_e.TOP_RIGHT})})}),R(pe,{onChange:f,value:p!==null?p.toString():void 0,disabled:P,align:t?se.horizontal:se.vertical,"aria-label":s,"data-testid":"stRadioGroup",overrides:{RadioGroupRoot:{style:{gap:d?l.spacing.sm:l.spacing.none,minHeight:l.sizes.minElementHeight}}},children:g.map((v,h)=>ne(fe,{value:h.toString(),overrides:{Root:{style:({$isFocusVisible:m})=>({marginBottom:l.spacing.none,marginTop:l.spacing.none,marginRight:d?l.spacing.sm:l.spacing.lg,paddingLeft:l.spacing.none,alignItems:"start",paddingRight:l.spacing.threeXS,backgroundColor:m?l.colors.darkenedBgMix25:""})},RadioMarkOuter:{style:({$checked:m})=>({width:l.sizes.checkbox,height:l.sizes.checkbox,marginTop:"0.35rem",marginRight:l.spacing.none,marginLeft:l.spacing.none,backgroundColor:m&&!P?l.colors.primary:l.colors.fadedText40})},RadioMarkInner:{style:({$checked:m})=>({height:m?x:I,width:m?x:I})},Label:{style:{color:P?l.colors.fadedText40:l.colors.bodyText,position:"relative",top:l.spacing.px}}},children:[R(oe,{source:v,allowHTML:!1,isLabel:!0,largerLabel:!0}),d&&R(oe,{source:H(i[h]),allowHTML:!1,isCaption:!0,isLabel:!0})]},h))})]})}const it=u.memo(ot);function at({disabled:e,element:t,widgetMgr:n,fragmentId:r}){const[o,i]=we({getStateFromWidgetMgr:st,getDefaultStateFromProto:lt,getCurrStateFromProto:ut,updateWidgetMgrState:ct,element:t,widgetMgr:n,fragmentId:r}),s=u.useCallback(d=>{i({value:d,fromUi:!0})},[i]),{horizontal:a,options:c,captions:p,label:b,labelVisibility:f,help:l}=t;return R(it,{label:b,onChange:s,options:c,captions:p,disabled:e,horizontal:a,labelVisibility:Pe(f?.value),value:o??null,help:l})}function st(e,t){return e.getIntValue(t)}function lt(e){return e.default??null}function ut(e){return e.value??null}function ct(e,t,n,r){t.setIntValue(e,n.value??null,{fromUi:n.fromUi},r)}const bt=u.memo(at);export{bt as default};
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{d as Ze,bv as J,r as C,b$ as vt,bO as mt,bw as G,c0 as bt,c1 as yt,s as me,J as Tt,bF as kt,z as Ot,aO as wt,C as Ve,j as re,cr as Rt,br as St,bH as Mt,bs as _t,b9 as $t,bt as Et,S as It,cs as $e}from"./index.JlbLrYBv.js";import{s as ze}from"./sprintf.D7DtBTRn.js";import{a as xt}from"./useBasicWidgetState.Ds5amAnj.js";import"./FormClearHelper.Bfl6Fb0k.js";var se={},H={},ue={},ce={},Ne;function Ie(){if(Ne)return ce;Ne=1,Object.defineProperty(ce,"__esModule",{value:!0}),ce.Direction=void 0;var e;return function(r){r.Right="to right",r.Left="to left",r.Down="to bottom",r.Up="to top"}(e||(ce.Direction=e={})),ce}var Ue;function Ge(){return Ue||(Ue=1,function(e){var r=ue&&ue.__spreadArray||function(i,o,u){if(u||arguments.length===2)for(var v=0,O=o.length,p;v<O;v++)(p||!(v in o))&&(p||(p=Array.prototype.slice.call(o,0,v)),p[v]=o[v]);return i.concat(p||Array.prototype.slice.call(o))};Object.defineProperty(e,"__esModule",{value:!0}),e.isIOS=e.useThumbOverlap=e.assertUnreachable=e.voidFn=e.getTrackBackground=e.replaceAt=e.schd=e.translate=e.getClosestThumbIndex=e.translateThumbs=e.getPaddingAndBorder=e.getMargin=e.checkInitialOverlap=e.checkValuesAgainstBoundaries=e.checkBoundaries=e.isVertical=e.relativeValue=e.normalizeValue=e.isStepDivisible=e.isTouchEvent=e.getStepDecimals=void 0;var a=Ze(),s=Ie(),h=function(i){var o=i.toString().split(".")[1];return o?o.length:0};e.getStepDecimals=h;function S(i){return i.touches&&i.touches.length||i.changedTouches&&i.changedTouches.length}e.isTouchEvent=S;function c(i,o,u){var v=(o-i)/u,O=8,p=Number(v.toFixed(O));return parseInt(p.toString(),10)===p}e.isStepDivisible=c;function f(i,o,u,v,O,p,k){var _=1e11;if(i=Math.round(i*_)/_,!p){var P=k[o-1],x=k[o+1];if(P&&P>i)return P;if(x&&x<i)return x}if(i>v)return v;if(i<u)return u;var U=Math.floor(i*_-u*_)%Math.floor(O*_),z=Math.floor(i*_-Math.abs(U)),W=U===0?i:z/_,B=Math.abs(U/_)<O/2?W:W+O,A=(0,e.getStepDecimals)(O);return parseFloat(B.toFixed(A))}e.normalizeValue=f;function j(i,o,u){return(i-o)/(u-o)}e.relativeValue=j;function F(i){return i===s.Direction.Up||i===s.Direction.Down}e.isVertical=F;function L(i,o,u){if(o>=u)throw new RangeError("min (".concat(o,") is equal/bigger than max (").concat(u,")"));if(i<o)throw new RangeError("value (".concat(i,") is smaller than min (").concat(o,")"));if(i>u)throw new RangeError("value (".concat(i,") is bigger than max (").concat(u,")"))}e.checkBoundaries=L;function $(i,o,u){return i<o?o:i>u?u:i}e.checkValuesAgainstBoundaries=$;function b(i){if(!(i.length<2)&&!i.slice(1).every(function(o,u){return i[u]<=o}))throw new RangeError("values={[".concat(i,"]} needs to be sorted when allowOverlap={false}"))}e.checkInitialOverlap=b;function d(i){var o=window.getComputedStyle(i);return{top:parseInt(o["margin-top"],10),bottom:parseInt(o["margin-bottom"],10),left:parseInt(o["margin-left"],10),right:parseInt(o["margin-right"],10)}}e.getMargin=d;function t(i){var o=window.getComputedStyle(i);return{top:parseInt(o["padding-top"],10)+parseInt(o["border-top-width"],10),bottom:parseInt(o["padding-bottom"],10)+parseInt(o["border-bottom-width"],10),left:parseInt(o["padding-left"],10)+parseInt(o["border-left-width"],10),right:parseInt(o["padding-right"],10)+parseInt(o["border-right-width"],10)}}e.getPaddingAndBorder=t;function n(i,o,u){var v=u?-1:1;i.forEach(function(O,p){return g(O,v*o[p].x,o[p].y)})}e.translateThumbs=n;function l(i,o,u,v){for(var O=0,p=D(i[0],o,u,v),k=1;k<i.length;k++){var _=D(i[k],o,u,v);_<p&&(p=_,O=k)}return O}e.getClosestThumbIndex=l;function g(i,o,u){i.style.transform="translate(".concat(o,"px, ").concat(u,"px)")}e.translate=g;var m=function(i){var o=[],u=null,v=function(){for(var O=[],p=0;p<arguments.length;p++)O[p]=arguments[p];o=O,!u&&(u=requestAnimationFrame(function(){u=null,i.apply(void 0,o)}))};return v};e.schd=m;function y(i,o,u){var v=i.slice(0);return v[o]=u,v}e.replaceAt=y;function E(i){var o=i.values,u=i.colors,v=i.min,O=i.max,p=i.direction,k=p===void 0?s.Direction.Right:p,_=i.rtl,P=_===void 0?!1:_;P&&k===s.Direction.Right?k=s.Direction.Left:P&&s.Direction.Left&&(k=s.Direction.Right);var x=o.slice(0).sort(function(z,W){return z-W}).map(function(z){return(z-v)/(O-v)*100}),U=x.reduce(function(z,W,B){return"".concat(z,", ").concat(u[B]," ").concat(W,"%, ").concat(u[B+1]," ").concat(W,"%")},"");return"linear-gradient(".concat(k,", ").concat(u[0]," 0%").concat(U,", ").concat(u[u.length-1]," 100%)")}e.getTrackBackground=E;function w(){}e.voidFn=w;function R(i){throw new Error("Didn't expect to get here")}e.assertUnreachable=R;var M=function(i,o,u,v,O){O===void 0&&(O=function(k){return k});var p=Math.ceil(r([i],Array.from(i.children),!0).reduce(function(k,_){var P=Math.ceil(_.getBoundingClientRect().width);if(_.innerText&&_.innerText.includes(u)&&_.childElementCount===0){var x=_.cloneNode(!0);x.innerHTML=O(o.toFixed(v)),x.style.visibility="hidden",document.body.appendChild(x),P=Math.ceil(x.getBoundingClientRect().width),document.body.removeChild(x)}return P>k?P:k},i.getBoundingClientRect().width));return p},I=function(i,o,u,v,O,p,k){k===void 0&&(k=function(x){return x});var _=[],P=function(x){var U=M(u[x],v[x],O,p,k),z=o[x].x;o.forEach(function(W,B){var A=W.x,Z=M(u[B],v[B],O,p,k);x!==B&&(z>=A&&z<=A+Z||z+U>=A&&z+U<=A+Z)&&(_.includes(B)||(_.push(x),_.push(B),_=r(r([],_,!0),[x,B],!1),P(B)))})};return P(i),Array.from(new Set(_.sort()))},T=function(i,o,u,v,O,p){v===void 0&&(v=.1),O===void 0&&(O=" - "),p===void 0&&(p=function(B){return B});var k=(0,e.getStepDecimals)(v),_=(0,a.useState)({}),P=_[0],x=_[1],U=(0,a.useState)(p(o[u].toFixed(k))),z=U[0],W=U[1];return(0,a.useEffect)(function(){if(i){var B=i.getThumbs();if(B.length<1)return;var A={},Z=i.getOffsets(),ne=I(u,Z,B,o,O,k,p),le=p(o[u].toFixed(k));if(ne.length){var Q=ne.reduce(function(ee,oe,ge,pe){return ee.length?r(r([],ee,!0),[Z[pe[ge]].x],!1):[Z[pe[ge]].x]},[]);if(Math.min.apply(Math,Q)===Z[u].x){var de=[];ne.forEach(function(ee){de.push(o[ee].toFixed(k))}),le=Array.from(new Set(de.sort(function(ee,oe){return parseFloat(ee)-parseFloat(oe)}))).map(p).join(O);var fe=Math.min.apply(Math,Q),he=Math.max.apply(Math,Q),_e=B[ne[Q.indexOf(he)]].getBoundingClientRect().width;A.left="".concat(Math.abs(fe-(he+_e))/2,"px"),A.transform="translate(-50%, 0)"}else A.visibility="hidden"}W(le),x(A)}},[i,o]),[z,P]};e.useThumbOverlap=T;function D(i,o,u,v){var O=i.getBoundingClientRect(),p=O.left,k=O.top,_=O.width,P=O.height;return F(v)?Math.abs(u-(k+P/2)):Math.abs(o-(p+_/2))}var V=function(){var i,o=((i=navigator.userAgentData)===null||i===void 0?void 0:i.platform)||navigator.platform;return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(o)||navigator.userAgent.includes("Mac")&&"ontouchend"in document};e.isIOS=V}(ue)),ue}var He;function Ct(){if(He)return H;He=1;var e=H&&H.__extends||function(){var $=function(b,d){return $=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(t[l]=n[l])},$(b,d)};return function(b,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");$(b,d);function t(){this.constructor=b}b.prototype=d===null?Object.create(d):(t.prototype=d.prototype,new t)}}(),r=H&&H.__createBinding||(Object.create?function($,b,d,t){t===void 0&&(t=d);var n=Object.getOwnPropertyDescriptor(b,d);(!n||("get"in n?!b.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return b[d]}}),Object.defineProperty($,t,n)}:function($,b,d,t){t===void 0&&(t=d),$[t]=b[d]}),a=H&&H.__setModuleDefault||(Object.create?function($,b){Object.defineProperty($,"default",{enumerable:!0,value:b})}:function($,b){$.default=b}),s=H&&H.__importStar||function($){if($&&$.__esModule)return $;var b={};if($!=null)for(var d in $)d!=="default"&&Object.prototype.hasOwnProperty.call($,d)&&r(b,$,d);return a(b,$),b},h=H&&H.__spreadArray||function($,b,d){if(d||arguments.length===2)for(var t=0,n=b.length,l;t<n;t++)(l||!(t in b))&&(l||(l=Array.prototype.slice.call(b,0,t)),l[t]=b[t]);return $.concat(l||Array.prototype.slice.call(b))};Object.defineProperty(H,"__esModule",{value:!0});var S=s(Ze()),c=Ge(),f=Ie(),j=["ArrowRight","ArrowUp","k","PageUp"],F=["ArrowLeft","ArrowDown","j","PageDown"],L=function($){e(b,$);function b(d){var t=$.call(this,d)||this;if(t.trackRef=S.createRef(),t.thumbRefs=[],t.state={draggedTrackPos:[-1,-1],draggedThumbIndex:-1,thumbZIndexes:new Array(t.props.values.length).fill(0).map(function(n,l){return l}),isChanged:!1,markOffsets:[]},t.getOffsets=function(){var n=t.props,l=n.direction,g=n.values,m=n.min,y=n.max,E=t.trackRef.current;if(!E)return console.warn("No track element found."),[];var w=E.getBoundingClientRect(),R=(0,c.getPaddingAndBorder)(E);return t.getThumbs().map(function(M,I){var T={x:0,y:0},D=M.getBoundingClientRect(),V=(0,c.getMargin)(M);switch(l){case f.Direction.Right:return T.x=(V.left+R.left)*-1,T.y=((D.height-w.height)/2+R.top)*-1,T.x+=w.width*(0,c.relativeValue)(g[I],m,y)-D.width/2,T;case f.Direction.Left:return T.x=(V.right+R.right)*-1,T.y=((D.height-w.height)/2+R.top)*-1,T.x+=w.width-w.width*(0,c.relativeValue)(g[I],m,y)-D.width/2,T;case f.Direction.Up:return T.x=((D.width-w.width)/2+V.left+R.left)*-1,T.y=-R.left,T.y+=w.height-w.height*(0,c.relativeValue)(g[I],m,y)-D.height/2,T;case f.Direction.Down:return T.x=((D.width-w.width)/2+V.left+R.left)*-1,T.y=-R.left,T.y+=w.height*(0,c.relativeValue)(g[I],m,y)-D.height/2,T;default:return(0,c.assertUnreachable)(l)}})},t.getThumbs=function(){return t.trackRef&&t.trackRef.current?Array.from(t.trackRef.current.children).filter(function(n){return n.hasAttribute("aria-valuenow")}):(console.warn("No thumbs found in the track container. Did you forget to pass & spread the `props` param in renderTrack?"),[])},t.getTargetIndex=function(n){return t.getThumbs().findIndex(function(l){return l===n.target||l.contains(n.target)})},t.addTouchEvents=function(n){document.addEventListener("touchmove",t.schdOnTouchMove,{passive:!1}),document.addEventListener("touchend",t.schdOnEnd,{passive:!1}),document.addEventListener("touchcancel",t.schdOnEnd,{passive:!1})},t.addMouseEvents=function(n){document.addEventListener("mousemove",t.schdOnMouseMove),document.addEventListener("mouseup",t.schdOnEnd)},t.onMouseDownTrack=function(n){var l;if(!(n.button!==0||(0,c.isIOS)()))if(n.persist(),n.preventDefault(),t.addMouseEvents(n.nativeEvent),t.props.values.length>1&&t.props.draggableTrack){if(t.thumbRefs.some(function(m){var y;return(y=m.current)===null||y===void 0?void 0:y.contains(n.target)}))return;t.setState({draggedTrackPos:[n.clientX,n.clientY]},function(){return t.onMove(n.clientX,n.clientY)})}else{var g=(0,c.getClosestThumbIndex)(t.thumbRefs.map(function(m){return m.current}),n.clientX,n.clientY,t.props.direction);(l=t.thumbRefs[g].current)===null||l===void 0||l.focus(),t.setState({draggedThumbIndex:g},function(){return t.onMove(n.clientX,n.clientY)})}},t.onResize=function(){(0,c.translateThumbs)(t.getThumbs(),t.getOffsets(),t.props.rtl),t.calculateMarkOffsets()},t.onTouchStartTrack=function(n){var l;if(n.persist(),t.addTouchEvents(n.nativeEvent),t.props.values.length>1&&t.props.draggableTrack){if(t.thumbRefs.some(function(m){var y;return(y=m.current)===null||y===void 0?void 0:y.contains(n.target)}))return;t.setState({draggedTrackPos:[n.touches[0].clientX,n.touches[0].clientY]},function(){return t.onMove(n.touches[0].clientX,n.touches[0].clientY)})}else{var g=(0,c.getClosestThumbIndex)(t.thumbRefs.map(function(m){return m.current}),n.touches[0].clientX,n.touches[0].clientY,t.props.direction);(l=t.thumbRefs[g].current)===null||l===void 0||l.focus(),t.setState({draggedThumbIndex:g},function(){return t.onMove(n.touches[0].clientX,n.touches[0].clientY)})}},t.onMouseOrTouchStart=function(n){if(!t.props.disabled){var l=(0,c.isTouchEvent)(n);if(!(!l&&n.button!==0)){var g=t.getTargetIndex(n);g!==-1&&(l?t.addTouchEvents(n):t.addMouseEvents(n),t.setState({draggedThumbIndex:g,thumbZIndexes:t.state.thumbZIndexes.map(function(m,y){return y===g?Math.max.apply(Math,t.state.thumbZIndexes):m<=t.state.thumbZIndexes[g]?m:m-1})}))}}},t.onMouseMove=function(n){n.preventDefault(),t.onMove(n.clientX,n.clientY)},t.onTouchMove=function(n){n.preventDefault(),t.onMove(n.touches[0].clientX,n.touches[0].clientY)},t.onKeyDown=function(n){var l=t.props,g=l.values,m=l.onChange,y=l.step,E=l.rtl,w=l.direction,R=t.state.isChanged,M=t.getTargetIndex(n.nativeEvent),I=E||w===f.Direction.Left||w===f.Direction.Down?-1:1;M!==-1&&(j.includes(n.key)?(n.preventDefault(),t.setState({draggedThumbIndex:M,isChanged:!0}),m((0,c.replaceAt)(g,M,t.normalizeValue(g[M]+I*(n.key==="PageUp"?y*10:y),M)))):F.includes(n.key)?(n.preventDefault(),t.setState({draggedThumbIndex:M,isChanged:!0}),m((0,c.replaceAt)(g,M,t.normalizeValue(g[M]-I*(n.key==="PageDown"?y*10:y),M)))):n.key==="Tab"?t.setState({draggedThumbIndex:-1},function(){R&&t.fireOnFinalChange()}):R&&t.fireOnFinalChange())},t.onKeyUp=function(n){var l=t.state.isChanged;t.setState({draggedThumbIndex:-1},function(){l&&t.fireOnFinalChange()})},t.onMove=function(n,l){var g=t.state,m=g.draggedThumbIndex,y=g.draggedTrackPos,E=t.props,w=E.direction,R=E.min,M=E.max,I=E.onChange,T=E.values,D=E.step,V=E.rtl;if(m===-1&&y[0]===-1&&y[1]===-1)return null;var i=t.trackRef.current;if(!i)return null;var o=i.getBoundingClientRect(),u=(0,c.isVertical)(w)?o.height:o.width;if(y[0]!==-1&&y[1]!==-1){var v=n-y[0],O=l-y[1],p=0;switch(w){case f.Direction.Right:case f.Direction.Left:p=v/u*(M-R);break;case f.Direction.Down:case f.Direction.Up:p=O/u*(M-R);break;default:(0,c.assertUnreachable)(w)}if(V&&(p*=-1),Math.abs(p)>=D/2){for(var k=0;k<t.thumbRefs.length;k++){if(T[k]===M&&Math.sign(p)===1||T[k]===R&&Math.sign(p)===-1)return;var _=T[k]+p;_>M?p=M-T[k]:_<R&&(p=R-T[k])}for(var P=T.slice(0),k=0;k<t.thumbRefs.length;k++)P=(0,c.replaceAt)(P,k,t.normalizeValue(T[k]+p,k));t.setState({draggedTrackPos:[n,l]}),I(P)}}else{var x=0;switch(w){case f.Direction.Right:x=(n-o.left)/u*(M-R)+R;break;case f.Direction.Left:x=(u-(n-o.left))/u*(M-R)+R;break;case f.Direction.Down:x=(l-o.top)/u*(M-R)+R;break;case f.Direction.Up:x=(u-(l-o.top))/u*(M-R)+R;break;default:(0,c.assertUnreachable)(w)}V&&(x=M+R-x),Math.abs(T[m]-x)>=D/2&&I((0,c.replaceAt)(T,m,t.normalizeValue(x,m)))}},t.normalizeValue=function(n,l){var g=t.props,m=g.min,y=g.max,E=g.step,w=g.allowOverlap,R=g.values;return(0,c.normalizeValue)(n,l,m,y,E,w,R)},t.onEnd=function(n){if(n.preventDefault(),document.removeEventListener("mousemove",t.schdOnMouseMove),document.removeEventListener("touchmove",t.schdOnTouchMove),document.removeEventListener("mouseup",t.schdOnEnd),document.removeEventListener("touchend",t.schdOnEnd),document.removeEventListener("touchcancel",t.schdOnEnd),t.state.draggedThumbIndex===-1&&t.state.draggedTrackPos[0]===-1&&t.state.draggedTrackPos[1]===-1)return null;t.setState({draggedThumbIndex:-1,draggedTrackPos:[-1,-1]},function(){t.fireOnFinalChange()})},t.fireOnFinalChange=function(){t.setState({isChanged:!1});var n=t.props,l=n.onFinalChange,g=n.values;l&&l(g)},t.updateMarkRefs=function(n){if(!n.renderMark){t.numOfMarks=void 0,t.markRefs=void 0;return}t.numOfMarks=(n.max-n.min)/t.props.step,t.markRefs=[];for(var l=0;l<t.numOfMarks+1;l++)t.markRefs[l]=S.createRef()},t.calculateMarkOffsets=function(){if(!(!t.props.renderMark||!t.trackRef||!t.numOfMarks||!t.markRefs||t.trackRef.current===null)){for(var n=window.getComputedStyle(t.trackRef.current),l=parseInt(n.width,10),g=parseInt(n.height,10),m=parseInt(n.paddingLeft,10),y=parseInt(n.paddingTop,10),E=[],w=0;w<t.numOfMarks+1;w++){var R=9999,M=9999;if(t.markRefs[w].current){var I=t.markRefs[w].current.getBoundingClientRect();R=I.height,M=I.width}t.props.direction===f.Direction.Left||t.props.direction===f.Direction.Right?E.push([Math.round(l/t.numOfMarks*w+m-M/2),-Math.round((R-g)/2)]):E.push([Math.round(g/t.numOfMarks*w+y-R/2),-Math.round((M-l)/2)])}t.setState({markOffsets:E})}},d.step===0)throw new Error('"step" property should be a positive number');return t.schdOnMouseMove=(0,c.schd)(t.onMouseMove),t.schdOnTouchMove=(0,c.schd)(t.onTouchMove),t.schdOnEnd=(0,c.schd)(t.onEnd),t.thumbRefs=d.values.map(function(){return S.createRef()}),t.updateMarkRefs(d),t}return b.prototype.componentDidMount=function(){var d=this,t=this.props,n=t.values,l=t.min,g=t.step;this.resizeObserver=window.ResizeObserver?new window.ResizeObserver(this.onResize):{observe:function(){return window.addEventListener("resize",d.onResize)},unobserve:function(){return window.removeEventListener("resize",d.onResize)}},document.addEventListener("touchstart",this.onMouseOrTouchStart,{passive:!1}),document.addEventListener("mousedown",this.onMouseOrTouchStart,{passive:!1}),!this.props.allowOverlap&&(0,c.checkInitialOverlap)(this.props.values),this.props.values.forEach(function(m){return(0,c.checkBoundaries)(m,d.props.min,d.props.max)}),this.resizeObserver.observe(this.trackRef.current),(0,c.translateThumbs)(this.getThumbs(),this.getOffsets(),this.props.rtl),this.calculateMarkOffsets(),n.forEach(function(m){(0,c.isStepDivisible)(l,m,g)||console.warn("The `values` property is in conflict with the current `step`, `min`, and `max` properties. Please provide values that are accessible using the min, max, and step values.")})},b.prototype.componentDidUpdate=function(d,t){var n=this.props,l=n.max,g=n.min,m=n.step,y=n.values,E=n.rtl;(d.max!==l||d.min!==g||d.step!==m)&&this.updateMarkRefs(this.props),(0,c.translateThumbs)(this.getThumbs(),this.getOffsets(),E),(d.max!==l||d.min!==g||d.step!==m||t.markOffsets.length!==this.state.markOffsets.length)&&(this.calculateMarkOffsets(),y.forEach(function(w){(0,c.isStepDivisible)(g,w,m)||console.warn("The `values` property is in conflict with the current `step`, `min`, and `max` properties. Please provide values that are accessible using the min, max, and step values.")}))},b.prototype.componentWillUnmount=function(){var d={passive:!1};document.removeEventListener("mousedown",this.onMouseOrTouchStart,d),document.removeEventListener("mousemove",this.schdOnMouseMove),document.removeEventListener("touchmove",this.schdOnTouchMove),document.removeEventListener("touchstart",this.onMouseOrTouchStart),document.removeEventListener("mouseup",this.schdOnEnd),document.removeEventListener("touchend",this.schdOnEnd),this.resizeObserver.unobserve(this.trackRef.current)},b.prototype.render=function(){var d=this,t=this.props,n=t.label,l=t.labelledBy,g=t.renderTrack,m=t.renderThumb,y=t.renderMark,E=y===void 0?function(){return null}:y,w=t.values,R=t.min,M=t.max,I=t.allowOverlap,T=t.disabled,D=this.state,V=D.draggedThumbIndex,i=D.thumbZIndexes,o=D.markOffsets;return g({props:{style:{transform:"scale(1)",cursor:V>-1?"grabbing":this.props.draggableTrack?(0,c.isVertical)(this.props.direction)?"ns-resize":"ew-resize":w.length===1&&!T?"pointer":"inherit"},onMouseDown:T?c.voidFn:this.onMouseDownTrack,onTouchStart:T?c.voidFn:this.onTouchStartTrack,ref:this.trackRef},isDragged:this.state.draggedThumbIndex>-1,disabled:T,children:h(h([],o.map(function(u,v,O){return E({props:{style:d.props.direction===f.Direction.Left||d.props.direction===f.Direction.Right?{position:"absolute",left:"".concat(u[0],"px"),marginTop:"".concat(u[1],"px")}:{position:"absolute",top:"".concat(u[0],"px"),marginLeft:"".concat(u[1],"px")},key:"mark".concat(v),ref:d.markRefs[v]},index:v})}),!0),w.map(function(u,v){var O=d.state.draggedThumbIndex===v;return m({index:v,value:u,isDragged:O,props:{style:{position:"absolute",zIndex:i[v],cursor:T?"inherit":O?"grabbing":"grab",userSelect:"none",touchAction:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},key:v,tabIndex:T?void 0:0,"aria-valuemax":I?M:w[v+1]||M,"aria-valuemin":I?R:w[v-1]||R,"aria-valuenow":u,draggable:!1,ref:d.thumbRefs[v],"aria-label":n,"aria-labelledby":l,role:"slider",onKeyDown:T?c.voidFn:d.onKeyDown,onKeyUp:T?c.voidFn:d.onKeyUp}})}),!0)})},b.defaultProps={label:"Accessibility label",labelledBy:null,step:1,direction:f.Direction.Right,rtl:!1,disabled:!1,allowOverlap:!1,draggableTrack:!1,min:0,max:100},b}(S.Component);return H.default=L,H}var We;function Dt(){return We||(We=1,function(e){var r=se&&se.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(e,"__esModule",{value:!0}),e.checkValuesAgainstBoundaries=e.relativeValue=e.useThumbOverlap=e.Direction=e.getTrackBackground=e.Range=void 0;var a=r(Ct());e.Range=a.default;var s=Ge();Object.defineProperty(e,"getTrackBackground",{enumerable:!0,get:function(){return s.getTrackBackground}}),Object.defineProperty(e,"useThumbOverlap",{enumerable:!0,get:function(){return s.useThumbOverlap}}),Object.defineProperty(e,"relativeValue",{enumerable:!0,get:function(){return s.relativeValue}}),Object.defineProperty(e,"checkValuesAgainstBoundaries",{enumerable:!0,get:function(){return s.checkValuesAgainstBoundaries}});var h=Ie();Object.defineProperty(e,"Direction",{enumerable:!0,get:function(){return h.Direction}})}(se)),se}var Je=Dt();function qe(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(h){return Object.getOwnPropertyDescriptor(e,h).enumerable})),a.push.apply(a,s)}return a}function ve(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?qe(Object(a),!0).forEach(function(s){Pt(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):qe(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Pt(e,r,a){return r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}var be=J("div",{position:"relative",width:"100%"});be.displayName="Root";be.displayName="Root";be.displayName="StyledRoot";var ye=J("div",function(e){var r=e.$theme,a=e.$value,s=a===void 0?[]:a,h=e.$disabled,S=e.$isDragged,c=r.sizing,f="inherit";return h?f="not-allowed":S?f="grabbing":s.length===1&&(f="pointer"),{paddingTop:c.scale600,paddingBottom:c.scale600,paddingRight:c.scale600,paddingLeft:c.scale600,display:"flex",cursor:f,backgroundColor:r.colors.sliderTrackFill}});ye.displayName="Track";ye.displayName="Track";ye.displayName="StyledTrack";var Te=J("div",function(e){var r=e.$theme,a=e.$value,s=a===void 0?[]:a,h=e.$min,S=e.$max,c=e.$disabled,f=r.colors,j=r.borders,F=r.direction,L=r.borders.useRoundedCorners?j.radius100:0;return{borderTopLeftRadius:L,borderTopRightRadius:L,borderBottomRightRadius:L,borderBottomLeftRadius:L,background:Je.getTrackBackground({values:s,colors:s.length===1?[c?f.borderOpaque:f.primary,c?f.backgroundSecondary:f.borderOpaque]:[c?f.backgroundSecondary:f.borderOpaque,c?f.borderOpaque:f.primary,c?f.backgroundSecondary:f.borderOpaque],min:h||0,max:S||0,rtl:F==="rtl"}),height:"2px",width:"100%",alignSelf:"center",cursor:c?"not-allowed":"inherit"}});Te.displayName="InnerTrack";Te.displayName="InnerTrack";Te.displayName="StyledInnerTrack";var ke=J("div",function(e){return{width:"4px",height:"2px",backgroundColor:e.$theme.colors.backgroundPrimary,marginLeft:"16px"}});ke.displayName="Mark";ke.displayName="Mark";ke.displayName="StyledMark";var Oe=J("div",function(e){return ve(ve({},e.$theme.typography.font200),{},{color:e.$theme.colors.contentPrimary})});Oe.displayName="Tick";Oe.displayName="Tick";Oe.displayName="StyledTick";var we=J("div",function(e){var r=e.$theme,a=r.sizing;return{display:"flex",justifyContent:"space-between",alignItems:"center",paddingRight:a.scale600,paddingLeft:a.scale600,paddingBottom:a.scale400}});we.displayName="TickBar";we.displayName="TickBar";we.displayName="StyledTickBar";var Re=J("div",function(e){var r=e.$theme,a=e.$value,s=a===void 0?[]:a,h=e.$thumbIndex,S=e.$disabled,c=s.length===2&&h===0,f=s.length===2&&h===1;return r.direction==="rtl"&&(f||c)&&(c=!c,f=!f),{height:"24px",width:"24px",borderTopLeftRadius:"24px",borderTopRightRadius:"24px",borderBottomLeftRadius:"24px",borderBottomRightRadius:"24px",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:S?r.colors.sliderHandleFillDisabled:r.colors.sliderHandleFill,outline:"none",boxShadow:e.$isFocusVisible?"0 0 0 3px ".concat(r.colors.accent):"0 1px 4px rgba(0, 0, 0, 0.12)",cursor:S?"not-allowed":"inherit"}});Re.displayName="Thumb";Re.displayName="Thumb";Re.displayName="StyledThumb";var Se=J("div",function(e){var r=e.$disabled,a=e.$theme;return{position:"absolute",top:"-16px",width:"4px",height:"20px",backgroundColor:r?a.colors.sliderHandleFillDisabled:a.colors.sliderHandleInnerFill}});Se.displayName="InnerThumb";Se.displayName="InnerThumb";Se.displayName="StyledInnerThumb";var Me=J("div",function(e){var r=e.$disabled,a=e.$theme;return ve(ve({position:"absolute",top:"-".concat(a.sizing.scale1400)},a.typography.font200),{},{backgroundColor:r?a.colors.sliderHandleFillDisabled:a.colors.sliderHandleInnerFill,color:a.colors.contentInversePrimary,paddingLeft:a.sizing.scale600,paddingRight:a.sizing.scale600,paddingTop:a.sizing.scale500,paddingBottom:a.sizing.scale500,borderBottomLeftRadius:"48px",borderBottomRightRadius:"48px",borderTopLeftRadius:"48px",borderTopRightRadius:"48px",whiteSpace:"nowrap"})});Me.displayName="ThumbValue";Me.displayName="ThumbValue";Me.displayName="StyledThumbValue";function Ke(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(h){return Object.getOwnPropertyDescriptor(e,h).enumerable})),a.push.apply(a,s)}return a}function Bt(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?Ke(Object(a),!0).forEach(function(s){At(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):Ke(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function At(e,r,a){return r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},Y.apply(this,arguments)}function K(e,r){return Vt(e)||jt(e,r)||Ft(e,r)||Lt()}function Lt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
1
|
+
import{d as Ze,bv as J,r as C,b$ as vt,bO as mt,bw as G,c0 as bt,c1 as yt,s as me,J as Tt,bF as kt,z as Ot,aO as wt,C as Ve,j as re,cr as Rt,br as St,bH as Mt,bs as _t,b9 as $t,bt as Et,S as It,cs as $e}from"./index.D_0R5OBc.js";import{s as ze}from"./sprintf.D7DtBTRn.js";import{a as xt}from"./useBasicWidgetState.rpbnEZqG.js";import"./FormClearHelper.BYxFNamA.js";var se={},H={},ue={},ce={},Ne;function Ie(){if(Ne)return ce;Ne=1,Object.defineProperty(ce,"__esModule",{value:!0}),ce.Direction=void 0;var e;return function(r){r.Right="to right",r.Left="to left",r.Down="to bottom",r.Up="to top"}(e||(ce.Direction=e={})),ce}var Ue;function Ge(){return Ue||(Ue=1,function(e){var r=ue&&ue.__spreadArray||function(i,o,u){if(u||arguments.length===2)for(var v=0,O=o.length,p;v<O;v++)(p||!(v in o))&&(p||(p=Array.prototype.slice.call(o,0,v)),p[v]=o[v]);return i.concat(p||Array.prototype.slice.call(o))};Object.defineProperty(e,"__esModule",{value:!0}),e.isIOS=e.useThumbOverlap=e.assertUnreachable=e.voidFn=e.getTrackBackground=e.replaceAt=e.schd=e.translate=e.getClosestThumbIndex=e.translateThumbs=e.getPaddingAndBorder=e.getMargin=e.checkInitialOverlap=e.checkValuesAgainstBoundaries=e.checkBoundaries=e.isVertical=e.relativeValue=e.normalizeValue=e.isStepDivisible=e.isTouchEvent=e.getStepDecimals=void 0;var a=Ze(),s=Ie(),h=function(i){var o=i.toString().split(".")[1];return o?o.length:0};e.getStepDecimals=h;function S(i){return i.touches&&i.touches.length||i.changedTouches&&i.changedTouches.length}e.isTouchEvent=S;function c(i,o,u){var v=(o-i)/u,O=8,p=Number(v.toFixed(O));return parseInt(p.toString(),10)===p}e.isStepDivisible=c;function f(i,o,u,v,O,p,k){var _=1e11;if(i=Math.round(i*_)/_,!p){var P=k[o-1],x=k[o+1];if(P&&P>i)return P;if(x&&x<i)return x}if(i>v)return v;if(i<u)return u;var U=Math.floor(i*_-u*_)%Math.floor(O*_),z=Math.floor(i*_-Math.abs(U)),W=U===0?i:z/_,B=Math.abs(U/_)<O/2?W:W+O,A=(0,e.getStepDecimals)(O);return parseFloat(B.toFixed(A))}e.normalizeValue=f;function j(i,o,u){return(i-o)/(u-o)}e.relativeValue=j;function F(i){return i===s.Direction.Up||i===s.Direction.Down}e.isVertical=F;function L(i,o,u){if(o>=u)throw new RangeError("min (".concat(o,") is equal/bigger than max (").concat(u,")"));if(i<o)throw new RangeError("value (".concat(i,") is smaller than min (").concat(o,")"));if(i>u)throw new RangeError("value (".concat(i,") is bigger than max (").concat(u,")"))}e.checkBoundaries=L;function $(i,o,u){return i<o?o:i>u?u:i}e.checkValuesAgainstBoundaries=$;function b(i){if(!(i.length<2)&&!i.slice(1).every(function(o,u){return i[u]<=o}))throw new RangeError("values={[".concat(i,"]} needs to be sorted when allowOverlap={false}"))}e.checkInitialOverlap=b;function d(i){var o=window.getComputedStyle(i);return{top:parseInt(o["margin-top"],10),bottom:parseInt(o["margin-bottom"],10),left:parseInt(o["margin-left"],10),right:parseInt(o["margin-right"],10)}}e.getMargin=d;function t(i){var o=window.getComputedStyle(i);return{top:parseInt(o["padding-top"],10)+parseInt(o["border-top-width"],10),bottom:parseInt(o["padding-bottom"],10)+parseInt(o["border-bottom-width"],10),left:parseInt(o["padding-left"],10)+parseInt(o["border-left-width"],10),right:parseInt(o["padding-right"],10)+parseInt(o["border-right-width"],10)}}e.getPaddingAndBorder=t;function n(i,o,u){var v=u?-1:1;i.forEach(function(O,p){return g(O,v*o[p].x,o[p].y)})}e.translateThumbs=n;function l(i,o,u,v){for(var O=0,p=D(i[0],o,u,v),k=1;k<i.length;k++){var _=D(i[k],o,u,v);_<p&&(p=_,O=k)}return O}e.getClosestThumbIndex=l;function g(i,o,u){i.style.transform="translate(".concat(o,"px, ").concat(u,"px)")}e.translate=g;var m=function(i){var o=[],u=null,v=function(){for(var O=[],p=0;p<arguments.length;p++)O[p]=arguments[p];o=O,!u&&(u=requestAnimationFrame(function(){u=null,i.apply(void 0,o)}))};return v};e.schd=m;function y(i,o,u){var v=i.slice(0);return v[o]=u,v}e.replaceAt=y;function E(i){var o=i.values,u=i.colors,v=i.min,O=i.max,p=i.direction,k=p===void 0?s.Direction.Right:p,_=i.rtl,P=_===void 0?!1:_;P&&k===s.Direction.Right?k=s.Direction.Left:P&&s.Direction.Left&&(k=s.Direction.Right);var x=o.slice(0).sort(function(z,W){return z-W}).map(function(z){return(z-v)/(O-v)*100}),U=x.reduce(function(z,W,B){return"".concat(z,", ").concat(u[B]," ").concat(W,"%, ").concat(u[B+1]," ").concat(W,"%")},"");return"linear-gradient(".concat(k,", ").concat(u[0]," 0%").concat(U,", ").concat(u[u.length-1]," 100%)")}e.getTrackBackground=E;function w(){}e.voidFn=w;function R(i){throw new Error("Didn't expect to get here")}e.assertUnreachable=R;var M=function(i,o,u,v,O){O===void 0&&(O=function(k){return k});var p=Math.ceil(r([i],Array.from(i.children),!0).reduce(function(k,_){var P=Math.ceil(_.getBoundingClientRect().width);if(_.innerText&&_.innerText.includes(u)&&_.childElementCount===0){var x=_.cloneNode(!0);x.innerHTML=O(o.toFixed(v)),x.style.visibility="hidden",document.body.appendChild(x),P=Math.ceil(x.getBoundingClientRect().width),document.body.removeChild(x)}return P>k?P:k},i.getBoundingClientRect().width));return p},I=function(i,o,u,v,O,p,k){k===void 0&&(k=function(x){return x});var _=[],P=function(x){var U=M(u[x],v[x],O,p,k),z=o[x].x;o.forEach(function(W,B){var A=W.x,Z=M(u[B],v[B],O,p,k);x!==B&&(z>=A&&z<=A+Z||z+U>=A&&z+U<=A+Z)&&(_.includes(B)||(_.push(x),_.push(B),_=r(r([],_,!0),[x,B],!1),P(B)))})};return P(i),Array.from(new Set(_.sort()))},T=function(i,o,u,v,O,p){v===void 0&&(v=.1),O===void 0&&(O=" - "),p===void 0&&(p=function(B){return B});var k=(0,e.getStepDecimals)(v),_=(0,a.useState)({}),P=_[0],x=_[1],U=(0,a.useState)(p(o[u].toFixed(k))),z=U[0],W=U[1];return(0,a.useEffect)(function(){if(i){var B=i.getThumbs();if(B.length<1)return;var A={},Z=i.getOffsets(),ne=I(u,Z,B,o,O,k,p),le=p(o[u].toFixed(k));if(ne.length){var Q=ne.reduce(function(ee,oe,ge,pe){return ee.length?r(r([],ee,!0),[Z[pe[ge]].x],!1):[Z[pe[ge]].x]},[]);if(Math.min.apply(Math,Q)===Z[u].x){var de=[];ne.forEach(function(ee){de.push(o[ee].toFixed(k))}),le=Array.from(new Set(de.sort(function(ee,oe){return parseFloat(ee)-parseFloat(oe)}))).map(p).join(O);var fe=Math.min.apply(Math,Q),he=Math.max.apply(Math,Q),_e=B[ne[Q.indexOf(he)]].getBoundingClientRect().width;A.left="".concat(Math.abs(fe-(he+_e))/2,"px"),A.transform="translate(-50%, 0)"}else A.visibility="hidden"}W(le),x(A)}},[i,o]),[z,P]};e.useThumbOverlap=T;function D(i,o,u,v){var O=i.getBoundingClientRect(),p=O.left,k=O.top,_=O.width,P=O.height;return F(v)?Math.abs(u-(k+P/2)):Math.abs(o-(p+_/2))}var V=function(){var i,o=((i=navigator.userAgentData)===null||i===void 0?void 0:i.platform)||navigator.platform;return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(o)||navigator.userAgent.includes("Mac")&&"ontouchend"in document};e.isIOS=V}(ue)),ue}var He;function Ct(){if(He)return H;He=1;var e=H&&H.__extends||function(){var $=function(b,d){return $=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(t[l]=n[l])},$(b,d)};return function(b,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");$(b,d);function t(){this.constructor=b}b.prototype=d===null?Object.create(d):(t.prototype=d.prototype,new t)}}(),r=H&&H.__createBinding||(Object.create?function($,b,d,t){t===void 0&&(t=d);var n=Object.getOwnPropertyDescriptor(b,d);(!n||("get"in n?!b.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return b[d]}}),Object.defineProperty($,t,n)}:function($,b,d,t){t===void 0&&(t=d),$[t]=b[d]}),a=H&&H.__setModuleDefault||(Object.create?function($,b){Object.defineProperty($,"default",{enumerable:!0,value:b})}:function($,b){$.default=b}),s=H&&H.__importStar||function($){if($&&$.__esModule)return $;var b={};if($!=null)for(var d in $)d!=="default"&&Object.prototype.hasOwnProperty.call($,d)&&r(b,$,d);return a(b,$),b},h=H&&H.__spreadArray||function($,b,d){if(d||arguments.length===2)for(var t=0,n=b.length,l;t<n;t++)(l||!(t in b))&&(l||(l=Array.prototype.slice.call(b,0,t)),l[t]=b[t]);return $.concat(l||Array.prototype.slice.call(b))};Object.defineProperty(H,"__esModule",{value:!0});var S=s(Ze()),c=Ge(),f=Ie(),j=["ArrowRight","ArrowUp","k","PageUp"],F=["ArrowLeft","ArrowDown","j","PageDown"],L=function($){e(b,$);function b(d){var t=$.call(this,d)||this;if(t.trackRef=S.createRef(),t.thumbRefs=[],t.state={draggedTrackPos:[-1,-1],draggedThumbIndex:-1,thumbZIndexes:new Array(t.props.values.length).fill(0).map(function(n,l){return l}),isChanged:!1,markOffsets:[]},t.getOffsets=function(){var n=t.props,l=n.direction,g=n.values,m=n.min,y=n.max,E=t.trackRef.current;if(!E)return console.warn("No track element found."),[];var w=E.getBoundingClientRect(),R=(0,c.getPaddingAndBorder)(E);return t.getThumbs().map(function(M,I){var T={x:0,y:0},D=M.getBoundingClientRect(),V=(0,c.getMargin)(M);switch(l){case f.Direction.Right:return T.x=(V.left+R.left)*-1,T.y=((D.height-w.height)/2+R.top)*-1,T.x+=w.width*(0,c.relativeValue)(g[I],m,y)-D.width/2,T;case f.Direction.Left:return T.x=(V.right+R.right)*-1,T.y=((D.height-w.height)/2+R.top)*-1,T.x+=w.width-w.width*(0,c.relativeValue)(g[I],m,y)-D.width/2,T;case f.Direction.Up:return T.x=((D.width-w.width)/2+V.left+R.left)*-1,T.y=-R.left,T.y+=w.height-w.height*(0,c.relativeValue)(g[I],m,y)-D.height/2,T;case f.Direction.Down:return T.x=((D.width-w.width)/2+V.left+R.left)*-1,T.y=-R.left,T.y+=w.height*(0,c.relativeValue)(g[I],m,y)-D.height/2,T;default:return(0,c.assertUnreachable)(l)}})},t.getThumbs=function(){return t.trackRef&&t.trackRef.current?Array.from(t.trackRef.current.children).filter(function(n){return n.hasAttribute("aria-valuenow")}):(console.warn("No thumbs found in the track container. Did you forget to pass & spread the `props` param in renderTrack?"),[])},t.getTargetIndex=function(n){return t.getThumbs().findIndex(function(l){return l===n.target||l.contains(n.target)})},t.addTouchEvents=function(n){document.addEventListener("touchmove",t.schdOnTouchMove,{passive:!1}),document.addEventListener("touchend",t.schdOnEnd,{passive:!1}),document.addEventListener("touchcancel",t.schdOnEnd,{passive:!1})},t.addMouseEvents=function(n){document.addEventListener("mousemove",t.schdOnMouseMove),document.addEventListener("mouseup",t.schdOnEnd)},t.onMouseDownTrack=function(n){var l;if(!(n.button!==0||(0,c.isIOS)()))if(n.persist(),n.preventDefault(),t.addMouseEvents(n.nativeEvent),t.props.values.length>1&&t.props.draggableTrack){if(t.thumbRefs.some(function(m){var y;return(y=m.current)===null||y===void 0?void 0:y.contains(n.target)}))return;t.setState({draggedTrackPos:[n.clientX,n.clientY]},function(){return t.onMove(n.clientX,n.clientY)})}else{var g=(0,c.getClosestThumbIndex)(t.thumbRefs.map(function(m){return m.current}),n.clientX,n.clientY,t.props.direction);(l=t.thumbRefs[g].current)===null||l===void 0||l.focus(),t.setState({draggedThumbIndex:g},function(){return t.onMove(n.clientX,n.clientY)})}},t.onResize=function(){(0,c.translateThumbs)(t.getThumbs(),t.getOffsets(),t.props.rtl),t.calculateMarkOffsets()},t.onTouchStartTrack=function(n){var l;if(n.persist(),t.addTouchEvents(n.nativeEvent),t.props.values.length>1&&t.props.draggableTrack){if(t.thumbRefs.some(function(m){var y;return(y=m.current)===null||y===void 0?void 0:y.contains(n.target)}))return;t.setState({draggedTrackPos:[n.touches[0].clientX,n.touches[0].clientY]},function(){return t.onMove(n.touches[0].clientX,n.touches[0].clientY)})}else{var g=(0,c.getClosestThumbIndex)(t.thumbRefs.map(function(m){return m.current}),n.touches[0].clientX,n.touches[0].clientY,t.props.direction);(l=t.thumbRefs[g].current)===null||l===void 0||l.focus(),t.setState({draggedThumbIndex:g},function(){return t.onMove(n.touches[0].clientX,n.touches[0].clientY)})}},t.onMouseOrTouchStart=function(n){if(!t.props.disabled){var l=(0,c.isTouchEvent)(n);if(!(!l&&n.button!==0)){var g=t.getTargetIndex(n);g!==-1&&(l?t.addTouchEvents(n):t.addMouseEvents(n),t.setState({draggedThumbIndex:g,thumbZIndexes:t.state.thumbZIndexes.map(function(m,y){return y===g?Math.max.apply(Math,t.state.thumbZIndexes):m<=t.state.thumbZIndexes[g]?m:m-1})}))}}},t.onMouseMove=function(n){n.preventDefault(),t.onMove(n.clientX,n.clientY)},t.onTouchMove=function(n){n.preventDefault(),t.onMove(n.touches[0].clientX,n.touches[0].clientY)},t.onKeyDown=function(n){var l=t.props,g=l.values,m=l.onChange,y=l.step,E=l.rtl,w=l.direction,R=t.state.isChanged,M=t.getTargetIndex(n.nativeEvent),I=E||w===f.Direction.Left||w===f.Direction.Down?-1:1;M!==-1&&(j.includes(n.key)?(n.preventDefault(),t.setState({draggedThumbIndex:M,isChanged:!0}),m((0,c.replaceAt)(g,M,t.normalizeValue(g[M]+I*(n.key==="PageUp"?y*10:y),M)))):F.includes(n.key)?(n.preventDefault(),t.setState({draggedThumbIndex:M,isChanged:!0}),m((0,c.replaceAt)(g,M,t.normalizeValue(g[M]-I*(n.key==="PageDown"?y*10:y),M)))):n.key==="Tab"?t.setState({draggedThumbIndex:-1},function(){R&&t.fireOnFinalChange()}):R&&t.fireOnFinalChange())},t.onKeyUp=function(n){var l=t.state.isChanged;t.setState({draggedThumbIndex:-1},function(){l&&t.fireOnFinalChange()})},t.onMove=function(n,l){var g=t.state,m=g.draggedThumbIndex,y=g.draggedTrackPos,E=t.props,w=E.direction,R=E.min,M=E.max,I=E.onChange,T=E.values,D=E.step,V=E.rtl;if(m===-1&&y[0]===-1&&y[1]===-1)return null;var i=t.trackRef.current;if(!i)return null;var o=i.getBoundingClientRect(),u=(0,c.isVertical)(w)?o.height:o.width;if(y[0]!==-1&&y[1]!==-1){var v=n-y[0],O=l-y[1],p=0;switch(w){case f.Direction.Right:case f.Direction.Left:p=v/u*(M-R);break;case f.Direction.Down:case f.Direction.Up:p=O/u*(M-R);break;default:(0,c.assertUnreachable)(w)}if(V&&(p*=-1),Math.abs(p)>=D/2){for(var k=0;k<t.thumbRefs.length;k++){if(T[k]===M&&Math.sign(p)===1||T[k]===R&&Math.sign(p)===-1)return;var _=T[k]+p;_>M?p=M-T[k]:_<R&&(p=R-T[k])}for(var P=T.slice(0),k=0;k<t.thumbRefs.length;k++)P=(0,c.replaceAt)(P,k,t.normalizeValue(T[k]+p,k));t.setState({draggedTrackPos:[n,l]}),I(P)}}else{var x=0;switch(w){case f.Direction.Right:x=(n-o.left)/u*(M-R)+R;break;case f.Direction.Left:x=(u-(n-o.left))/u*(M-R)+R;break;case f.Direction.Down:x=(l-o.top)/u*(M-R)+R;break;case f.Direction.Up:x=(u-(l-o.top))/u*(M-R)+R;break;default:(0,c.assertUnreachable)(w)}V&&(x=M+R-x),Math.abs(T[m]-x)>=D/2&&I((0,c.replaceAt)(T,m,t.normalizeValue(x,m)))}},t.normalizeValue=function(n,l){var g=t.props,m=g.min,y=g.max,E=g.step,w=g.allowOverlap,R=g.values;return(0,c.normalizeValue)(n,l,m,y,E,w,R)},t.onEnd=function(n){if(n.preventDefault(),document.removeEventListener("mousemove",t.schdOnMouseMove),document.removeEventListener("touchmove",t.schdOnTouchMove),document.removeEventListener("mouseup",t.schdOnEnd),document.removeEventListener("touchend",t.schdOnEnd),document.removeEventListener("touchcancel",t.schdOnEnd),t.state.draggedThumbIndex===-1&&t.state.draggedTrackPos[0]===-1&&t.state.draggedTrackPos[1]===-1)return null;t.setState({draggedThumbIndex:-1,draggedTrackPos:[-1,-1]},function(){t.fireOnFinalChange()})},t.fireOnFinalChange=function(){t.setState({isChanged:!1});var n=t.props,l=n.onFinalChange,g=n.values;l&&l(g)},t.updateMarkRefs=function(n){if(!n.renderMark){t.numOfMarks=void 0,t.markRefs=void 0;return}t.numOfMarks=(n.max-n.min)/t.props.step,t.markRefs=[];for(var l=0;l<t.numOfMarks+1;l++)t.markRefs[l]=S.createRef()},t.calculateMarkOffsets=function(){if(!(!t.props.renderMark||!t.trackRef||!t.numOfMarks||!t.markRefs||t.trackRef.current===null)){for(var n=window.getComputedStyle(t.trackRef.current),l=parseInt(n.width,10),g=parseInt(n.height,10),m=parseInt(n.paddingLeft,10),y=parseInt(n.paddingTop,10),E=[],w=0;w<t.numOfMarks+1;w++){var R=9999,M=9999;if(t.markRefs[w].current){var I=t.markRefs[w].current.getBoundingClientRect();R=I.height,M=I.width}t.props.direction===f.Direction.Left||t.props.direction===f.Direction.Right?E.push([Math.round(l/t.numOfMarks*w+m-M/2),-Math.round((R-g)/2)]):E.push([Math.round(g/t.numOfMarks*w+y-R/2),-Math.round((M-l)/2)])}t.setState({markOffsets:E})}},d.step===0)throw new Error('"step" property should be a positive number');return t.schdOnMouseMove=(0,c.schd)(t.onMouseMove),t.schdOnTouchMove=(0,c.schd)(t.onTouchMove),t.schdOnEnd=(0,c.schd)(t.onEnd),t.thumbRefs=d.values.map(function(){return S.createRef()}),t.updateMarkRefs(d),t}return b.prototype.componentDidMount=function(){var d=this,t=this.props,n=t.values,l=t.min,g=t.step;this.resizeObserver=window.ResizeObserver?new window.ResizeObserver(this.onResize):{observe:function(){return window.addEventListener("resize",d.onResize)},unobserve:function(){return window.removeEventListener("resize",d.onResize)}},document.addEventListener("touchstart",this.onMouseOrTouchStart,{passive:!1}),document.addEventListener("mousedown",this.onMouseOrTouchStart,{passive:!1}),!this.props.allowOverlap&&(0,c.checkInitialOverlap)(this.props.values),this.props.values.forEach(function(m){return(0,c.checkBoundaries)(m,d.props.min,d.props.max)}),this.resizeObserver.observe(this.trackRef.current),(0,c.translateThumbs)(this.getThumbs(),this.getOffsets(),this.props.rtl),this.calculateMarkOffsets(),n.forEach(function(m){(0,c.isStepDivisible)(l,m,g)||console.warn("The `values` property is in conflict with the current `step`, `min`, and `max` properties. Please provide values that are accessible using the min, max, and step values.")})},b.prototype.componentDidUpdate=function(d,t){var n=this.props,l=n.max,g=n.min,m=n.step,y=n.values,E=n.rtl;(d.max!==l||d.min!==g||d.step!==m)&&this.updateMarkRefs(this.props),(0,c.translateThumbs)(this.getThumbs(),this.getOffsets(),E),(d.max!==l||d.min!==g||d.step!==m||t.markOffsets.length!==this.state.markOffsets.length)&&(this.calculateMarkOffsets(),y.forEach(function(w){(0,c.isStepDivisible)(g,w,m)||console.warn("The `values` property is in conflict with the current `step`, `min`, and `max` properties. Please provide values that are accessible using the min, max, and step values.")}))},b.prototype.componentWillUnmount=function(){var d={passive:!1};document.removeEventListener("mousedown",this.onMouseOrTouchStart,d),document.removeEventListener("mousemove",this.schdOnMouseMove),document.removeEventListener("touchmove",this.schdOnTouchMove),document.removeEventListener("touchstart",this.onMouseOrTouchStart),document.removeEventListener("mouseup",this.schdOnEnd),document.removeEventListener("touchend",this.schdOnEnd),this.resizeObserver.unobserve(this.trackRef.current)},b.prototype.render=function(){var d=this,t=this.props,n=t.label,l=t.labelledBy,g=t.renderTrack,m=t.renderThumb,y=t.renderMark,E=y===void 0?function(){return null}:y,w=t.values,R=t.min,M=t.max,I=t.allowOverlap,T=t.disabled,D=this.state,V=D.draggedThumbIndex,i=D.thumbZIndexes,o=D.markOffsets;return g({props:{style:{transform:"scale(1)",cursor:V>-1?"grabbing":this.props.draggableTrack?(0,c.isVertical)(this.props.direction)?"ns-resize":"ew-resize":w.length===1&&!T?"pointer":"inherit"},onMouseDown:T?c.voidFn:this.onMouseDownTrack,onTouchStart:T?c.voidFn:this.onTouchStartTrack,ref:this.trackRef},isDragged:this.state.draggedThumbIndex>-1,disabled:T,children:h(h([],o.map(function(u,v,O){return E({props:{style:d.props.direction===f.Direction.Left||d.props.direction===f.Direction.Right?{position:"absolute",left:"".concat(u[0],"px"),marginTop:"".concat(u[1],"px")}:{position:"absolute",top:"".concat(u[0],"px"),marginLeft:"".concat(u[1],"px")},key:"mark".concat(v),ref:d.markRefs[v]},index:v})}),!0),w.map(function(u,v){var O=d.state.draggedThumbIndex===v;return m({index:v,value:u,isDragged:O,props:{style:{position:"absolute",zIndex:i[v],cursor:T?"inherit":O?"grabbing":"grab",userSelect:"none",touchAction:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},key:v,tabIndex:T?void 0:0,"aria-valuemax":I?M:w[v+1]||M,"aria-valuemin":I?R:w[v-1]||R,"aria-valuenow":u,draggable:!1,ref:d.thumbRefs[v],"aria-label":n,"aria-labelledby":l,role:"slider",onKeyDown:T?c.voidFn:d.onKeyDown,onKeyUp:T?c.voidFn:d.onKeyUp}})}),!0)})},b.defaultProps={label:"Accessibility label",labelledBy:null,step:1,direction:f.Direction.Right,rtl:!1,disabled:!1,allowOverlap:!1,draggableTrack:!1,min:0,max:100},b}(S.Component);return H.default=L,H}var We;function Dt(){return We||(We=1,function(e){var r=se&&se.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(e,"__esModule",{value:!0}),e.checkValuesAgainstBoundaries=e.relativeValue=e.useThumbOverlap=e.Direction=e.getTrackBackground=e.Range=void 0;var a=r(Ct());e.Range=a.default;var s=Ge();Object.defineProperty(e,"getTrackBackground",{enumerable:!0,get:function(){return s.getTrackBackground}}),Object.defineProperty(e,"useThumbOverlap",{enumerable:!0,get:function(){return s.useThumbOverlap}}),Object.defineProperty(e,"relativeValue",{enumerable:!0,get:function(){return s.relativeValue}}),Object.defineProperty(e,"checkValuesAgainstBoundaries",{enumerable:!0,get:function(){return s.checkValuesAgainstBoundaries}});var h=Ie();Object.defineProperty(e,"Direction",{enumerable:!0,get:function(){return h.Direction}})}(se)),se}var Je=Dt();function qe(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(h){return Object.getOwnPropertyDescriptor(e,h).enumerable})),a.push.apply(a,s)}return a}function ve(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?qe(Object(a),!0).forEach(function(s){Pt(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):qe(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function Pt(e,r,a){return r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}var be=J("div",{position:"relative",width:"100%"});be.displayName="Root";be.displayName="Root";be.displayName="StyledRoot";var ye=J("div",function(e){var r=e.$theme,a=e.$value,s=a===void 0?[]:a,h=e.$disabled,S=e.$isDragged,c=r.sizing,f="inherit";return h?f="not-allowed":S?f="grabbing":s.length===1&&(f="pointer"),{paddingTop:c.scale600,paddingBottom:c.scale600,paddingRight:c.scale600,paddingLeft:c.scale600,display:"flex",cursor:f,backgroundColor:r.colors.sliderTrackFill}});ye.displayName="Track";ye.displayName="Track";ye.displayName="StyledTrack";var Te=J("div",function(e){var r=e.$theme,a=e.$value,s=a===void 0?[]:a,h=e.$min,S=e.$max,c=e.$disabled,f=r.colors,j=r.borders,F=r.direction,L=r.borders.useRoundedCorners?j.radius100:0;return{borderTopLeftRadius:L,borderTopRightRadius:L,borderBottomRightRadius:L,borderBottomLeftRadius:L,background:Je.getTrackBackground({values:s,colors:s.length===1?[c?f.borderOpaque:f.primary,c?f.backgroundSecondary:f.borderOpaque]:[c?f.backgroundSecondary:f.borderOpaque,c?f.borderOpaque:f.primary,c?f.backgroundSecondary:f.borderOpaque],min:h||0,max:S||0,rtl:F==="rtl"}),height:"2px",width:"100%",alignSelf:"center",cursor:c?"not-allowed":"inherit"}});Te.displayName="InnerTrack";Te.displayName="InnerTrack";Te.displayName="StyledInnerTrack";var ke=J("div",function(e){return{width:"4px",height:"2px",backgroundColor:e.$theme.colors.backgroundPrimary,marginLeft:"16px"}});ke.displayName="Mark";ke.displayName="Mark";ke.displayName="StyledMark";var Oe=J("div",function(e){return ve(ve({},e.$theme.typography.font200),{},{color:e.$theme.colors.contentPrimary})});Oe.displayName="Tick";Oe.displayName="Tick";Oe.displayName="StyledTick";var we=J("div",function(e){var r=e.$theme,a=r.sizing;return{display:"flex",justifyContent:"space-between",alignItems:"center",paddingRight:a.scale600,paddingLeft:a.scale600,paddingBottom:a.scale400}});we.displayName="TickBar";we.displayName="TickBar";we.displayName="StyledTickBar";var Re=J("div",function(e){var r=e.$theme,a=e.$value,s=a===void 0?[]:a,h=e.$thumbIndex,S=e.$disabled,c=s.length===2&&h===0,f=s.length===2&&h===1;return r.direction==="rtl"&&(f||c)&&(c=!c,f=!f),{height:"24px",width:"24px",borderTopLeftRadius:"24px",borderTopRightRadius:"24px",borderBottomLeftRadius:"24px",borderBottomRightRadius:"24px",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:S?r.colors.sliderHandleFillDisabled:r.colors.sliderHandleFill,outline:"none",boxShadow:e.$isFocusVisible?"0 0 0 3px ".concat(r.colors.accent):"0 1px 4px rgba(0, 0, 0, 0.12)",cursor:S?"not-allowed":"inherit"}});Re.displayName="Thumb";Re.displayName="Thumb";Re.displayName="StyledThumb";var Se=J("div",function(e){var r=e.$disabled,a=e.$theme;return{position:"absolute",top:"-16px",width:"4px",height:"20px",backgroundColor:r?a.colors.sliderHandleFillDisabled:a.colors.sliderHandleInnerFill}});Se.displayName="InnerThumb";Se.displayName="InnerThumb";Se.displayName="StyledInnerThumb";var Me=J("div",function(e){var r=e.$disabled,a=e.$theme;return ve(ve({position:"absolute",top:"-".concat(a.sizing.scale1400)},a.typography.font200),{},{backgroundColor:r?a.colors.sliderHandleFillDisabled:a.colors.sliderHandleInnerFill,color:a.colors.contentInversePrimary,paddingLeft:a.sizing.scale600,paddingRight:a.sizing.scale600,paddingTop:a.sizing.scale500,paddingBottom:a.sizing.scale500,borderBottomLeftRadius:"48px",borderBottomRightRadius:"48px",borderTopLeftRadius:"48px",borderTopRightRadius:"48px",whiteSpace:"nowrap"})});Me.displayName="ThumbValue";Me.displayName="ThumbValue";Me.displayName="StyledThumbValue";function Ke(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r&&(s=s.filter(function(h){return Object.getOwnPropertyDescriptor(e,h).enumerable})),a.push.apply(a,s)}return a}function Bt(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?Ke(Object(a),!0).forEach(function(s){At(e,s,a[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):Ke(Object(a)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(a,s))})}return e}function At(e,r,a){return r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&(e[s]=a[s])}return e},Y.apply(this,arguments)}function K(e,r){return Vt(e)||jt(e,r)||Ft(e,r)||Lt()}function Lt(){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 Ft(e,r){if(e){if(typeof e=="string")return Ye(e,r);var a=Object.prototype.toString.call(e).slice(8,-1);if(a==="Object"&&e.constructor&&(a=e.constructor.name),a==="Map"||a==="Set")return Array.from(e);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return Ye(e,r)}}function Ye(e,r){(r==null||r>e.length)&&(r=e.length);for(var a=0,s=new Array(r);a<r;a++)s[a]=e[a];return s}function jt(e,r){var a=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(a!=null){var s=[],h=!0,S=!1,c,f;try{for(a=a.call(e);!(h=(c=a.next()).done)&&(s.push(c.value),!(r&&s.length===r));h=!0);}catch(j){S=!0,f=j}finally{try{!h&&a.return!=null&&a.return()}finally{if(S)throw f}}return s}}function Vt(e){if(Array.isArray(e))return e}var zt=function(r){if(r.length>2||r.length===0)throw new Error("the value prop represents positions of thumbs, so its length can be only one or two");return r};function Nt(e){var r=e.overrides,a=r===void 0?{}:r,s=e.disabled,h=s===void 0?!1:s,S=e.marks,c=S===void 0?!1:S,f=e.onChange,j=f===void 0?function(){}:f,F=e.onFinalChange,L=F===void 0?function(){}:F,$=e.min,b=$===void 0?0:$,d=e.max,t=d===void 0?100:d,n=e.step,l=n===void 0?1:n,g=e.persistentThumb,m=g===void 0?!1:g,y=e.valueToLabel,E=y===void 0?function(X){return X}:y,w=e.value,R=C.useContext(vt),M=C.useState(!1),I=K(M,2),T=I[0],D=I[1],V=C.useState(!1),i=K(V,2),o=i[0],u=i[1],v=C.useState(!1),O=K(v,2),p=O[0],k=O[1],_=C.useState(-1),P=K(_,2),x=P[0],U=P[1],z=C.useCallback(function(X){mt(X)&&k(!0);var N=X.target.parentNode.firstChild===X.target?0:1;U(N)},[]),W=C.useCallback(function(X){p!==!1&&k(!1),U(-1)},[]),B=zt(w),A={$disabled:h,$step:l,$min:b,$max:t,$marks:c,$value:B,$isFocusVisible:p},Z=G(a.Root,be),ne=K(Z,2),le=ne[0],Q=ne[1],de=G(a.Track,ye),fe=K(de,2),he=fe[0],_e=fe[1],ee=G(a.InnerTrack,Te),oe=K(ee,2),ge=oe[0],pe=oe[1],Qe=G(a.Thumb,Re),xe=K(Qe,2),et=xe[0],tt=xe[1],rt=G(a.InnerThumb,Se),Ce=K(rt,2),nt=Ce[0],at=Ce[1],it=G(a.ThumbValue,Me),De=K(it,2),ot=De[0],st=De[1],ut=G(a.Tick,Oe),Pe=K(ut,2),Be=Pe[0],Ae=Pe[1],ct=G(a.TickBar,we),Le=K(ct,2),lt=Le[0],dt=Le[1],ft=G(a.Mark,ke),Fe=K(ft,2),ht=Fe[0],gt=Fe[1];return C.createElement(le,Y({"data-baseweb":"slider"},A,Q,{onFocus:yt(Q,z),onBlur:bt(Q,W)}),C.createElement(Je.Range,Y({step:l,min:b,max:t,values:B,disabled:h,onChange:function(N){return j({value:N})},onFinalChange:function(N){return L({value:N})},rtl:R.direction==="rtl",renderTrack:function(N){var te=N.props,q=N.children,ae=N.isDragged;return C.createElement(he,Y({onMouseDown:te.onMouseDown,onTouchStart:te.onTouchStart,$isDragged:ae},A,_e),C.createElement(ge,Y({$isDragged:ae,ref:te.ref},A,pe),q))},renderThumb:function(N){var te=N.props,q=N.index,ae=N.isDragged,je=m||(!!q&&o||!q&&T||ae)&&!h;return C.createElement(et,Y({},te,{onMouseEnter:function(){q===0?D(!0):u(!0)},onMouseLeave:function(){q===0?D(!1):u(!1)},$thumbIndex:q,$isDragged:ae,style:Bt({},te.style)},A,tt,{$isFocusVisible:p&&x===q}),je&&C.createElement(ot,Y({$thumbIndex:q,$isDragged:ae},A,st),E(B[q])),je&&C.createElement(nt,Y({$thumbIndex:q,$isDragged:ae},A,at)))}},c?{renderMark:function(N){var te=N.props,q=N.index;return C.createElement(ht,Y({$markIndex:q},te,A,gt))}}:{})),C.createElement(lt,Y({},A,dt),C.createElement(Be,Y({},A,Ae),E(b)),C.createElement(Be,Y({},A,Ae),E(t))))}const Ut=me("div",{target:"e8lt0n70"})(({disabled:e,theme:r})=>({alignItems:"center",backgroundColor:e?r.colors.gray:r.colors.primary,borderTopLeftRadius:"100%",borderTopRightRadius:"100%",borderBottomLeftRadius:"100%",borderBottomRightRadius:"100%",borderTopStyle:"none",borderBottomStyle:"none",borderRightStyle:"none",borderLeftStyle:"none",boxShadow:"none",display:"flex",justifyContent:"center",height:r.sizes.sliderThumb,width:r.sizes.sliderThumb,":focus":{outline:"none"},":focus-visible":{boxShadow:`0 0 0 0.2rem ${Tt(r.colors.primary,.5)}`}})),Ht=me("div",{target:"e8lt0n71"})(({disabled:e,theme:r})=>({fontFamily:r.genericFonts.codeFont,fontSize:r.fontSizes.sm,color:e?r.colors.gray:r.colors.primary,top:"-1.6em",position:"absolute",whiteSpace:"nowrap",backgroundColor:r.colors.transparent,lineHeight:r.lineHeights.base,fontWeight:r.fontWeights.normal,pointerEvents:"none"})),Wt=me("div",{target:"e8lt0n72"})(({theme:e})=>({fontSize:e.fontSizes.sm,paddingBottom:e.spacing.none,paddingLeft:e.spacing.none,paddingRight:e.spacing.none,paddingTop:"0.65em",justifyContent:"space-between",alignItems:"center",display:"flex"})),Xe=me("div",{target:"e8lt0n73"})(({disabled:e,theme:r})=>({lineHeight:r.lineHeights.base,fontWeight:r.fontWeights.normal,fontFamily:r.genericFonts.codeFont,color:e?r.colors.fadedText40:"inherit"})),qt=200;function Kt({disabled:e,element:r,widgetMgr:a,fragmentId:s}){const[h,S]=xt({getStateFromWidgetMgr:Yt,getDefaultStateFromProto:Xt,getCurrStateFromProto:Zt,updateWidgetMgrState:Gt,element:r,widgetMgr:a,fragmentId:s}),[c,f]=C.useState(h),j=C.useRef(null),[F]=C.useState([]),[L]=C.useState([]),{colors:$,fonts:b,fontSizes:d,spacing:t}=Ot(),n=c.map(I=>Ee(I,r)),l=Ee(r.min,r),g=Ee(r.max,r),m=r.label;C.useEffect(()=>{f(h)},[h]);const y=C.useCallback(wt(qt,I=>{S({value:I,fromUi:!0})}),[]),E=C.useCallback(({value:I})=>{f(I),y(I)},[y]),w=C.useCallback(()=>Ve(Wt,{"data-testid":"stSliderTickBar",children:[re(Xe,{disabled:e,"data-testid":"stSliderTickBarMin",children:l}),re(Xe,{disabled:e,"data-testid":"stSliderTickBarMax",children:g})]}),[l,g,e]),R=C.useCallback(C.forwardRef(function(T,D){const{$thumbIndex:V}=T,i=V||0;F[i]=D,L[i]||=C.createRef();const o=Rt(T,["role","style","aria-valuemax","aria-valuemin","aria-valuenow","tabIndex","onKeyUp","onKeyDown","onMouseEnter","onMouseLeave","draggable"]),u=n[i];return re(Ut,{...o,disabled:T.$disabled===!0,ref:F[i],"aria-valuetext":u,"aria-label":m,children:re(Ht,{"data-testid":"stSliderThumbValue",disabled:T.$disabled===!0,ref:L[i],children:u})})}),[]);C.useEffect(()=>{L.map((o,u)=>{o.current&&(o.current.innerText=n[u])}),F.map((o,u)=>{o.current&&o.current.setAttribute("aria-valuetext",n[u])});const I=j.current??null,T=F[0].current,D=F[1]?.current,V=L[0].current,i=L[1]?.current;er(I,T,D,V,i)});const M=C.useCallback(({$disabled:I})=>({height:t.twoXS,...I?{background:$.darkenedBgMix25}:{}}),[$,t]);return Ve("div",{ref:j,className:"stSlider","data-testid":"stSlider",children:[re(Et,{label:r.label,disabled:e,labelVisibility:St(r.labelVisibility?.value),children:r.help&&re(Mt,{children:re(_t,{content:r.help,placement:$t.TOP_RIGHT})})}),re(Nt,{min:r.min,max:r.max,step:r.step,value:Qt(c,r),onChange:E,disabled:e,overrides:{Thumb:R,Tick:{style:{fontFamily:b.monospace}},Track:{style:{backgroundColor:"none !important",paddingBottom:t.none,paddingLeft:t.none,paddingRight:t.none,paddingTop:`calc(${d.sm} * 1.35)`}},InnerTrack:{style:M},TickBar:w}})]})}function Yt(e,r){return e.getDoubleArrayValue(r)}function Xt(e){return e.default}function Zt(e){return e.value}function Gt(e,r,a,s){r.setDoubleArrayValue(e,a.value,{fromUi:a.fromUi},s)}function Jt(e){const{dataType:r}=e;return r===$e.DataType.DATETIME||r===$e.DataType.DATE||r===$e.DataType.TIME}function Ee(e,r){const{format:a,options:s}=r;return Jt(r)?It.utc(e/1e3).format(a):s.length>0?ze.sprintf(a,s[e]):ze.sprintf(a,e)}function Qt(e,r){const{min:a,max:s}=r;let h=e[0],S=e.length>1?e[1]:e[0];return h>S&&(h=S),h<a&&(h=a),h>s&&(h=s),S<a&&(S=a),S>s&&(S=s),e.length>1?[h,S]:[h]}function er(e,r,a,s,h){!e||!r||!s||(ie(e,r,s),a&&h&&(ie(e,a,h),tr(e,r,a,s,h)))}function ie(e,r,a){const s=e.getBoundingClientRect(),h=r.getBoundingClientRect(),S=a.getBoundingClientRect(),c=h.left+h.width/2,f=c-S.width/2<s.left,j=c+S.width/2>s.right;a.style.left=f?"0":"",a.style.right=j?"0":""}function tr(e,r,a,s,h){const c=e.getBoundingClientRect(),f=r.getBoundingClientRect(),j=a.getBoundingClientRect(),F=s.getBoundingClientRect(),L=h.getBoundingClientRect(),$=c.left+c.width/2,b=f.left+f.width/2,d=j.left+j.width/2,t=b-F.width/2>=c.left,n=d+L.width/2<=c.right,l=f.left-F.width>=c.left,g=j.right+L.width<=c.right,m=t?F.width/2:F.width,y=n?L.width/2:L.width,E=b+m;if(d-y-E>24){ie(e,r,s),ie(e,a,h);return}if(l&&g){s.style.left="",s.style.right=`${Math.round(f.width)}px`,h.style.left=`${Math.round(j.width)}px`,h.style.right="";return}b<$?(ie(e,r,s),h.style.left=`${Math.round(b+m+24-d)}px`,h.style.right=""):(ie(e,a,h),s.style.left="",s.style.right=`${-Math.round(d-y-24-b)}px`)}const or=kt(C.memo(Kt));export{or as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{s,k as r,r as i,j as n}from"./index.
|
1
|
+
import{s,k as r,r as i,j as n}from"./index.D_0R5OBc.js";import{P as m,R as c}from"./RenderInPortalIfExists.BnEeVRFq.js";const p=""+new URL("../media/balloon-0.Czj7AKwE.png",import.meta.url).href,f=""+new URL("../media/balloon-1.CNvFFrND.png",import.meta.url).href,d=""+new URL("../media/balloon-2.DTvC6B1t.png",import.meta.url).href,B=""+new URL("../media/balloon-3.CgSk4tbL.png",import.meta.url).href,L=""+new URL("../media/balloon-4.mbtFrzxf.png",import.meta.url).href,h=""+new URL("../media/balloon-5.CSwkUfRA.png",import.meta.url).href,t=300,a=121,e=20,g=80,u=1e3,x=r("from{transform:translateY(calc(100vh + ",t,"px));}to{transform:translateY(0);}"),_=s("img",{target:"eosrfo90"})(({theme:o})=>({position:"fixed",top:`${-t}px`,marginLeft:`${-a/2}px`,zIndex:o.zIndices.balloons,left:`${Math.random()*(g-e)+e}vw`,animationDelay:`${Math.random()*u}ms`,height:`${t}px`,width:`${a}px`,pointerEvents:"none",animationDuration:"750ms",animationName:x,animationTimingFunction:"ease-in",animationDirection:"normal",animationIterationCount:1,opacity:1})),A=30,l=[p,f,d,B,L,h],I=l.length,M=({particleType:o})=>n(_,{src:l[o]}),w=({scriptRunId:o})=>n(c,{children:n(m,{className:"stBalloons","data-testid":"stBalloons",scriptRunId:o,numParticleTypes:I,numParticles:A,ParticleComponent:M})}),U=i.memo(w);export{A as NUM_BALLOONS,U as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{r as d,E as S,_ as x,s as c,H as O,C as p,j as a,bo as f,bp as F,b3 as _,b4 as w,bh as G,F as q,bF as K,aE as Y,bj as J,bG as z,M as h,b as m,bl as Q,bk as Z,br as ee,bH as te,bs as ie,b9 as se,bt as le}from"./index.JlbLrYBv.js";import{F as ne}from"./FormClearHelper.Bfl6Fb0k.js";import{g as b,F as y,b as ae,D as oe,I as re,C as de,a as ce,s as pe}from"./FileHelper.BJWG5mWZ.js";import{S as ge,P as ue}from"./ProgressBar.BOxvIdHT.js";import{u as he}from"./Hooks.BZNasbgB.js";import{U as v}from"./UploadFileInfo.C-jY39rj.js";var M=d.forwardRef(function(e,s){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return d.createElement(S,x({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:s}),d.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),d.createElement("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12l4.58-4.59z"}))});M.displayName="ChevronLeft";var V=d.forwardRef(function(e,s){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return d.createElement(S,x({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:s}),d.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),d.createElement("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z"}))});V.displayName="ChevronRight";var B=d.forwardRef(function(e,s){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return d.createElement(S,x({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:s}),d.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),d.createElement("path",{d:"M19.35 10.04A7.49 7.49 0 0012 4C9.11 4 6.6 5.64 5.35 8.04A5.994 5.994 0 000 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95A5.469 5.469 0 0112 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11A2.98 2.98 0 0122 15c0 1.65-1.35 3-3 3zM8 13h2.55v3h2.9v-3H16l-4-4z"}))});B.displayName="CloudUpload";var D=d.forwardRef(function(e,s){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return d.createElement(S,x({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:s}),d.createElement("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}))});D.displayName="Error";const L=c("section",{target:"e16xj5sw0"})(({isDisabled:e,theme:s})=>({display:"flex",alignItems:"center",padding:s.spacing.lg,backgroundColor:s.colors.secondaryBg,borderRadius:s.radii.default,border:s.colors.widgetBorderColor?`${s.sizes.borderWidth} solid ${s.colors.widgetBorderColor}`:void 0,":focus":{outline:"none"},":focus-visible":{boxShadow:`0 0 0 1px ${s.colors.primary}`},color:e?s.colors.gray:s.colors.bodyText})),P=c("div",{target:"e16xj5sw1"})({marginRight:"auto",alignItems:"center",display:"flex"}),E=c("span",{target:"e16xj5sw2"})(({theme:e})=>({color:e.colors.darkenedBgMix100,marginRight:e.spacing.lg})),fe=c("span",{target:"e16xj5sw3"})(({theme:e})=>({marginBottom:e.spacing.twoXS})),me=c("div",{target:"e16xj5sw4"})({display:"flex",flexDirection:"column"}),j=c("div",{target:"e16xj5sw5"})(({theme:e})=>({left:0,right:0,lineHeight:e.lineHeights.tight,paddingTop:e.spacing.md,paddingLeft:e.spacing.lg,paddingRight:e.spacing.lg})),Fe=c("ul",{target:"e16xj5sw6"})(({theme:e})=>({listStyleType:"none",margin:e.spacing.none,padding:e.spacing.none})),A=c("li",{target:"e16xj5sw7"})(({theme:e})=>({margin:e.spacing.none,padding:e.spacing.none})),H=c("div",{target:"e16xj5sw8"})(({theme:e})=>({display:"flex",alignItems:"baseline",flex:1,paddingLeft:e.spacing.lg,overflow:"hidden"})),N=c("div",{target:"e16xj5sw9"})(({theme:e})=>({marginRight:e.spacing.sm,marginBottom:e.spacing.twoXS,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),W=c("div",{target:"e16xj5sw10"})(({theme:e})=>({display:"flex",alignItems:"center",marginBottom:e.spacing.twoXS})),we=c("span",{target:"e16xj5sw11"})(({theme:e})=>({marginRight:e.spacing.twoXS})),ye=c("div",{target:"e16xj5sw12"})(({theme:e})=>({display:"flex",padding:e.spacing.twoXS,color:e.colors.darkenedBgMix100})),k=c("small",{target:"e16xj5sw13"})(({theme:e})=>({color:e.colors.red,fontSize:e.fontSizes.sm,height:e.fontSizes.sm,lineHeight:e.fontSizes.sm,display:"flex",alignItems:"center",whiteSpace:"nowrap"})),R=c("span",{target:"e16xj5sw14"})({}),Se=e=>({[L]:{display:"flex",flexDirection:"column",alignItems:"flex-start"},[P]:{marginBottom:e.spacing.lg},[E]:{display:"none"},[j]:{paddingRight:e.spacing.lg},[W]:{maxWidth:"inherit",flex:1,alignItems:"flex-start",marginBottom:e.spacing.sm},[N]:{width:e.sizes.full},[H]:{flexDirection:"column"},[k]:{height:"auto",whiteSpace:"initial"},[R]:{display:"none"},[A]:{margin:e.spacing.none,padding:e.spacing.none}}),xe=c("div",{target:"e16xj5sw15"})(({theme:e,width:s})=>{if(s<O("23rem"))return Se(e)}),I=c("small",{target:"ejh2rmr0"})(({kind:e,theme:s})=>{const{danger:t,fadedText60:i}=s.colors;return{color:e==="danger"?t:i,fontSize:s.fontSizes.sm,lineHeight:s.lineHeights.tight}}),Ue=({multiple:e,acceptedExtensions:s,maxSizeBytes:t})=>p(P,{"data-testid":"stFileUploaderDropzoneInstructions",children:[a(E,{children:a(f,{content:B,size:"threeXL"})}),p(me,{children:[p(fe,{children:["Drag and drop file",e?"s":""," here"]}),p(I,{children:[`Limit ${b(t,y.Byte,0)} per file`,s.length?` • ${s.map(i=>i.replace(/^\./,"").toUpperCase()).join(", ")}`:null]})]})]}),ve=d.memo(Ue),Ie=({onDrop:e,multiple:s,acceptedExtensions:t,maxSizeBytes:i,disabled:l,label:o})=>a(oe,{onDrop:e,multiple:s,accept:ae(t),maxSize:i,disabled:l,useFsAccessApi:!1,children:({getRootProps:n,getInputProps:r})=>p(L,{...n(),"data-testid":"stFileUploaderDropzone",isDisabled:l,"aria-label":o,children:[a("input",{"data-testid":"stFileUploaderDropzoneInput",...r()}),a(ve,{multiple:s,acceptedExtensions:t,maxSizeBytes:i}),a(F,{kind:w.SECONDARY,disabled:l,size:_.SMALL,children:"Browse files"})]})}),ze=d.memo(Ie),Ce=c("div",{target:"egc9vxm0"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:e.spacing.twoXS,marginBottom:e.spacing.twoXS})),be=c("div",{target:"egc9vxm1"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.colors.fadedText40})),Me=({currentPage:e,totalPages:s,onNext:t,onPrevious:i})=>p(Ce,{"data-testid":"stFileUploaderPagination",children:[a(I,{children:`Showing page ${e} of ${s}`}),p(be,{children:[a(F,{onClick:i,kind:w.MINIMAL,children:a(f,{content:M,size:"xl"})}),a(F,{onClick:t,kind:w.MINIMAL,children:a(f,{content:V,size:"xl"})})]})]}),Ve=d.memo(Me),C=(e,s)=>Math.ceil(e.length/s),Be=e=>G(({pageSize:t,items:i,resetOnAdd:l,...o})=>{const[n,r]=d.useState(0),[g,U]=d.useState(()=>C(i,t)),u=he(i);d.useEffect(()=>{u&&u.length!==i.length&&U(C(i,t)),u&&u.length<i.length?l&&r(0):n+1>=g&&r(g-1)},[i,n,t,u,l,g]);const T=()=>{r(Math.min(n+1,g-1))},$=()=>{r(Math.max(0,n-1))},X=i.slice(n*t,n*t+t);return p(q,{children:[a(e,{items:X,...o}),i.length>t?a(Ve,{pageSize:t,totalPages:g,currentPage:n+1,onNext:T,onPrevious:$}):null]})},e),De=({fileInfo:e})=>e.status.type==="uploading"?a(ue,{value:e.status.progress,size:ge.SMALL}):e.status.type==="error"?p(k,{children:[a(we,{"data-testid":"stFileUploaderFileErrorMessage",children:e.status.errorMessage}),a(R,{children:a(f,{content:D,size:"lg"})})]}):e.status.type==="uploaded"?a(I,{children:b(e.size,y.Byte)}):null,Le=({fileInfo:e,onDelete:s})=>p(W,{className:"stFileUploaderFile","data-testid":"stFileUploaderFile",children:[a(ye,{children:a(f,{content:re,size:"twoXL"})}),p(H,{className:"stFileUploaderFileData",children:[a(N,{className:"stFileUploaderFileName","data-testid":"stFileUploaderFileName",title:e.name,children:e.name}),a(De,{fileInfo:e})]}),a("div",{"data-testid":"stFileUploaderDeleteBtn",children:a(F,{onClick:()=>s(e.id),kind:w.MINIMAL,children:a(f,{content:de,size:"lg"})})})]}),Pe=d.memo(Le),Ee=({items:e,onDelete:s})=>a(Fe,{children:e.map(t=>a(A,{children:a(Pe,{fileInfo:t,onDelete:s})},t.id))}),je=Be(Ee),Ae=e=>a(j,{children:a(je,{...e})}),He=d.memo(Ae);class Ne extends d.PureComponent{constructor(s){super(s),this.formClearHelper=new ne,this.localFileIdCounter=1,this.forceUpdatingStatus=!1,this.componentDidUpdate=()=>{if(this.status!=="ready")return;const t=this.createWidgetValue(),{element:i,widgetMgr:l,fragmentId:o}=this.props,n=l.getFileUploaderStateValue(i);Y(t,n)||l.setFileUploaderStateValue(i,t,{fromUi:!0},o)},this.dropHandler=(t,i)=>{const{element:l}=this.props,{multipleFiles:o}=l;if(!o&&t.length===0&&i.length>1){const n=i.findIndex(r=>r.errors.length===1&&r.errors[0].code==="too-many-files");n>=0&&(t.push(i[n].file),i.splice(n,1))}if(this.props.uploadClient.fetchFileURLs(t).then(n=>{if(!o&&t.length>0){const r=this.state.files.find(g=>g.status.type!=="error");r&&(this.forceUpdatingStatus=!0,this.deleteFile(r.id),this.forceUpdatingStatus=!1)}J(n,t).forEach(([r,g])=>{this.uploadFile(r,g)})}).catch(n=>{this.addFiles(t.map(r=>new v(r.name,r.size,this.nextLocalFileId(),{type:"error",errorMessage:n})))}),i.length>0){const n=i.map(r=>ce(r,this.nextLocalFileId(),this.maxUploadSizeInBytes));this.addFiles(n)}},this.uploadFile=(t,i)=>{const l=z.CancelToken.source(),o=new v(i.name,i.size,this.nextLocalFileId(),{type:"uploading",cancelToken:l,progress:1});this.addFile(o),this.props.uploadClient.uploadFile(this.props.element,t.uploadUrl,i,n=>this.onUploadProgress(n,o.id),l.token).then(()=>this.onUploadComplete(o.id,t)).catch(n=>{z.isCancel(n)||this.updateFile(o.id,o.setStatus({type:"error",errorMessage:n?n.toString():"Unknown error"}))})},this.onUploadComplete=(t,i)=>{const l=this.getFile(t);h(l)||l.status.type!=="uploading"||this.updateFile(l.id,l.setStatus({type:"uploaded",fileId:i.fileId,fileUrls:i}))},this.deleteFile=t=>{const i=this.getFile(t);h(i)||(i.status.type==="uploading"&&i.status.cancelToken.cancel(),i.status.type==="uploaded"&&i.status.fileUrls.deleteUrl&&this.props.uploadClient.deleteFile(i.status.fileUrls.deleteUrl),this.removeFile(t))},this.addFile=t=>{m.flushSync(()=>{this.setState(i=>({files:[...i.files,t]}))})},this.addFiles=t=>{m.flushSync(()=>{this.setState(i=>({files:[...i.files,...t]}))})},this.removeFile=t=>{m.flushSync(()=>{this.setState(i=>({files:i.files.filter(l=>l.id!==t)}))})},this.getFile=t=>this.state.files.find(i=>i.id===t),this.updateFile=(t,i)=>{m.flushSync(()=>{this.setState(l=>({files:l.files.map(o=>o.id===t?i:o)}))})},this.onUploadProgress=(t,i)=>{const l=this.getFile(i);if(h(l)||l.status.type!=="uploading")return;const o=Math.round(t.loaded*100/t.total);l.status.progress!==o&&this.updateFile(i,l.setStatus({type:"uploading",cancelToken:l.status.cancelToken,progress:o}))},this.onFormCleared=()=>{m.flushSync(()=>{this.setState({files:[]},()=>{const t=this.createWidgetValue();if(h(t))return;const{widgetMgr:i,element:l,fragmentId:o}=this.props;i.setFileUploaderStateValue(l,t,{fromUi:!0},o)})})},this.state=this.initialValue}get initialValue(){const s={files:[]},{widgetMgr:t,element:i}=this.props,l=t.getFileUploaderStateValue(i);if(h(l))return s;const{uploadedFileInfo:o}=l;return h(o)||o.length===0?s:{files:o.map(n=>{const r=n.name,g=n.size,U=n.fileId,u=n.fileUrls;return new v(r,g,this.nextLocalFileId(),{type:"uploaded",fileId:U,fileUrls:u})})}}componentWillUnmount(){this.formClearHelper.disconnect()}get maxUploadSizeInBytes(){const s=this.props.element.maxUploadSizeMb;return pe(s,y.Megabyte,y.Byte)}get status(){const s=t=>t.status.type==="uploading";return this.state.files.some(s)||this.forceUpdatingStatus?"updating":"ready"}componentDidMount(){const s=this.createWidgetValue(),{element:t,widgetMgr:i,fragmentId:l}=this.props;i.getFileUploaderStateValue(t)===void 0&&i.setFileUploaderStateValue(t,s,{fromUi:!1},l)}createWidgetValue(){const s=this.state.files.filter(t=>t.status.type==="uploaded").map(t=>{const{name:i,size:l,status:o}=t,{fileId:n,fileUrls:r}=o;return new Q({fileId:n,fileUrls:r,name:i,size:l})});return new Z({uploadedFileInfo:s})}render(){const{files:s}=this.state,{element:t,disabled:i,widgetMgr:l,width:o}=this.props,n=t.type;this.formClearHelper.manageFormClearListener(l,t.formId,this.onFormCleared);const r=s.slice().reverse();return p(xe,{className:"stFileUploader","data-testid":"stFileUploader",width:o,children:[a(le,{label:t.label,disabled:i,labelVisibility:ee(t.labelVisibility?.value),children:t.help&&a(te,{children:a(ie,{content:t.help,placement:se.TOP_RIGHT})})}),a(ze,{onDrop:this.dropHandler,multiple:t.multipleFiles,acceptedExtensions:n,maxSizeBytes:this.maxUploadSizeInBytes,label:t.label,disabled:i}),r.length>0&&a(He,{items:r,pageSize:3,onDelete:this.deleteFile,resetOnAdd:!0})]})}nextLocalFileId(){return this.localFileIdCounter++}}const Oe=K(d.memo(Ne));export{Oe as default};
|
1
|
+
import{r as d,E as S,_ as x,s as c,H as O,C as p,j as a,bo as f,bp as F,b3 as _,b4 as w,bh as G,F as q,bF as K,aE as Y,bj as J,bG as z,M as h,b as m,bl as Q,bk as Z,br as ee,bH as te,bs as ie,b9 as se,bt as le}from"./index.D_0R5OBc.js";import{F as ne}from"./FormClearHelper.BYxFNamA.js";import{g as b,F as y,b as ae,D as oe,I as re,C as de,a as ce,s as pe}from"./FileHelper.Zrnryqu0.js";import{S as ge,P as ue}from"./ProgressBar.CHyAN4g4.js";import{u as he}from"./Hooks.Bf489OB5.js";import{U as v}from"./UploadFileInfo.C-jY39rj.js";var M=d.forwardRef(function(e,s){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return d.createElement(S,x({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:s}),d.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),d.createElement("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12l4.58-4.59z"}))});M.displayName="ChevronLeft";var V=d.forwardRef(function(e,s){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return d.createElement(S,x({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:s}),d.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),d.createElement("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z"}))});V.displayName="ChevronRight";var B=d.forwardRef(function(e,s){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return d.createElement(S,x({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:s}),d.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),d.createElement("path",{d:"M19.35 10.04A7.49 7.49 0 0012 4C9.11 4 6.6 5.64 5.35 8.04A5.994 5.994 0 000 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95A5.469 5.469 0 0112 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11A2.98 2.98 0 0122 15c0 1.65-1.35 3-3 3zM8 13h2.55v3h2.9v-3H16l-4-4z"}))});B.displayName="CloudUpload";var D=d.forwardRef(function(e,s){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return d.createElement(S,x({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:s}),d.createElement("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"}))});D.displayName="Error";const L=c("section",{target:"e16xj5sw0"})(({isDisabled:e,theme:s})=>({display:"flex",alignItems:"center",padding:s.spacing.lg,backgroundColor:s.colors.secondaryBg,borderRadius:s.radii.default,border:s.colors.widgetBorderColor?`${s.sizes.borderWidth} solid ${s.colors.widgetBorderColor}`:void 0,":focus":{outline:"none"},":focus-visible":{boxShadow:`0 0 0 1px ${s.colors.primary}`},color:e?s.colors.gray:s.colors.bodyText})),P=c("div",{target:"e16xj5sw1"})({marginRight:"auto",alignItems:"center",display:"flex"}),E=c("span",{target:"e16xj5sw2"})(({theme:e})=>({color:e.colors.darkenedBgMix100,marginRight:e.spacing.lg})),fe=c("span",{target:"e16xj5sw3"})(({theme:e})=>({marginBottom:e.spacing.twoXS})),me=c("div",{target:"e16xj5sw4"})({display:"flex",flexDirection:"column"}),j=c("div",{target:"e16xj5sw5"})(({theme:e})=>({left:0,right:0,lineHeight:e.lineHeights.tight,paddingTop:e.spacing.md,paddingLeft:e.spacing.lg,paddingRight:e.spacing.lg})),Fe=c("ul",{target:"e16xj5sw6"})(({theme:e})=>({listStyleType:"none",margin:e.spacing.none,padding:e.spacing.none})),A=c("li",{target:"e16xj5sw7"})(({theme:e})=>({margin:e.spacing.none,padding:e.spacing.none})),H=c("div",{target:"e16xj5sw8"})(({theme:e})=>({display:"flex",alignItems:"baseline",flex:1,paddingLeft:e.spacing.lg,overflow:"hidden"})),N=c("div",{target:"e16xj5sw9"})(({theme:e})=>({marginRight:e.spacing.sm,marginBottom:e.spacing.twoXS,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})),W=c("div",{target:"e16xj5sw10"})(({theme:e})=>({display:"flex",alignItems:"center",marginBottom:e.spacing.twoXS})),we=c("span",{target:"e16xj5sw11"})(({theme:e})=>({marginRight:e.spacing.twoXS})),ye=c("div",{target:"e16xj5sw12"})(({theme:e})=>({display:"flex",padding:e.spacing.twoXS,color:e.colors.darkenedBgMix100})),k=c("small",{target:"e16xj5sw13"})(({theme:e})=>({color:e.colors.red,fontSize:e.fontSizes.sm,height:e.fontSizes.sm,lineHeight:e.fontSizes.sm,display:"flex",alignItems:"center",whiteSpace:"nowrap"})),R=c("span",{target:"e16xj5sw14"})({}),Se=e=>({[L]:{display:"flex",flexDirection:"column",alignItems:"flex-start"},[P]:{marginBottom:e.spacing.lg},[E]:{display:"none"},[j]:{paddingRight:e.spacing.lg},[W]:{maxWidth:"inherit",flex:1,alignItems:"flex-start",marginBottom:e.spacing.sm},[N]:{width:e.sizes.full},[H]:{flexDirection:"column"},[k]:{height:"auto",whiteSpace:"initial"},[R]:{display:"none"},[A]:{margin:e.spacing.none,padding:e.spacing.none}}),xe=c("div",{target:"e16xj5sw15"})(({theme:e,width:s})=>{if(s<O("23rem"))return Se(e)}),I=c("small",{target:"ejh2rmr0"})(({kind:e,theme:s})=>{const{danger:t,fadedText60:i}=s.colors;return{color:e==="danger"?t:i,fontSize:s.fontSizes.sm,lineHeight:s.lineHeights.tight}}),Ue=({multiple:e,acceptedExtensions:s,maxSizeBytes:t})=>p(P,{"data-testid":"stFileUploaderDropzoneInstructions",children:[a(E,{children:a(f,{content:B,size:"threeXL"})}),p(me,{children:[p(fe,{children:["Drag and drop file",e?"s":""," here"]}),p(I,{children:[`Limit ${b(t,y.Byte,0)} per file`,s.length?` • ${s.map(i=>i.replace(/^\./,"").toUpperCase()).join(", ")}`:null]})]})]}),ve=d.memo(Ue),Ie=({onDrop:e,multiple:s,acceptedExtensions:t,maxSizeBytes:i,disabled:l,label:o})=>a(oe,{onDrop:e,multiple:s,accept:ae(t),maxSize:i,disabled:l,useFsAccessApi:!1,children:({getRootProps:n,getInputProps:r})=>p(L,{...n(),"data-testid":"stFileUploaderDropzone",isDisabled:l,"aria-label":o,children:[a("input",{"data-testid":"stFileUploaderDropzoneInput",...r()}),a(ve,{multiple:s,acceptedExtensions:t,maxSizeBytes:i}),a(F,{kind:w.SECONDARY,disabled:l,size:_.SMALL,children:"Browse files"})]})}),ze=d.memo(Ie),Ce=c("div",{target:"egc9vxm0"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:e.spacing.twoXS,marginBottom:e.spacing.twoXS})),be=c("div",{target:"egc9vxm1"})(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"center",color:e.colors.fadedText40})),Me=({currentPage:e,totalPages:s,onNext:t,onPrevious:i})=>p(Ce,{"data-testid":"stFileUploaderPagination",children:[a(I,{children:`Showing page ${e} of ${s}`}),p(be,{children:[a(F,{onClick:i,kind:w.MINIMAL,children:a(f,{content:M,size:"xl"})}),a(F,{onClick:t,kind:w.MINIMAL,children:a(f,{content:V,size:"xl"})})]})]}),Ve=d.memo(Me),C=(e,s)=>Math.ceil(e.length/s),Be=e=>G(({pageSize:t,items:i,resetOnAdd:l,...o})=>{const[n,r]=d.useState(0),[g,U]=d.useState(()=>C(i,t)),u=he(i);d.useEffect(()=>{u&&u.length!==i.length&&U(C(i,t)),u&&u.length<i.length?l&&r(0):n+1>=g&&r(g-1)},[i,n,t,u,l,g]);const T=()=>{r(Math.min(n+1,g-1))},$=()=>{r(Math.max(0,n-1))},X=i.slice(n*t,n*t+t);return p(q,{children:[a(e,{items:X,...o}),i.length>t?a(Ve,{pageSize:t,totalPages:g,currentPage:n+1,onNext:T,onPrevious:$}):null]})},e),De=({fileInfo:e})=>e.status.type==="uploading"?a(ue,{value:e.status.progress,size:ge.SMALL}):e.status.type==="error"?p(k,{children:[a(we,{"data-testid":"stFileUploaderFileErrorMessage",children:e.status.errorMessage}),a(R,{children:a(f,{content:D,size:"lg"})})]}):e.status.type==="uploaded"?a(I,{children:b(e.size,y.Byte)}):null,Le=({fileInfo:e,onDelete:s})=>p(W,{className:"stFileUploaderFile","data-testid":"stFileUploaderFile",children:[a(ye,{children:a(f,{content:re,size:"twoXL"})}),p(H,{className:"stFileUploaderFileData",children:[a(N,{className:"stFileUploaderFileName","data-testid":"stFileUploaderFileName",title:e.name,children:e.name}),a(De,{fileInfo:e})]}),a("div",{"data-testid":"stFileUploaderDeleteBtn",children:a(F,{onClick:()=>s(e.id),kind:w.MINIMAL,children:a(f,{content:de,size:"lg"})})})]}),Pe=d.memo(Le),Ee=({items:e,onDelete:s})=>a(Fe,{children:e.map(t=>a(A,{children:a(Pe,{fileInfo:t,onDelete:s})},t.id))}),je=Be(Ee),Ae=e=>a(j,{children:a(je,{...e})}),He=d.memo(Ae);class Ne extends d.PureComponent{constructor(s){super(s),this.formClearHelper=new ne,this.localFileIdCounter=1,this.forceUpdatingStatus=!1,this.componentDidUpdate=()=>{if(this.status!=="ready")return;const t=this.createWidgetValue(),{element:i,widgetMgr:l,fragmentId:o}=this.props,n=l.getFileUploaderStateValue(i);Y(t,n)||l.setFileUploaderStateValue(i,t,{fromUi:!0},o)},this.dropHandler=(t,i)=>{const{element:l}=this.props,{multipleFiles:o}=l;if(!o&&t.length===0&&i.length>1){const n=i.findIndex(r=>r.errors.length===1&&r.errors[0].code==="too-many-files");n>=0&&(t.push(i[n].file),i.splice(n,1))}if(this.props.uploadClient.fetchFileURLs(t).then(n=>{if(!o&&t.length>0){const r=this.state.files.find(g=>g.status.type!=="error");r&&(this.forceUpdatingStatus=!0,this.deleteFile(r.id),this.forceUpdatingStatus=!1)}J(n,t).forEach(([r,g])=>{this.uploadFile(r,g)})}).catch(n=>{this.addFiles(t.map(r=>new v(r.name,r.size,this.nextLocalFileId(),{type:"error",errorMessage:n})))}),i.length>0){const n=i.map(r=>ce(r,this.nextLocalFileId(),this.maxUploadSizeInBytes));this.addFiles(n)}},this.uploadFile=(t,i)=>{const l=z.CancelToken.source(),o=new v(i.name,i.size,this.nextLocalFileId(),{type:"uploading",cancelToken:l,progress:1});this.addFile(o),this.props.uploadClient.uploadFile(this.props.element,t.uploadUrl,i,n=>this.onUploadProgress(n,o.id),l.token).then(()=>this.onUploadComplete(o.id,t)).catch(n=>{z.isCancel(n)||this.updateFile(o.id,o.setStatus({type:"error",errorMessage:n?n.toString():"Unknown error"}))})},this.onUploadComplete=(t,i)=>{const l=this.getFile(t);h(l)||l.status.type!=="uploading"||this.updateFile(l.id,l.setStatus({type:"uploaded",fileId:i.fileId,fileUrls:i}))},this.deleteFile=t=>{const i=this.getFile(t);h(i)||(i.status.type==="uploading"&&i.status.cancelToken.cancel(),i.status.type==="uploaded"&&i.status.fileUrls.deleteUrl&&this.props.uploadClient.deleteFile(i.status.fileUrls.deleteUrl),this.removeFile(t))},this.addFile=t=>{m.flushSync(()=>{this.setState(i=>({files:[...i.files,t]}))})},this.addFiles=t=>{m.flushSync(()=>{this.setState(i=>({files:[...i.files,...t]}))})},this.removeFile=t=>{m.flushSync(()=>{this.setState(i=>({files:i.files.filter(l=>l.id!==t)}))})},this.getFile=t=>this.state.files.find(i=>i.id===t),this.updateFile=(t,i)=>{m.flushSync(()=>{this.setState(l=>({files:l.files.map(o=>o.id===t?i:o)}))})},this.onUploadProgress=(t,i)=>{const l=this.getFile(i);if(h(l)||l.status.type!=="uploading")return;const o=Math.round(t.loaded*100/t.total);l.status.progress!==o&&this.updateFile(i,l.setStatus({type:"uploading",cancelToken:l.status.cancelToken,progress:o}))},this.onFormCleared=()=>{m.flushSync(()=>{this.setState({files:[]},()=>{const t=this.createWidgetValue();if(h(t))return;const{widgetMgr:i,element:l,fragmentId:o}=this.props;i.setFileUploaderStateValue(l,t,{fromUi:!0},o)})})},this.state=this.initialValue}get initialValue(){const s={files:[]},{widgetMgr:t,element:i}=this.props,l=t.getFileUploaderStateValue(i);if(h(l))return s;const{uploadedFileInfo:o}=l;return h(o)||o.length===0?s:{files:o.map(n=>{const r=n.name,g=n.size,U=n.fileId,u=n.fileUrls;return new v(r,g,this.nextLocalFileId(),{type:"uploaded",fileId:U,fileUrls:u})})}}componentWillUnmount(){this.formClearHelper.disconnect()}get maxUploadSizeInBytes(){const s=this.props.element.maxUploadSizeMb;return pe(s,y.Megabyte,y.Byte)}get status(){const s=t=>t.status.type==="uploading";return this.state.files.some(s)||this.forceUpdatingStatus?"updating":"ready"}componentDidMount(){const s=this.createWidgetValue(),{element:t,widgetMgr:i,fragmentId:l}=this.props;i.getFileUploaderStateValue(t)===void 0&&i.setFileUploaderStateValue(t,s,{fromUi:!1},l)}createWidgetValue(){const s=this.state.files.filter(t=>t.status.type==="uploaded").map(t=>{const{name:i,size:l,status:o}=t,{fileId:n,fileUrls:r}=o;return new Q({fileId:n,fileUrls:r,name:i,size:l})});return new Z({uploadedFileInfo:s})}render(){const{files:s}=this.state,{element:t,disabled:i,widgetMgr:l,width:o}=this.props,n=t.type;this.formClearHelper.manageFormClearListener(l,t.formId,this.onFormCleared);const r=s.slice().reverse();return p(xe,{className:"stFileUploader","data-testid":"stFileUploader",width:o,children:[a(le,{label:t.label,disabled:i,labelVisibility:ee(t.labelVisibility?.value),children:t.help&&a(te,{children:a(ie,{content:t.help,placement:se.TOP_RIGHT})})}),a(ze,{onDrop:this.dropHandler,multiple:t.multipleFiles,acceptedExtensions:n,maxSizeBytes:this.maxUploadSizeInBytes,label:t.label,disabled:i}),r.length>0&&a(He,{items:r,pageSize:3,onDelete:this.deleteFile,resetOnAdd:!0})]})}nextLocalFileId(){return this.localFileIdCounter++}}const Oe=K(d.memo(Ne));export{Oe as default};
|