@tap-payments/connect-v2 0.0.29-test → 0.0.30-test
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.
- package/build/index.cjs.js +1 -1
- package/build/index.esm.js +54 -33
- package/package.json +1 -1
package/build/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),A=require("react-dom");function R(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const u=R(p);var g=(e=>(e.PAGE="page",e.POPUP="popup",e.CONTENT="content",e))(g||{}),j=(e=>(e.AUTH="auth",e.MERCHANT="merchant",e))(j||{}),_=(e=>(e.SET_PASSWORD="set_password",e.RESET_PASSWORD="reset_password",e))(_||{}),C=(e=>(e.DARK="dark",e.LIGHT="light",e))(C||{}),O=(e=>(e.AR="ar",e.EN="en",e))(O||{}),E=(e=>(e.STRAIGHT="straight",e.CURVED="curved",e))(E||{}),b=(e=>(e.LEFT="left",e.RIGHT="right",e.UP="up",e.DOWN="down",e))(b||{}),l=(e=>(e.ON_CLOSE="connect:onClose",e.ON_ERROR="connect:onError",e.ON_SUCCESS="connect:onSuccess",e.ON_READY="connect:onReady",e.ON_LOADED="connect:onLoaded",e))(l||{}),h=(e=>(e.PROFILE_TOKEN="profile_token",e.CONFIG_TOKEN="config_token",e.THEME="theme",e.LANGUAGE="lang",e))(h||{});const L=({outerStartColor:e="rgba(244, 244, 244, 1)",outerEndColor:n="rgba(238, 238, 238, 1)",innerStartColor:r="rgba(244, 244, 244, 1)",innerEndColor:o="rgba(238, 238, 238, 1)",duration:s=3,toggleAnimation:i=!1})=>t.jsx("div",{style:{position:"relative",width:"135px",height:"135px"},children:t.jsx("div",{style:{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",opacity:.9},children:t.jsxs("svg",{width:"199",height:"197",viewBox:"0 0 199 197",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsxs("g",{children:[t.jsx("circle",{cx:"89.5",cy:"86.5",r:"67.5",fill:"none",stroke:"url(#strokeGradientOuter_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"425 125",children:i&&t.jsxs(t.Fragment,{children:[t.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 89.5 86.5",to:"360 89.5 86.5",dur:`${s/3}s`,repeatCount:"indefinite"}),t.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; 425; 425; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${s}s`,repeatCount:"indefinite"})]})}),t.jsx("circle",{cx:"89.5",cy:"86.5",r:"48",fill:"none",stroke:"url(#strokeGradientInner_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"300 100",children:i&&t.jsxs(t.Fragment,{children:[t.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"360 89.5 86.5",to:"0 89.5 86.5",dur:`${s/3}s`,repeatCount:"indefinite"}),t.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; -300; -300; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${s}s`,repeatCount:"indefinite"})]})})]}),t.jsxs("defs",{children:[t.jsxs("filter",{id:"filter0_dddi_1427_22275",x:"0.882668",y:"0.899429",width:"198.08",height:"195.314",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[t.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),t.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),t.jsx("feOffset",{dy:"1.68224"}),t.jsx("feGaussianBlur",{stdDeviation:"4.20656"}),t.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),t.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 1 0"}),t.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_1427_22275"}),t.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),t.jsx("feOffset",{dx:"22.3542",dy:"22.6047"}),t.jsx("feGaussianBlur",{stdDeviation:"9.80447"}),t.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),t.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0.6 0"}),t.jsx("feBlend",{mode:"normal",in2:"effect1_dropShadow_1427_22275",result:"effect2_dropShadow_1427_22275"}),t.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),t.jsx("feOffset",{dx:"-6.03352",dy:"-3.01676"}),t.jsx("feGaussianBlur",{stdDeviation:"7.5419"}),t.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),t.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.7 0"}),t.jsx("feBlend",{mode:"normal",in2:"effect2_dropShadow_1427_22275",result:"effect3_dropShadow_1427_22275"}),t.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect3_dropShadow_1427_22275",result:"shape"}),t.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),t.jsx("feOffset",{dy:"1.50838"}),t.jsx("feComposite",{in2:"hardAlpha",operator:"arithmetic",k2:"-1",k3:"1"}),t.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"}),t.jsx("feBlend",{mode:"normal",in2:"shape",result:"effect4_innerShadow_1427_22275"})]}),t.jsxs("linearGradient",{id:"strokeGradientOuter_1427_22275",x1:"89.5",y1:"19",x2:"89.5",y2:"154",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{stopColor:e}),t.jsx("stop",{offset:"1",stopColor:n})]}),t.jsxs("linearGradient",{id:"strokeGradientInner_1427_22275",x1:"89.4991",y1:"38.2849",x2:"89.4991",y2:"134.713",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{stopColor:r}),t.jsx("stop",{offset:"1",stopColor:o})]})]})]})})}),T=p.memo(L),N=p.createContext({}),v=()=>p.useContext(N);function U({children:e,props:n}){const[r,o]=p.useState(!1),s=a=>{o(a)},i=()=>{o(!1)};return t.jsx(N.Provider,{value:{...n,onLoadingHandler:s,loading:r,onLoaded:i},children:e})}const G="https://connect-mw.dev.tap.company/middleware/v3/connect",I="https://connect-mw.dev.tap.company/middleware/v3/connect",D="https://connect-mw.dev.tap.company/middleware/v3/connect",P="tap-connect-sdk-iframe",x="https://connect.alpha.tap.company",F=({src:e})=>{const{loading:n}=v();return t.jsxs(t.Fragment,{children:[n&&t.jsx(T,{toggleAnimation:!0}),e&&t.jsx("iframe",{id:P,title:"connect",src:e,style:{width:"100%",height:"100%",border:"none",position:"absolute",top:0,left:0}})]})};var B=function(e){var n,r;return((r=(n=e==null?void 0:e.response)===null||n===void 0?void 0:n.data)===null||r===void 0?void 0:r.errors)!==void 0},M=function(e){return e instanceof Error},$=function(e){return typeof e=="string"},H=function(e){try{var n=e.response.data.errors,r=n[0],o=r.description,s=r.code;return{message:o,code:s}}catch(i){return{message:i.message,code:"UNKNOWN"}}},W=function(e){try{var n=e.message,r=n.split("::"),o=r[0],s=r[1];return{message:s,code:o}}catch(i){return{message:i.message,code:"UNKNOWN"}}},K=function(e){try{var n=e.split("::"),r=n[0],o=n[1];return{message:o,code:r}}catch(s){return{message:s,code:"UNKNOWN"}}},q=function(){function e(n){if(Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"message",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),B(n)){var r=H(n);this.code=r.code,this.message=r.message}else if(M(n)){var r=W(n);this.code=r.code,this.message=r.message}else if($(n)){var r=K(n);this.code=r.code,this.message=r.message}else this.code="UNKNOWN",this.message="Unknown error"}return Object.defineProperty(e.prototype,"getCode",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.code}}),Object.defineProperty(e.prototype,"getMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.message}}),Object.defineProperty(e.prototype,"getClientError",{enumerable:!1,configurable:!0,writable:!0,value:function(){return{message:this.message,code:this.code}}}),e}();const z=(e="tap-connect-sdk-element")=>{const n=document.getElementById(e);if(n)return n;const r=document.createElement("div");return r.setAttribute("id",e),document.body.prepend(r),r},Y=e=>e?["sa","sau"].includes(e.toLowerCase()):!1,J=e=>e==="dr",V=(e="")=>{const[n,r]=e.split("-");return Y(n)?J(r)?D:I:G},Q=e=>{var n;return{...e,board:{display:e.showBoard,editable:e.boardEditable},operator:{public_key:e.publicKey},...((n=e.features)==null?void 0:n.dialogEdgeFormat)&&{interface:{edges:e.features.dialogEdgeFormat}},...e.leadId&&{lead:{id:e.leadId}},...e.postUrl&&{post:{url:e.postUrl}},...e.redirectUrl&&{redirect:{url:e.redirectUrl}}}},X=()=>{const[e,n]=u.useState(""),{onError:r,onLoadingHandler:o,loginMode:s,region:i,...a}=v(),f=async()=>{o(!0);try{const c=await fetch(V(i),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.publicKey}`,mdn:x},body:JSON.stringify(Q(a))});if(!c.ok)throw new Error(`${c.status}::${c.statusText}`);const d=await c.json(),m=new URLSearchParams;a!=null&&a.theme&&m.append(h.THEME,a.theme),a!=null&&a.language&&m.append(h.LANGUAGE,a.language);const k=s?`${x}/auth`:x;if(m.append(h.CONFIG_TOKEN,d.token),d.connect.url=`${k}?${m.toString()}`,a.mode!==g.PAGE)return n(d.connect.url);window.location.href=d.connect.url}catch(c){const d=new q(c);r==null||r(d.getClientError()),o(!1)}};return u.useEffect(()=>{f()},[]),{connectLink:e}},Z=()=>{const{onSuccess:e,onClose:n,onError:r,onReady:o,onLoaded:s}=v(),i=u.useCallback(async a=>{if(a.origin!==x)return;const{data:f,event:c}=a.data;switch(c){case l.ON_CLOSE:n==null||n();break;case l.ON_ERROR:r==null||r(f);break;case l.ON_SUCCESS:e(f);break;case l.ON_LOADED:s();break;case l.ON_READY:o==null||o();break}},[n,r,s,o,e]);u.useEffect(()=>(window.addEventListener("message",i,!1),()=>{window.removeEventListener("message",i)}),[i])},ee=()=>{const{connectLink:e}=X();return Z(),t.jsx("div",{id:"tap-connect-main-container",style:{display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.5)",position:"fixed",top:0,left:0,width:"100%",height:"100%"},children:t.jsx(F,{src:e})})},te=e=>t.jsx(U,{props:e,children:e.open&&t.jsx(ee,{})}),w=u.memo(te);var S,y=A;S=y.createRoot,y.hydrateRoot;const re=(e,n)=>{const r=z(e),o=S(r);return o.render(t.jsx(w,{...n})),{unmount:()=>o.unmount()}};exports.ConnectDialogEdgeFormat=E;exports.ConnectDialogTransition=b;exports.ConnectElement=w;exports.ConnectLanguage=O;exports.ConnectMode=g;exports.ConnectPasswordOperationType=_;exports.ConnectScope=j;exports.ConnectTheme=C;exports.renderConnectElement=re;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),A=require("react-dom");function R(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const u=R(p);var v=(e=>(e.PAGE="page",e.POPUP="popup",e.CONTENT="content",e))(v||{}),_=(e=>(e.AUTH="auth",e.MERCHANT="merchant",e))(_||{}),j=(e=>(e.SET_PASSWORD="set_password",e.RESET_PASSWORD="reset_password",e))(j||{}),C=(e=>(e.DARK="dark",e.LIGHT="light",e))(C||{}),E=(e=>(e.AR="ar",e.EN="en",e))(E||{}),O=(e=>(e.STRAIGHT="straight",e.CURVED="curved",e))(O||{}),b=(e=>(e.LEFT="left",e.RIGHT="right",e.UP="up",e.DOWN="down",e))(b||{}),l=(e=>(e.ON_CLOSE="connect:onClose",e.ON_ERROR="connect:onError",e.ON_SUCCESS="connect:onSuccess",e.ON_READY="connect:onReady",e.ON_LOADED="connect:onLoaded",e))(l||{}),h=(e=>(e.PROFILE_TOKEN="profile_token",e.CONFIG_TOKEN="config_token",e.THEME="theme",e.LANGUAGE="lang",e))(h||{});const L=({outerStartColor:e="rgba(244, 244, 244, 1)",outerEndColor:n="rgba(238, 238, 238, 1)",innerStartColor:r="rgba(244, 244, 244, 1)",innerEndColor:o="rgba(238, 238, 238, 1)",duration:s=3,toggleAnimation:i=!1})=>t.jsx("div",{style:{position:"relative",width:"135px",height:"135px"},children:t.jsx("div",{style:{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",opacity:.9},children:t.jsxs("svg",{width:"199",height:"197",viewBox:"0 0 199 197",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsxs("g",{children:[t.jsx("circle",{cx:"89.5",cy:"86.5",r:"67.5",fill:"none",stroke:"url(#strokeGradientOuter_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"425 125",children:i&&t.jsxs(t.Fragment,{children:[t.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 89.5 86.5",to:"360 89.5 86.5",dur:`${s/3}s`,repeatCount:"indefinite"}),t.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; 425; 425; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${s}s`,repeatCount:"indefinite"})]})}),t.jsx("circle",{cx:"89.5",cy:"86.5",r:"48",fill:"none",stroke:"url(#strokeGradientInner_1427_22275)",strokeWidth:"9.6",strokeLinecap:"round",strokeDasharray:"300 100",children:i&&t.jsxs(t.Fragment,{children:[t.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"360 89.5 86.5",to:"0 89.5 86.5",dur:`${s/3}s`,repeatCount:"indefinite"}),t.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; -300; -300; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${s}s`,repeatCount:"indefinite"})]})})]}),t.jsxs("defs",{children:[t.jsxs("filter",{id:"filter0_dddi_1427_22275",x:"0.882668",y:"0.899429",width:"198.08",height:"195.314",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[t.jsx("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),t.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),t.jsx("feOffset",{dy:"1.68224"}),t.jsx("feGaussianBlur",{stdDeviation:"4.20656"}),t.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),t.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 0 0.824495 0 0 0 1 0"}),t.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_1427_22275"}),t.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),t.jsx("feOffset",{dx:"22.3542",dy:"22.6047"}),t.jsx("feGaussianBlur",{stdDeviation:"9.80447"}),t.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),t.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0 0.740723 0 0 0 0.6 0"}),t.jsx("feBlend",{mode:"normal",in2:"effect1_dropShadow_1427_22275",result:"effect2_dropShadow_1427_22275"}),t.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),t.jsx("feOffset",{dx:"-6.03352",dy:"-3.01676"}),t.jsx("feGaussianBlur",{stdDeviation:"7.5419"}),t.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),t.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.7 0"}),t.jsx("feBlend",{mode:"normal",in2:"effect2_dropShadow_1427_22275",result:"effect3_dropShadow_1427_22275"}),t.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect3_dropShadow_1427_22275",result:"shape"}),t.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),t.jsx("feOffset",{dy:"1.50838"}),t.jsx("feComposite",{in2:"hardAlpha",operator:"arithmetic",k2:"-1",k3:"1"}),t.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"}),t.jsx("feBlend",{mode:"normal",in2:"shape",result:"effect4_innerShadow_1427_22275"})]}),t.jsxs("linearGradient",{id:"strokeGradientOuter_1427_22275",x1:"89.5",y1:"19",x2:"89.5",y2:"154",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{stopColor:e}),t.jsx("stop",{offset:"1",stopColor:n})]}),t.jsxs("linearGradient",{id:"strokeGradientInner_1427_22275",x1:"89.4991",y1:"38.2849",x2:"89.4991",y2:"134.713",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{stopColor:r}),t.jsx("stop",{offset:"1",stopColor:o})]})]})]})})}),T=p.memo(L),N=p.createContext({}),g=()=>p.useContext(N);function U({children:e,props:n}){const[r,o]=p.useState(!1),s=a=>{o(a)},i=()=>{o(!1)};return t.jsx(N.Provider,{value:{...n,onLoadingHandler:s,loading:r,onLoaded:i},children:e})}const G="https://connect-mw.dev.tap.company/middleware/v3/connect",I="https://connect-mw.dev.tap.company/middleware/v3/connect",D="https://connect-mw.dev.tap.company/middleware/v3/connect",P="tap-connect-sdk-iframe",x="https://connect.alpha.tap.company",F=({src:e})=>{const{loading:n}=g();return t.jsxs(t.Fragment,{children:[n&&t.jsx(T,{toggleAnimation:!0}),e&&t.jsx("iframe",{id:P,title:"connect",src:e,style:{width:"100%",height:"100%",border:"none",position:"absolute",top:0,left:0}})]})};var B=function(e){var n,r;return((r=(n=e==null?void 0:e.response)===null||n===void 0?void 0:n.data)===null||r===void 0?void 0:r.errors)!==void 0},M=function(e){return e instanceof Error},$=function(e){return typeof e=="string"},H=function(e){try{var n=e.response.data.errors,r=n[0],o=r.description,s=r.code;return{message:o,code:s}}catch(i){return{message:i.message,code:"UNKNOWN"}}},W=function(e){try{var n=e.message,r=n.split("::"),o=r[0],s=r[1];return{message:s,code:o}}catch(i){return{message:i.message,code:"UNKNOWN"}}},K=function(e){try{var n=e.split("::"),r=n[0],o=n[1];return{message:o,code:r}}catch(s){return{message:s,code:"UNKNOWN"}}},q=function(){function e(n){if(Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"message",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),B(n)){var r=H(n);this.code=r.code,this.message=r.message}else if(M(n)){var r=W(n);this.code=r.code,this.message=r.message}else if($(n)){var r=K(n);this.code=r.code,this.message=r.message}else this.code="UNKNOWN",this.message="Unknown error"}return Object.defineProperty(e.prototype,"getCode",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.code}}),Object.defineProperty(e.prototype,"getMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.message}}),Object.defineProperty(e.prototype,"getClientError",{enumerable:!1,configurable:!0,writable:!0,value:function(){return{message:this.message,code:this.code}}}),e}();const z=(e="tap-connect-sdk-element")=>{const n=document.getElementById(e);if(n)return n;const r=document.createElement("div");return r.setAttribute("id",e),document.body.prepend(r),r},Y=e=>e?["sa","sau"].includes(e.toLowerCase()):!1,J=e=>e==="dr",V=(e="")=>{const[n,r]=e.split("-");return Y(n)?J(r)?D:I:G},Q=e=>{var n,r;return{open:e.open,theme:e.theme,operator:{public_key:e.publicKey},merchant_domain:e.merchantDomain,app_info:e.appInfo,business_country_code:e.businessCountryCode,scope:e.scope,board:{display:e.showBoard,editable:e.boardEditable},...e.leadId&&{lead:{id:e.leadId}},platforms:e.platforms,payment_provider:e.paymentProvider,features:e.features,...e.postUrl&&{post:{url:e.postUrl}},...e.redirectUrl&&{redirect:{url:e.redirectUrl}},data:e.data,mode:e.mode,notification:e.notification,...(((n=e.features)==null?void 0:n.dialogEdgeFormat)||e.language)&&{interface:{...((r=e.features)==null?void 0:r.dialogEdgeFormat)&&{edges:e.features.dialogEdgeFormat},locale:e.language}}}},X=()=>{const[e,n]=u.useState(""),{onError:r,onLoadingHandler:o,loginMode:s,region:i,...a}=g(),m=async()=>{o(!0);try{const d=await fetch(V(i),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.publicKey}`,mdn:a.merchantDomain||x},body:JSON.stringify(Q(a))});if(!d.ok)throw new Error(`${d.status}::${d.statusText}`);const c=await d.json(),f=new URLSearchParams;a!=null&&a.theme&&f.append(h.THEME,a.theme),a!=null&&a.language&&f.append(h.LANGUAGE,a.language);const k=s?`${x}/auth`:x;if(f.append(h.CONFIG_TOKEN,c.token),c.connect.url=`${k}?${f.toString()}`,a.mode!==v.PAGE)return n(c.connect.url);window.location.href=c.connect.url}catch(d){const c=new q(d);r==null||r(c.getClientError()),o(!1)}};return u.useEffect(()=>{m()},[]),{connectLink:e}},Z=()=>{const{onSuccess:e,onClose:n,onError:r,onReady:o,onLoaded:s}=g(),i=u.useCallback(async a=>{if(a.origin!==x)return;const{data:m,event:d}=a.data;switch(d){case l.ON_CLOSE:n==null||n();break;case l.ON_ERROR:r==null||r(m);break;case l.ON_SUCCESS:e(m);break;case l.ON_LOADED:s();break;case l.ON_READY:o==null||o();break}},[n,r,s,o,e]);u.useEffect(()=>(window.addEventListener("message",i,!1),()=>{window.removeEventListener("message",i)}),[i])},ee=()=>{const{connectLink:e}=X();return Z(),t.jsx("div",{id:"tap-connect-main-container",style:{display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.5)",position:"fixed",top:0,left:0,width:"100%",height:"100%"},children:t.jsx(F,{src:e})})},te=e=>t.jsx(U,{props:e,children:e.open&&t.jsx(ee,{})}),w=u.memo(te);var S,y=A;S=y.createRoot,y.hydrateRoot;const re=(e,n)=>{const r=z(e),o=S(r);return o.render(t.jsx(w,{...n})),{unmount:()=>o.unmount()}};exports.ConnectDialogEdgeFormat=O;exports.ConnectDialogTransition=b;exports.ConnectElement=w;exports.ConnectLanguage=E;exports.ConnectMode=v;exports.ConnectPasswordOperationType=j;exports.ConnectScope=_;exports.ConnectTheme=C;exports.renderConnectElement=re;
|
package/build/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as t, jsxs as d, Fragment as
|
|
1
|
+
import { jsx as t, jsxs as d, Fragment as _ } from "react/jsx-runtime";
|
|
2
2
|
import * as p from "react";
|
|
3
|
-
import
|
|
3
|
+
import y from "react";
|
|
4
4
|
import w from "react-dom";
|
|
5
5
|
var C = /* @__PURE__ */ ((e) => (e.PAGE = "page", e.POPUP = "popup", e.CONTENT = "content", e))(C || {}), x = /* @__PURE__ */ ((e) => (e.AUTH = "auth", e.MERCHANT = "merchant", e))(x || {}), k = /* @__PURE__ */ ((e) => (e.SET_PASSWORD = "set_password", e.RESET_PASSWORD = "reset_password", e))(k || {}), S = /* @__PURE__ */ ((e) => (e.DARK = "dark", e.LIGHT = "light", e))(S || {}), A = /* @__PURE__ */ ((e) => (e.AR = "ar", e.EN = "en", e))(A || {}), R = /* @__PURE__ */ ((e) => (e.STRAIGHT = "straight", e.CURVED = "curved", e))(R || {}), L = /* @__PURE__ */ ((e) => (e.LEFT = "left", e.RIGHT = "right", e.UP = "up", e.DOWN = "down", e))(L || {}), u = /* @__PURE__ */ ((e) => (e.ON_CLOSE = "connect:onClose", e.ON_ERROR = "connect:onError", e.ON_SUCCESS = "connect:onSuccess", e.ON_READY = "connect:onReady", e.ON_LOADED = "connect:onLoaded", e))(u || {}), h = /* @__PURE__ */ ((e) => (e.PROFILE_TOKEN = "profile_token", e.CONFIG_TOKEN = "config_token", e.THEME = "theme", e.LANGUAGE = "lang", e))(h || {});
|
|
6
6
|
const U = ({
|
|
@@ -43,7 +43,7 @@ const U = ({
|
|
|
43
43
|
strokeWidth: "9.6",
|
|
44
44
|
strokeLinecap: "round",
|
|
45
45
|
strokeDasharray: "425 125",
|
|
46
|
-
children: i && /* @__PURE__ */ d(
|
|
46
|
+
children: i && /* @__PURE__ */ d(_, { children: [
|
|
47
47
|
/* @__PURE__ */ t(
|
|
48
48
|
"animateTransform",
|
|
49
49
|
{
|
|
@@ -79,7 +79,7 @@ const U = ({
|
|
|
79
79
|
strokeWidth: "9.6",
|
|
80
80
|
strokeLinecap: "round",
|
|
81
81
|
strokeDasharray: "300 100",
|
|
82
|
-
children: i && /* @__PURE__ */ d(
|
|
82
|
+
children: i && /* @__PURE__ */ d(_, { children: [
|
|
83
83
|
/* @__PURE__ */ t(
|
|
84
84
|
"animateTransform",
|
|
85
85
|
{
|
|
@@ -212,18 +212,18 @@ const U = ({
|
|
|
212
212
|
}
|
|
213
213
|
)
|
|
214
214
|
}
|
|
215
|
-
), G =
|
|
215
|
+
), G = y.memo(U), N = y.createContext({}), g = () => y.useContext(N);
|
|
216
216
|
function I({ children: e, props: n }) {
|
|
217
|
-
const [r, o] =
|
|
217
|
+
const [r, o] = y.useState(!1), a = (s) => {
|
|
218
218
|
o(s);
|
|
219
219
|
}, i = () => {
|
|
220
220
|
o(!1);
|
|
221
221
|
};
|
|
222
222
|
return /* @__PURE__ */ t(N.Provider, { value: { ...n, onLoadingHandler: a, loading: r, onLoaded: i }, children: e });
|
|
223
223
|
}
|
|
224
|
-
const T = "https://connect-mw.dev.tap.company/middleware/v3/connect",
|
|
225
|
-
const { loading: n } =
|
|
226
|
-
return /* @__PURE__ */ d(
|
|
224
|
+
const T = "https://connect-mw.dev.tap.company/middleware/v3/connect", D = "https://connect-mw.dev.tap.company/middleware/v3/connect", B = "https://connect-mw.dev.tap.company/middleware/v3/connect", F = "tap-connect-sdk-iframe", v = "https://connect.alpha.tap.company", P = ({ src: e }) => {
|
|
225
|
+
const { loading: n } = g();
|
|
226
|
+
return /* @__PURE__ */ d(_, { children: [
|
|
227
227
|
n && /* @__PURE__ */ t(G, { toggleAnimation: !0 }),
|
|
228
228
|
e && /* @__PURE__ */ t(
|
|
229
229
|
"iframe",
|
|
@@ -346,60 +346,81 @@ const q = (e = "tap-connect-sdk-element") => {
|
|
|
346
346
|
return r.setAttribute("id", e), document.body.prepend(r), r;
|
|
347
347
|
}, z = (e) => e ? ["sa", "sau"].includes(e.toLowerCase()) : !1, J = (e) => e === "dr", V = (e = "") => {
|
|
348
348
|
const [n, r] = e.split("-");
|
|
349
|
-
return z(n) ? J(r) ?
|
|
349
|
+
return z(n) ? J(r) ? B : D : T;
|
|
350
350
|
}, Q = (e) => {
|
|
351
|
-
var n;
|
|
351
|
+
var n, r;
|
|
352
352
|
return {
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
open: e.open,
|
|
354
|
+
theme: e.theme,
|
|
355
355
|
operator: { public_key: e.publicKey },
|
|
356
|
-
|
|
356
|
+
merchant_domain: e.merchantDomain,
|
|
357
|
+
// TODO: need to confirm with backend
|
|
358
|
+
app_info: e.appInfo,
|
|
359
|
+
// TODO: need to confirm with backend
|
|
360
|
+
business_country_code: e.businessCountryCode,
|
|
361
|
+
// TODO: need to confirm with backend
|
|
362
|
+
scope: e.scope,
|
|
363
|
+
board: { display: e.showBoard, editable: e.boardEditable },
|
|
357
364
|
...e.leadId && { lead: { id: e.leadId } },
|
|
365
|
+
platforms: e.platforms,
|
|
366
|
+
payment_provider: e.paymentProvider,
|
|
367
|
+
// TODO: need to confirm with backend
|
|
368
|
+
features: e.features,
|
|
369
|
+
// TODO: need to confirm with backend
|
|
358
370
|
...e.postUrl && { post: { url: e.postUrl } },
|
|
359
|
-
...e.redirectUrl && { redirect: { url: e.redirectUrl } }
|
|
371
|
+
...e.redirectUrl && { redirect: { url: e.redirectUrl } },
|
|
372
|
+
data: e.data,
|
|
373
|
+
mode: e.mode,
|
|
374
|
+
notification: e.notification,
|
|
375
|
+
...(((n = e.features) == null ? void 0 : n.dialogEdgeFormat) || e.language) && {
|
|
376
|
+
interface: {
|
|
377
|
+
...((r = e.features) == null ? void 0 : r.dialogEdgeFormat) && { edges: e.features.dialogEdgeFormat },
|
|
378
|
+
locale: e.language
|
|
379
|
+
}
|
|
380
|
+
}
|
|
360
381
|
};
|
|
361
382
|
}, X = () => {
|
|
362
|
-
const [e, n] = p.useState(""), { onError: r, onLoadingHandler: o, loginMode: a, region: i, ...s } =
|
|
383
|
+
const [e, n] = p.useState(""), { onError: r, onLoadingHandler: o, loginMode: a, region: i, ...s } = g(), m = async () => {
|
|
363
384
|
o(!0);
|
|
364
385
|
try {
|
|
365
|
-
const
|
|
386
|
+
const l = await fetch(V(i), {
|
|
366
387
|
method: "POST",
|
|
367
388
|
headers: {
|
|
368
389
|
"Content-Type": "application/json",
|
|
369
390
|
Authorization: `Bearer ${s.publicKey}`,
|
|
370
|
-
mdn: v
|
|
391
|
+
mdn: s.merchantDomain || v
|
|
371
392
|
},
|
|
372
393
|
body: JSON.stringify(Q(s))
|
|
373
394
|
});
|
|
374
|
-
if (!
|
|
375
|
-
throw new Error(`${
|
|
376
|
-
const
|
|
377
|
-
s != null && s.theme &&
|
|
395
|
+
if (!l.ok)
|
|
396
|
+
throw new Error(`${l.status}::${l.statusText}`);
|
|
397
|
+
const c = await l.json(), f = new URLSearchParams();
|
|
398
|
+
s != null && s.theme && f.append(h.THEME, s.theme), s != null && s.language && f.append(h.LANGUAGE, s.language);
|
|
378
399
|
const b = a ? `${v}/auth` : v;
|
|
379
|
-
if (
|
|
380
|
-
window.location.href =
|
|
381
|
-
} catch (
|
|
382
|
-
const
|
|
383
|
-
r == null || r(
|
|
400
|
+
if (f.append(h.CONFIG_TOKEN, c.token), c.connect.url = `${b}?${f.toString()}`, s.mode !== C.PAGE) return n(c.connect.url);
|
|
401
|
+
window.location.href = c.connect.url;
|
|
402
|
+
} catch (l) {
|
|
403
|
+
const c = new Y(l);
|
|
404
|
+
r == null || r(c.getClientError()), o(!1);
|
|
384
405
|
}
|
|
385
406
|
};
|
|
386
407
|
return p.useEffect(() => {
|
|
387
|
-
|
|
408
|
+
m();
|
|
388
409
|
}, []), { connectLink: e };
|
|
389
410
|
}, Z = () => {
|
|
390
|
-
const { onSuccess: e, onClose: n, onError: r, onReady: o, onLoaded: a } =
|
|
411
|
+
const { onSuccess: e, onClose: n, onError: r, onReady: o, onLoaded: a } = g(), i = p.useCallback(
|
|
391
412
|
async (s) => {
|
|
392
413
|
if (s.origin !== v) return;
|
|
393
|
-
const { data:
|
|
394
|
-
switch (
|
|
414
|
+
const { data: m, event: l } = s.data;
|
|
415
|
+
switch (l) {
|
|
395
416
|
case u.ON_CLOSE:
|
|
396
417
|
n == null || n();
|
|
397
418
|
break;
|
|
398
419
|
case u.ON_ERROR:
|
|
399
|
-
r == null || r(
|
|
420
|
+
r == null || r(m);
|
|
400
421
|
break;
|
|
401
422
|
case u.ON_SUCCESS:
|
|
402
|
-
e(
|
|
423
|
+
e(m);
|
|
403
424
|
break;
|
|
404
425
|
case u.ON_LOADED:
|
|
405
426
|
a();
|